如何通过pom中的属性动态启用profile
例如:
<properties>
<enableTestProfile>true</enableTestProfile>
</properties>
<profiles>
<profile>
<id>test</id>
</profile>
</profiles>
我想根据enableTestProfile不同的取值去启用或禁用test

解决方案 »

  1.   

    The profile below will activate the profile when the system property "enableTestProfile" is specified with value "true":
    <profiles>
      <profile>
        <activation>
          <property>
            <name>enableTestProfile</name>
            <value>true</value>
          </property>
        </activation>
        ...
      </profile>
    </profiles>
      

  2.   

    补充:上面说的是系统属性(system property)
      

  3.   

    我现在就只想取pom文件里面定义的属性还有maven版本是2.x的
      

  4.   

    如果属性不做它用,仅用于激活/关闭profile,不如不用了,
    直接用
      <activeProfiles>
        <activeProfile>TestProfile</activeProfile>
      </activeProfiles>
    好了。
      

  5.   

    不想在settings.xml里面配置呀,不过还是谢谢了
      

  6.   

    settings.xml 有两个啊。 一个在 ${M2_HOME}/config 下,这个一般整个项目组保持一致。还有一个在 ${USER}/.m2 下,这个根据个人习惯改动几下没有关系的吧。