2011-04-12 33 views
0

在Maven中撿了-Dattribute所以我有這樣的片段在我的POM問題用Antrun

<configuration> 
    <target if="csc" > 
    <echo>Unzipping md csc help</echo> 
    </target> 
    <target unless="csc"> 
    <echo>Unzipping md help</echo> 
    </target> 
</configuration> 

當我和MVN恢復正常運行。它正確執行,除非=「CSC」的目標。問題是,當我使用-Dcsc = true運行它時,它不運行任何目標。

我在做什麼錯? :)

感謝

+0

解鏈可以在不使用Ant ... – khmarbaise 2011-04-12 12:06:35

+0

@khmarbaise做 - 謝謝你... – willcodejavaforfood 2011-04-12 12:38:47

回答

1

看來antrun插件僅支持配置中的單個目標元素。你可以用maven profiles達到同樣的效果,當property is set or absent即得到激活:

<profiles> 
    <profile> 
     <id>property-set</id> 
     <activation> 
      <property> 
       <name>csc</name> 
      </property> 
     </activation> 
     <build> 
      <plugins> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-antrun-plugin</artifactId> 
        <version>1.6</version> 
        <executions> 
         <execution> 
          <id>antrun-property-set</id> 
          <goals> 
           <goal>run</goal> 
          </goals> 
          <phase>generate-sources</phase> 
          <configuration> 
           <target> 
            <echo>property is set</echo> 
           </target> 
          </configuration> 
         </execution> 
        </executions> 
       </plugin> 
      </plugins> 
     </build> 
    </profile> 
    <profile> 
     <id>property-not-set</id> 
     <activation> 
      <property> 
       <name>!csc</name> 
      </property> 
     </activation> 
     <build> 
      <plugins> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-antrun-plugin</artifactId> 
        <version>1.6</version> 
        <executions> 
         <execution> 
          <id>antrun-property-not-set</id> 
          <goals> 
           <goal>run</goal> 
          </goals> 
          <phase>generate-sources</phase> 
          <configuration> 
           <target> 
            <echo>property is not set</echo> 
           </target> 
          </configuration> 
         </execution> 
        </executions> 
       </plugin> 
      </plugins> 
     </build> 
    </profile> 
</profiles>