2013-05-28 17 views
5

Yapılandırma değerlerini maven'den kareye geçirebilmek istiyorum. Mantıklı geliyorsa.'maven' öğesinden ant görevine geçiş argümanları

bu göreve değişkenleri geçmek mümkün istiyorum:

ı değişken $ {someArg} Ben maven senaryoya ve sonunda sürüme 'someArg' geçmek isterler tanımlamak varsayalım. xml karınca komut dosyası. İşte

benim tanımı şöyledir:

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

Ve sonra burada build.xml parçasıdır:

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

Ve

cevap

4

bir yoktur Build.xml iletmek istediğimiz örnek: http://maven.apache.org/plugins/maven-antrun-plugin/examples/classpaths.html

Yapılandırmanızda 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 dokümantasyon hedef etiketinde şey koyabilirsiniz, böylece $ {özellik adı} kullanarak hedefe yılında maven özelliklerini kullanabilmek için olması gerektiğini söylüyor.

+0

Bu işe yarayacak, sadece ihtiyacınız olan özellikleri kopyala/ekle. –