2013-05-28 11 views
5

mavenからantに設定値を渡したいと思っています。それが意味をなさないならば。'maven'からantタスクに引数を渡す

私はこのタスクに変数を渡すことができるようにしたい:

のは、私はMavenのスクリプトに、最終的にビルドに「someArg」を渡すことができるようにしたい変数$ {someArg}を定義するとしましょう。 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> 

そして私は

答えて

4

があるの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のドキュメントでは、ターゲットタグに何かを置くことができると言うので、あなたは$ {プロパティ名}を使用してターゲットでMavenのプロパティを使用することができるはずです。

+0

これでうまくいくので、必要なプロパティをコピー/追加してください。 –

関連する問題