当我使用mvn ant:ant生成Ant项目时,生成的Ant项目不会过滤资源来替换属性令牌(例如${property})。有没有简单的方法可以做到这一点?
发布于 2012-08-30 09:09:02
ant插件将根据您的POM生成以下文件:
|-- build.xml
|-- maven-build.properties
|-- maven-build.xml资源过滤发生在“编译”目标中,因此您可以通过将目标复制到build.xml并更改它的行为来覆盖它的行为。
再次运行Maven ANT插件不会覆盖此自定义(仅重新生成maven-*文件)。
示例
build.xml
Filterset被添加到compile目标内的复制任务中:
<project name="maven-ant-demo" default="package" basedir=".">
<!-- ====================================================================== -->
<!-- Import maven-build.xml into the current project -->
<!-- ====================================================================== -->
<import file="maven-build.xml"/>
<!-- ====================================================================== -->
<!-- Help target -->
<!-- ====================================================================== -->
<target name="help">
<echo message="Please run: $ant -projecthelp"/>
</target>
<!-- ====================================================================== -->
<!-- Override target -->
<!-- Copied from "maven-build.xml" -->
<!-- ====================================================================== -->
<target name="compile" depends="get-deps" description="Compile the code">
<mkdir dir="${maven.build.outputDir}"/>
<javac destdir="${maven.build.outputDir}"
nowarn="false"
debug="true"
optimize="false"
deprecation="true"
target="1.1"
verbose="false"
fork="false"
source="1.3">
<src>
<pathelement location="${maven.build.srcDir.0}"/>
</src>
<classpath refid="build.classpath"/>
</javac>
<!--
Note the filterset. This will perform resource filtering
-->
<copy todir="${maven.build.outputDir}">
<fileset dir="${maven.build.resourceDir.0}"/>
<filterset begintoken="${" endtoken="}">
<filter token="helloworld" value="${helloworld}"/>
</filterset>
</copy>
</target>
</project>https://stackoverflow.com/questions/12188301
复制相似问题