[英]Pass arguments from 'maven' to ant task
我希望能夠將配置值從maven傳遞給ant。 如果這是有道理的。
我希望能夠將變量傳遞給此任務:
假設我定義了一個變量$ {someArg}我希望能夠將'someArg'傳遞給maven腳本並最終傳遞給build.xml ant腳本。
這是我的定義:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>gen</id>
<phase>generate-resources</phase>
<configuration>
<target name="main">
<script language="javascript" manager="javax"
src="${project.basedir}/src/scripts/myfile.js"/>
</target>
</configuration>
<goals>
${someArg} (how to pass someArg)
<goal>run</goal>
</goals>
</execution>
...
然后這是build.xml的一部分:
<?xml version="1.0" ?> <project name="deployment" default="deploy">
<property file="build.properties" />
<target>
<echo message="${someArg}" />
</target>
</project>
我想傳遞給build.xml
有一個例子: http : //maven.apache.org/plugins/maven-antrun-plugin/examples/classpaths.html
在你的配置pom.xml中:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<configuration>
<target>
<property name="compile_classpath" refid="maven.compile.classpath"/>
<property name="runtime_classpath" refid="maven.runtime.classpath"/>
<property name="test_classpath" refid="maven.test.classpath"/>
<property name="plugin_classpath" refid="maven.plugin.classpath"/>
<echo message="compile classpath: ${compile_classpath}"/>
<echo message="runtime classpath: ${runtime_classpath}"/>
<echo message="test classpath: ${test_classpath}"/>
<echo message="plugin classpath: ${plugin_classpath}"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Maven文檔說您可以在目標標記中放置任何內容,因此您應該能夠使用$ {property name}在目標中使用maven屬性。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.