如果您确定要迁移到Maven 2,那么修改项目结构以使每个模块都包含自己的源代码和测试并遵循Maven约定将为您省去很多麻烦。
如果您真的不能这样做,您可以创建一个并行模块层次结构,并使用指向现有结构的相对路径配置每个模块。结构可能最终看起来像这样:
|- Maven Root
| |- pom.xml
| |- ModuleA
| | |- pom.xml
| |- ModuleB
| | |- pom.xml
| |- ModuleX
| | |- pom.xml
| |- ModuleY
| | |- pom.xml
| |- asset1
| | |- pom.xml
| |-...
|
|- Existing-Root
|- bin
| |- moduleX.swf
| |- moduleY.swf
| |- ...
|- lib
| |- moduleA.swc
| |- moduleB.swc
| |- ...
|- src
| |- moduleA
| |- moduleB
|-...
您可能还希望添加临时POM,以便可以构建相关集(例如
share
包含所有共享模块的pom)。
以下是为其中一个POM实现这些步骤的示例配置:
<build>
<!--configure the source and test sources to point to the existing structure-->
<sourceDirectory>
${baseDir}/../../Existing-Root/test/${project.artifactId}
</sourceDirectory>
<testSourceDirectory>
${baseDir}/../../Existing-Root/src/${project.artifactId}
</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.sonatype.flexmojos</groupId>
<artifactId>flexmojos-maven-plugin</artifactId>
<version>3.2.0</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<!--unpack asset1 to target/flex/resources,
define any additional artifacts for other shares-->
<artifactItem>
<groupId>my.group.id</groupId>
<artifactId>asset1</artifactId>
<version>1.0.0</version>
<type>swf</type>
</artifactItem>
</artifactItems>
<outputDirectory>
${project.build.directory}/flex/resources
</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!--add target/flex/resources as a resource location-->
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>add-resource</id>
<phase>generate-resources</phase>
<goals>
<goal>add-resources</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>
${project.build.directory}/flex/resources
</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>pre-integration-test</phase>
<configuration>
<tasks>
<!--copy the final artifact to the module's bin directory-->
<copy
file="${project.artifactId}-${project.version}.${project.packaging}"
todir="${baseDir}/../../Existing-Root/bin/${project.artifactId}"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
...
</build>