Maven: How do I activate a profile from command line?

后端 未结 4 1594
梦谈多话
梦谈多话 2020-12-25 09:28

This is a snippet from my pom.xml. I tried the following, but the profile was not activated.

mvn clean install -Pdev1
mvn clean install -P dev1
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-25 09:58

    Activation by system properties can be done as follows

    
        
            foo
            bar
        
    
    

    And run the mvn build with -D to set system property

    mvn clean install -Dfoo=bar
    

    This method also helps select profiles in transitive dependency of project artifacts.

提交回复
热议问题