我有一个相当简单的 Flex SWC 模块,它是通过 Maven Flexmojos 插件编译的。该模块还在 generate-sources 阶段使用 flexmojos:generate 目标来创建我的 Java 服务和域类的 Actionscript3 等效项。常规源位于 中src/main/flex
,生成的源位于src/main/flex-generated
. 生成的源代码未检入 Subversion。像许多其他 flexmojos 用户一样,我使用 build-helper:add-source 目标将第二个源代码树添加到我的编译中。这几个月来一直运行良好,Maven 输出通常如下所示:
[INFO] ------------------------------------------------------------------------
[INFO] Building myproj Core Client -- Flex Service
[INFO] task-segment: [deploy]
[INFO] ------------------------------------------------------------------------
[INFO] [flexmojos:generate {execution: create-actionscript-classes}]
[INFO] Flexmojos 3.7.1
[INFO] Apache License - Version 2.0 (NO WARRANTY) - See COPYRIGHT file
[INFO] flexmojos 3.7.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
[INFO] Calling the generator for each Java class.
[INFO] Generating: /home/bsmith/develop/myproj/myproj-core/tags/myproj-core-1.0.2/flex-service/src/main/flex-generated/com/myprojvision/core/domain/security/Group.as
.......
[INFO] [build-helper:add-source {execution: add-source}]
[INFO] Source directory: /home/bsmith/develop/myproj/myproj-core/tags/myproj-core-1.0.2/flex-service/src/main/flex-generated added.
[INFO] Flex compiler configurations:
.....
-compiler.source-path /home/bsmith/develop/myproj/myproj-core/tags/myproj-core-1.0.2/flex-service/src/main/flex /home/bsmith/develop/myproj/myproj-core/tags/myproj-core-1.0.2/flex-service/src/main/flex
请注意 flex 编译器源路径如何很好地表示两个源目录。此设置将成功打包、安装和部署 SWC 工件。但是,现在我们希望使用 Maven 发布插件来自动化发布过程。release:prepare
目标运行良好。但是,release:perform 目标失败了,因为 flex 编译器由于某种未知原因没有收到生成的源目录:
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Building myproj Core Client -- Flex Service
[INFO] [INFO] task-segment: [deploy]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] [flexmojos:generate {execution: create-actionscript-classes}]
[INFO] [INFO] Flexmojos 3.7.1
[INFO] [INFO] Apache License - Version 2.0 (NO WARRANTY) - See COPYRIGHT file
[INFO] [INFO] Calling the generator for each Java class.
[INFO] [INFO] Generating: /home/bsmith/develop/myproj/myproj-core/trunk/target/checkout/flex-service/src/main/flex-generated/com/myprojvision/core/domain/security/Group.as
...
[INFO] [INFO] [build-helper:add-source {execution: add-source}]
[INFO] [INFO] Source directory: /home/bsmith/develop/myproj/myproj-core/trunk/target/checkout/flex-service/src/main/flex-generated added.
...
[INFO] [INFO] Flex compiler configurations:
[INFO] -compiler.source-path /home/bsmith/develop/myproj/myproj-core/trunk/target/checkout/flex-service/src/main/flex
请注意,文件是在正确的位置生成的,正确调用了构建助手,但是 flex compiler.source-path 缺少生成的源目录,因此会产生 Flex class-not-found 错误。这个问题令我惊讶的是 release:prepare 在分叉的 Maven 生命周期中执行了 [clean, verify] 并且它可以工作,但是 release:perform 没有......所以它似乎不是叉子就是问题所在。
下面是 build-helper 插件的配置:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.basedir}/src/main/flex-generated</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
请注意,如果我放弃 build-helper 插件并使用 flexmojo 的 sourcePaths 配置,那么一切正常。
<sourcePaths>
<path>${project.basedir}/src/main/flex</path>
<path>${project.basedir}/src/main/flex-generated</path>
</sourcePaths>
但是 sourcePaths 已被弃用,对于那些拥有多个 flex 源代码树的人来说,前进的道路是 build-helper。