为了加载正确的插件版本,我需要检测用户是否在我的父pom中使用mvn2或mvn3。我遵循了这里的推荐:http://maven.apache.org/plugins/maven-site-plugin/maven-3.html#Using_maven-site-plugin_2.x_with_Maven_2_and_maven-site-plugin_3.x_with_Maven_3
检测机制工作得很好--但是,我的其他配置文件,即activatedByDefaul,不再被拾取。
超级pom如下所示:
<profile>
<id>profile-1</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>profile-2</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
</profile>
<profile>
<id>maven-3</id>
<activation>
<file>
<!-- This employs that the basedir expression is only recognized by Maven 3.x (see MNG-2363) -->
<exists>${basedir}</exists>
</file>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.company.plugins</groupId>
<artifactId>my-super-plugin</artifactId>
<version>1.0-123</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>当我运行mvn帮助:使用mvn3的活动配置文件->只有maven-3配置文件被列出。如果我使用mvn2,配置文件-1是正确列出的。
*编辑*:事实证明,它实际上在这里有很好的文档:http://maven.apache.org/guides/introduction/introduction-to-profiles.html
此配置文件对于所有构建都将自动激活,除非使用前面描述的方法之一激活同一POM中的另一个配置文件。默认情况下,当POM中的配置文件在命令行上激活或通过其激活配置文件时,所有活动的配置文件都会自动停用。
那么,我现在的问题是:默认情况下,您建议激活profile1,如果使用-P profile2,则建议激活配置文件2;如果使用maven3,则建议激活maven-3配置文件?
发布于 2012-06-12 17:24:11
到目前为止,我还没有找到比这更好的东西:
<activation>
<property>
<name>!dummy</name>
</property>
</activation>其中dummy是某种愚蠢的变量名,您不能肯定地使用它。
https://stackoverflow.com/questions/11001295
复制相似问题