我的pom.xml
正在運行Ant任務以使用FTP部署文件。但是,只有在Maven命令(即mvn clean install -Dftp=true
)中給出-Dftp=true
參數時才能執行此部署。因此,我寫了下面的代碼:只有在設置屬性時纔在Maven中運行Ant任務
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks if="ftp">
<echo message="Deploying files through FTP..."/>
...
</tasks>
</configuration>
</execution>
</executions>
使用該pom.xml
,如果我不定義在我的Maven命令-Dftp
財產不執行Ant任務。但是,如果我爲此屬性提供任何類型的值,例如-Dftp=false
,則Ant任務將運行,這是不正確的。
如何配置AntRun任務僅在給定屬性具有給定值時才運行?
ps:我知道我可以使用profile
,只有當ftp
等於true
時纔有效。此解決方案有效,但由於某種原因,我想要我的Antrun插件build
塊。
<profiles>
<profile>
<id>deployment</id>
<activation>
<activeByDefault>false</activeByDefault>
<property>
<name>ftp</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
... (define the Ant task here)
這個'if'任務的可怕(和冗長)語法是什麼。但它做的工作,這是更重要的; o)謝謝! – romaintaz 2010-02-24 09:04:33