我在我的pom.xml中有一个配置文件,除非明确停用(-P!firstProfile),否则它应始终处于活动状态.我通过使用activeByDefault标志解决了这个问题:
<profiles>
<profile>
<id>firstProfile</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
...
</profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)
现在在同一个pom.xml中我定义了第二个配置文件,只有在配置文件被激活时才会激活(-P secondProfile).因此默认行为是:firstProfile active,secondProfile inactive.在其他一些方面,除了第一个配置文件之外,我还想激活第二个配置文件.现在的问题是,如果我用"-P secondProfile"执行此操作,则不幸的是,第一个配置文件将被停用.Maven文档说明了这一点:
...除非使用前面描述的方法之一激活同一POM中的另一个配置文件,否则此配置文件将自动为所有版本激活.当在命令行上激活POM中的配置文件或通过其激活配置时,默认情况下处于活动状态的所有配置文件都将自动停用....
是否有可能如何保持firstProfile始终处于活动状态(无需在settings.xml中声明它)?
我已经为我的Maven项目添加了分析.
<profile>
<id>da</id>
</profile>
<profile>
<id>live</id>
</profile>
<profile>
<id>dev</id>
</profile>
Run Code Online (Sandbox Code Playgroud)
当我在mvn clean install不指定构建配置文件的情况下发出命令时.我需要默认构建开发配置文件.
我怎样才能做到这一点?
我在pom.xml中定义了两个配置文件:
<profiles>
<profile>
<id>nobrand</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<brand>nobrand</brand>
</properties>
</profile>
<profile>
<id>mybrand</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<brand>mybrand</brand>
</properties>
</profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)
本<build>节仅使用每个配置文件设置的属性。
默认情况下,两个配置文件均设置为活动状态。但是,只有最后一个由执行mvn package。为什么?我希望构建可以执行两次。