88

I have added profiling to my Maven project.

        <profile>
            <id>da</id>                
        </profile>
        <profile>
            <id>live</id>
        </profile>
        <profile>
            <id>dev</id>
        </profile>

When I give the command mvn clean install without specifying the build profile. I need the dev profile to be build by default.

How can I achieve this?

Lii
  • 11,553
  • 8
  • 64
  • 88
Isuru
  • 7,893
  • 8
  • 30
  • 38

2 Answers2

175

By using the attribute activeByDefault you will be able to select a default profile in Maven when no other profile is selected with the -P parameter.

<profiles>
    <profile>
        <id>da</id>                
    </profile>
    <profile>
        <id>live</id>
    </profile>
    <profile>
        <id>dev</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
    </profile>
</profiles>
    

See Maven Introduction to Profiles documentation

Jose Da Silva Gomes
  • 3,814
  • 3
  • 24
  • 34
FredrikO
  • 1,982
  • 1
  • 12
  • 8
  • Beware of [Does using activeByDefault go against maven best practices?](http://stackoverflow.com/questions/16167206/does-using-activebydefault-go-against-maven-best-practices) – Vadzim Jan 23 '17 at 13:27
1

You can also activate specific profile by running

mvn clean install -Pprod  

or

mvn clean install -Pdev
pawello2222
  • 46,897
  • 22
  • 145
  • 209
Pravin Bansal
  • 4,315
  • 1
  • 28
  • 19