带有 Flex4 设置的复杂 Maven2

2024-01-12

我一直在努力让 Maven2 与我合作,并且想知道是否有人对如何使其工作有任何想法......我正在开发一个 Flash 项目,我们正在考虑从我们的混合 Flex4/ 切换FlashCS4 到纯粹的 Flex4 解决方案。我们希望使用 Maven2 构建系统,这样我们的开发人员就不必在他们的机器上手动下载、安装和配置 Flex4。

我已经成功地使用 Maven2 和 Flex4 创建了一个单模块项目(我使用的是 Sonatype FlexMojos 插件及其 Maven2 存储库,位于 http://repository.sonatype.org/content/groups/flexgroup/http://repository.sonatype.org/content/groups/flexgroup/ 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//”下,其测试源位于“test//”下,生成的 SWF 文件放置在“bin”中,生成的 SWC 文件放置在“bin”中在“lib”中。我们的资产(我们希望能够使用“@Embed”或“[Embed]”标签引用的内容)位于“共享”下。我查看了有关项目继承和聚合的参考资料,但似乎找不到任何可以让我们保留现有项目目录结构的内容。我们希望这次迁移尽可能快速、无痛且无中断。如果有人能够弄清楚如何创建一个“pom.xml”文件来允许我们保留当前的基础设施,我将非常感激。


如果您确定要迁移到 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,以便可以构建相关集(例如sharepom 包含所有共享模块)。

然后你可以:

  • 使用适当的相对路径配置每个 pom,以便它可以构建其源。
  • 配置maven-dependency-plugin来解压Embed资源进入目标/弹性/资源
  • use the 构建助手 maven 插件 http://maven.apache.org/plugins/maven-dependency-plugin/将 target/flex/resources 设置为资源位置(请注意,这实际上可能不起作用,因为插件期望嵌入资源位于 src/main/resources 中)
  • 定义模块之间适当的依赖关系。
  • use the maven-antrun-插件 http://maven.apache.org/plugins/maven-antrun-plugin/将最终工件复制到现有的 bin 目录(如果您尝试通过设置 project.build.outputDirectory 来使用相同的输出目录,但清理一个模块将破坏其他构建)。

下面是一个示例配置,用于实现其中一个 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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

带有 Flex4 设置的复杂 Maven2 的相关文章

  • spring-data-jpa 和 querydsl 的 Maven 构建问题

    我有一个用于 spring data jpa 和 QueryDsl 的 Eclipse Maven 项目 我似乎对 maven apt plugin 有问题 如果我执行 mvn clean 然后执行 mvn install 它会尝试 处理
  • BlazeDS 中的多个频道

    我正在尝试设置一个场景 其中 Flex 应用程序将能够使用在实现 BlazeDS 的两个不同 Web 应用程序中编写的资源 我最初尝试这样做在我的 mxml 代码中指定通道集 https stackoverflow com question
  • Flex:获取自己的 SWF 文件名?

    有没有办法以编程方式确定我的类正在运行的 swf 文件名 Thanks Stage http livedocs adobe com flex 3 langref flash display Stage html has a 加载器信息 ht
  • 开发在线考试应用程序,如何防止作弊?

    我的任务是为一所小型大学开发在线考试软件 我需要实施防止作弊的措施 您对如何做到这一点有什么想法 我想可能禁用所有 IE Firefox 选项卡 或者一些如何记录互联网活动的选项卡 以便我知道他们是否在谷歌搜索 anwsers 是否有任何现
  • flex:如何防止在flex3文本输入中粘贴(ctrl+V)?

    你好 我需要禁用在文本输入中粘贴文本 flex 3 CTRL V 任何想法 reagrds 这只会阻止粘贴多个字母 但它确实适用于大多数用途
  • 如何在 IDE 中使用 Grails 依赖项

    So I finally https stackoverflow com questions 1867064 grails and local maven dependencies让我的依赖项与 Grails 一起工作 现在 我的 IDE
  • IIS7什么时候负载太大?

    在我们的客户中 候选人使用我们的软件进行测试 如果他们的测试完成 一些计算将在服务器上完成 现在 有时200名考生可以同时结束考试 因此200个计算是同时进行的 计算似乎一切顺利 但对 IIS7 服务器的一些调用返回了 http 错误 在
  • 将 Flex ByteArray 转换为 Java byte[]

    我正在尝试将使用 rtmp 协议从 Flex GUI 发送的文件上传到服务器上 我昨天问如何在服务器上发送文件数据 通过rtmps java上传文件到服务器 https stackoverflow com questions 2310855
  • 在自定义 Flex 组件中绘制叠加层

    如何在 Flex 中创建一个自定义 MXML 组件 该组件基于现有组件 但在某些情况下会在该现有组件上绘制覆盖层 理想情况下 新组件应该基于 派生自 现有组件 以便现有组件的出现可以用新组件替换 我尝试在新组件中重写 updateDispl
  • FlexUnit ANT 任务挂起

    我正在使用 ANT 任务在构建服务器上运行 FlexUnit 当我从 Flash Builder 4 运行 Flex 单元测试时 它工作正常 但是当从 ANT 运行时 它会打开默认播放器 在我的例子中是 FireFox 成功运行 FU 但永
  • Flex DataGrid:根据另一个值更改值?

    我在 Flex 中有一个 DataGrid 其中一列是复选框 另一列是数值 单击该复选框时 数值应更改 如果未选中该复选框 则数值应更改为 0 如果选中该复选框 则应更改为预定义的最小值 这是我的代码
  • Maven 2 checkstyle 插件版本 2.5 - configLocation 问题

    我在 maven 2 中使用 checkstyle 插件 我现在想要将我的配置文件从默认文件切换为 a 在线文件 或 b 本地文件 我尝试了以下两件事 但都不起作用 有什么建议么 A 本地文件 直接位于我的项目文件夹中的 pom xml 旁
  • 从另一个域加载外部图像

    是否可以从另一个域加载图像 jpg png gif 并操作像素 我想当下载 复制图像时它就在我的域中 使用加载器并将内容添加到图像组件时 我在调试器中收到错误 我想这里有一些跨域策略在起作用 但在继续之前我需要更确定它是如何工作的 我想 如
  • 将应用程序状态保存在磁盘或其他位置,以便用户稍后访问它

    In 弹性构建器 4 5我正在做一个像这样的项目cacoo http www cacoo com 我想保存diagrams display object ui components text 在将应用程序关闭到应用程序之后我无法访问的某个地
  • 如何从 Flex Spark 列表的 DataProvider 对象获取其 ItemRenderer?

    在 Flex 中 我可以创建一个 ItemRenderer 来表示列表 DataProvider 中的每个项目 但如何通过 DataProviders 对象访问 ItemRenderer 的实例 就像是myList getItemRende
  • Flex 字典字面量

    在 Flex 中工作 我需要用相当复杂的结构填充字典 基于本文档页面 http livedocs adobe com flex 3 html help html content 10 Lists of data 4 html我尝试通过以下语
  • 闪存和 CORBA

    如何让 AS3 和 或 Flex AIR 应用程序与 CORBA 应用程序进行通信 在有人为 Flex 编写符合 CORBA 的库 您可能愿意自己做 之前 您最好的选择可能是构建一个充当桥梁的 包装器 Web 服务 可通过标准 Flex W
  • Eclipse(STS)+ Maven

    我基本上有两个问题 有没有办法从 Eclipse 调用 Maven 控制台 我可以在哪里写eclipse eclipse 并开始构建 eclipse 项目 哪里有STS http www springsource com products
  • 如何在maven中使用不同的JAR进行编译和测试?

    我根据 javaee api 编译我的程序 但对于 Junit 测试 我必须使用 glassfish javaee jar 等特定实现来避免类似错误java lang ClassFormatError 类文件 javax persisten
  • GWT、Maven、Spring - 在 Maven 构建上获取 com.thoughtworks.qdox.parser.ParseException:语法错误

    我正在尝试集成此演示中的代码 http code google com p gwt spring starter app http code google com p gwt spring starter app 进入我的主要 Spring

随机推荐