我已经挣扎着获得Maven2与我合作,并想知道如果任何人有任何想法怎么得到这个工作。...我工作上的闪光灯项目,并且我们正在考虑交换,从我们的混合Flex4/FlashCS4为一个纯粹的Flex4的解决方案。我们想利用的Maven2建立系统,因此,我们的开发不必手动下载,安装和配置Flex4在他们的机器。

我们设法建立一个单一的模块项目使用Maven2与Flex4(I am使用Sonatype FlexMojos插件和其Maven2库位于 http://repository.sonatype.org/content/groups/flexgroup/).我真的开始运行到麻烦的时候就是做这个多模....

我们的项目是安排如下:

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

基本上,我们每个模块都有其来源的位于下"src/<modulename>/"及其试验的来源位于根据"测试/<modulename>/",产生的SWF的文件被放置在"bin"和产生SWC的文件被放置在"lib".我们的资产(事情,我们希望能够参考使用的"@嵌入"或"[嵌入]"标签)生活在"共享"。我已经看过引用上项目的继承和聚集,但似乎无法找到任何东西,将使我们能够保持我们现有的项目目录结构。我们希望这种迁移是为快速、无痛,而非破坏性作为可能。我真的很欣赏它,如果任何人都可以弄清楚如何建立一个"pom.xml"文件,使我们能够保持我们现有的基础设施。

有帮助吗?

解决方案

如果你是某些有关移动给家2,这会节省很多的痛苦,以修改该项目的结构使每一个模块包含其自己的来源和试验和遵行公约。

如果你真的不能做到这一点,您可以创建一个平行的模块层次结构,并配置,每个模块相对道路指向回到现有的结构。结构可能最终在寻找像这样的东西:

|- 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与适当的相对路径,以便它可以建立它的来源。
  • 配置家依赖件解开 Embed 资源为目标/flex/资源
  • 使用 建立辅助-玛文件 设定目标/flex/资源作为资源的位置(注意,这可能不实际工作,因为插件嵌入预计资源将在src/main/资源)
  • 定义的适当之间的依赖关系的模块。
  • 使用 专家-antrun-插件 复制的最后文物的现有bin directory(如果你试图使用相同的输出目录的通过设置项目。建立。outputDirectory,但后一个干净的一个模块将会破坏其他基础).

这里是一个例子配置来实现这些步骤对于一个劲歌:

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

其他提示

一个多模块项目应该是这样的

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

在一个项目中有多个来源是好的,如果你打算建立一个单一的神器,但是如果你正在试图建立来自多个来源的多个工件在一个项目中Maven的不配合。

如果您不能左右移动源树;创建在当前结构的多聚甲醛模块层次结构和编辑新的子-POMS指向他们的src和测试目录到电流源层次src和测试目录。

可以具有输出文件夹的所有点到同一文件夹,以及

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
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top