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

后端 未结 4 1599
梦谈多话
梦谈多话 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条回答
  •  星月不相逢
    2020-12-25 10:08

    Both commands are correct :

    mvn clean install -Pdev1
    mvn clean install -P dev1
    

    The problem is most likely not profile activation, but the profile not accomplishing what you expect it to.

    It is normal that the command :

    mvn help:active-profiles
    

    does not display the profile, because is does not contain -Pdev1. You could add it to make the profile appear, but it would be pointless because you would be testing maven itself.

    What you should do is check the profile behavior by doing the following :

    1. set activeByDefault to true in the profile configuration,
    2. run mvn help:active-profiles (to make sure it is effectively activated even without -Pdev1),
    3. run mvn install.

    It should give the same results as before, and therefore confirm that the problem is the profile not doing what you expect.

提交回复
热议问题