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
|-...
share
関連するセット (すべての共有モジュールを含む pom など) を構築できるように、一時的な pom を追加することもできます。
次に、次のことができます。
- ソースをビルドできるように、適切な相対パスで各 pom を構成します。
Embed
リソースを target/flex/resourcesにアンパックするように maven-dependency-plugin を設定します
- build-helper-maven-pluginを使用して、target/flex/resources をリソースの場所として設定します (プラグインは埋め込みリソースが src/main/resources にあると想定しているため、これは実際には機能しない可能性があることに注意してください)
- モジュール間の適切な依存関係を定義します。
- maven-antrun-pluginを使用して、最終成果物を既存の bin ディレクトリにコピーします (project.build.outputDirectory を設定して同じ出力ディレクトリを使用しようとした場合、1 つのモジュールを消去すると他のビルドが破壊されます)。
以下は、pom の 1 つでこれらの手順を実行するための構成例です。
<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>