Maven2 complex with Flex4 installation

I'm trying to get Maven2 to work with me, and I was wondering if anyone has any ideas on how to do this ... I'm working on a Flash project and we are considering moving from our hybrid Flex4 / FlashCS4 with Clean Flex4 Solution. We would like to use the Maven2 build system so that our developers do not have to manually download, install and configure Flex4 on their machines.

I managed to create a single-module project using Maven2 with Flex4 (I use the Sonatype FlexMojos plugin and their Maven2 repository located at http://repository.sonatype.org/content/groups/flexgroup/ ). I am really starting to face difficulties when it comes to creating this multi-module ....

Our project is organized as follows:

 | - bin
 | | - moduleX.swf
 | | - moduleY.swf
 | | - ...
 | - lib
 | | - moduleA.swc
 | | - moduleB.swc
 | | - ...
 | - src
 | | - moduleA
 | | - moduleB
 | | - ...
 | - test
 | | - moduleA
 | | - moduleB
 | | - ...
 | - share
 | | - asset1
 | | - asset2
 | | - ...
 | - ...

, , "src/<modulename> /" , "test/<modulename> /", SWF, "bin" SWC , "lib". (, , "@Embed" "[Embed]", "share". , , . , , , . , - , "pom.xml", .

+3
2

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, ).

:

:

<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 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>
+3

:

Root
 |- Module a
 |  |- src
 |- Module b
 |  |- src
 |- Module c
 |  |- src

, , Maven , .

; pom , src src test.

, .

root
 |- ModuleA
 |  |- pom.xml, src points to root/src/moduleA
 |- ModuleB
 |  |- pom.xml, src points to root/src/moduleB
 |- src
 |  |- moduleA
 |  |- moduleB
 |  |- ...
 |- test
 |  |- moduleA
 |  |- moduleB
0

Source: https://habr.com/ru/post/1718624/


All Articles