我目前正在研究一个已经从Ant迁移到Maven的相当大的项目。实际的构建过程没有问题(它编译和打包源代码的罚款)。将蚂蚁资源生成目标集成到Maven版本
的问题是,我也有很多产生额外资源为项目目标(编译LessCSS,产生&上传文档,生成tld
文件自定义标签和功能等)。我不知道我应该如何处理这些任务。让我们以构建CSS的目标为例(其他人或多或少相似,但未连接)。它看起来像这样(简化):
<target name="build.css_js">
<concat destfile="${webapp.dir}/scripts/main.js">
<fileset dir="${webapp.dir}/scripts/src" includes="*.js"/>
</concat>
<!-- build css files from less sources -->
<taskdef name="lesscss" classname="com.asual.lesscss.LessEngineTask" classpathref="libraries" />
<lesscss input="${webapp.dir}/syles/src/input.less" output="${webapp.dir}/styles/output.css" />
</target>
在pom.xml
我有以下插件设置:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<configuration>
<tasks>
<echo message="Hello World from pom.xml"/>
<ant target="build.css_js"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
我使用的依赖性不再在我们的SVN仓库(因为它们是Maven的管理),所以我切换变量指向Maven的回购库:
<property name="lib.dir" location="${env.HOMEPATH}/.m2/repository" />
这是不好的,因为这条道路可能只是我的机器上是有效的。我不知道任何其他的方式来从Maven仓库引用库,我需要它们来运行ant目标。
- 我的方法好吗,还是有更好的做事方法?
- 如何解决图书馆问题?
- 包装项目时需要一些资源,但有些则不需要。
是否存在超出编译/包的范围的生命周期阶段?我发现我认为符合我需求的site
生命周期。 - 理想情况下,我应该完全放弃ant构建文件,但我不确定这是值得努力使脚本作为maven插件运行(我目前不知道该怎么做)。你怎么看待这件事?
我是Maven的新手,所以有什么建议值得赞赏。
谢谢你的提示! – 2011-06-03 16:20:29