2013-05-28 11 views
5

Chcę móc przekazywać wartości konfiguracyjne z maven do ant. Jeśli to ma sens.Przekazywanie argumentów z "maven" do zadania ant

Chcę być w stanie przekazać zmienne do tego zadania:

Powiedzmy, że zdefiniowanie zmiennej $ {someArg} Chcę, aby być w stanie przejść „someArg” do skryptu maven i ostatecznie do kompilacji. skrypt xml ant.

Oto moja definicja:

<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> 
... 

I to tutaj jest częścią build.xml:

<?xml version="1.0" ?> <project name="deployment" default="deploy"> 
    <property file="build.properties" /> 
    <target> 
    <echo message="${someArg}" /> 
    </target> 
</project> 

I chcę, aby przejść do build.xml

Odpowiedz

4

Jest przykład w: http://maven.apache.org/plugins/maven-antrun-plugin/examples/classpaths.html

W swojej konfiguracji 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> 

dokumentacja Maven mówi, że można umieścić coś w docelowej tagu, więc powinieneś być w stanie wykorzystać właściwości Maven w celu przy użyciu $ {nazwa} nieruchomości.

+0

To zadziała, więc po prostu skopiuj/dodaj właściwości, których potrzebujesz. –

Powiązane problemy