您的位置:首页 > 大数据 > 人工智能

flexmojos : 无法复制 src/main/resources 文件问题的解决方法

2011-02-20 03:10 627 查看
运行环境:

flex sdk4 , maven3.0, flexmojos 3.8,

问题描述:

flexmojos 在进行 compile-swf 时,无法将 src/main/resources 下的文件同步到 outputDirectory,这将会造成编译后的 swf 无法正常读取到原先定义在 src/main/resources 内的各种文件(jpg,css...)。

可能是 flexmojos 还不太够完美,configuration 中的所有参数都尝试了,问题仍无法解决。

解决思路:

通过 maven-antrun-plugin 来自定义一个phase同步到 ant target,转而由 ant 复制 src/main/resources 文件到 outputDirectory。

具体步骤:

1、在 flex 项目 pom.xml 中添加 maven-antrun-plugin:

<project>
<dependencies...>
<build>
...
<plugins>
<!--flexmojos 插件-->
<plugin...>

<!--maven-antrun-plugin-->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>run</id>
<!--定义一个比较快的 phase-->
<phase>validate</phase>
<configuration>
<target>
<!--将 maven 中设置的参数传給 ant-->
<property name="client_deploy_path" value="${client.deploy.path}"/>
<!--外部的 ant build.xml文件-->
<ant antfile="${project.basedir}/ant-build.xml"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>
</project>


说明:

1)定义在 mvn validate 时进行 ant build,可以根据需要设置为其他 compile, install.. 我这里设置 validate 只是时间少一点 :)

2)保持 pom.xml 的整洁,设置读取外部的 ant build.xml文件

3)pom.xml 其他配置见 这里

2. 建立ant build.xml

在 pom.xml 定义的 antfile 路径下,建立ant-build.xml

<?xml version="1.0" encoding="UTF-8" ?>
<project name="maven-antrun-" default="copyResources"  >
<target name="copyResources">
<echo  message="copying file(s) to : ${client_deploy_path}..."/>
<!--需要拷贝的文件目录-->
<property name="resourceFolder" value="${basedir}/src/main/resources"/>
<!--目标文件夹-->
<property name="destinationFolder"  value="${client_deploy_path}"/>
<!--先删除原来文件-->
<delete dir="${destinationFolder}/assets" />
<!--拷贝文件-->
<copy todir="${destinationFolder}" overwrite="true" failonerror="true">
<fileset dir="${resourceFolder}"/>
</copy>
</target>
</project>


3.运行脚本

输入mvn validate flexmojos:compile-swf,即可进行compile-swf 的同时将 src/main/resources 下的文件拷贝到定义的目录下。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐