FTPpom.xml
を使用してファイルをデプロイするためにAntタスクを実行しています。-Dftp=true
ただし、このデプロイメントは、引数がMavenコマンド(つまり)で指定されている場合にのみ実行する必要がありますmvn clean install -Dftp=true
。したがって、私は次のコードを書きました:
<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>
これを使用すると、Mavenコマンドでプロパティをpom.xml
定義しない場合、Antタスクは実行されません。-Dftp
ただし、たとえば、このプロパティに何らかの値を-Dftp=false
指定すると、Antタスクが実行されます。これは正しくありません。
特定のプロパティに特定の値がある場合にのみ実行されるようにAntRunタスクを構成するにはどうすればよいですか?
ps:が等しいprofile
場合にのみアクティブになるaを使用できることはわかっています。このソリューションは機能しますが、何らかの理由で、Antrunプラグインブロックが必要です。ftp
true
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)