我想获得以下行为:当我为属性“my.prop”指定一个值时,我希望执行依赖项和干净的插件。如果没有为该属性指定值,我希望它们被跳过。
我像这样创建了“my.prop”:
<properties>
<my.prop></my.prop>
</properties>
然后我读到配置文件激活仅适用于系统属性,所以我删除了上面的内容并使用了 surefire 插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<systemPropertyVariables>
<my.prop></my.prop>
</systemPropertyVariables>
</configuration>
</plugin>
我尝试使用配置文件,如下所示:
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<skipDependecyAndCleanPlugins>false</skipDependecyAndCleanPlugins>
</properties>
</profile>
<profile>
<id>skip-dependency-and-clean-plugins</id>
<activation>
<property>
<name>my.prop</name>
<value></value>
<!-- I also tried: <value>null</value> without success.-->
</property>
</activation>
<properties>
<skipDependecyAndCleanPlugins>true</skipDependecyAndCleanPlugins>
</properties>
</profile>
</profiles>
后来,对于每个插件,我都会做这样的事情:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.9</version>
<configuration>
<skip>${skipDependecyAndCleanPlugins}</skip>
</configuration>
....
</plugin>
但是插件仍然执行...
当“my.prop”为空/空时,如何确定 Maven 跳过插件的执行?