Default build profile for Maven
Asked Answered
E

2

89

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?

Elinoreeliot answered 6/8, 2012 at 7:46 Comment(0)
P
180

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

Paraffin answered 6/8, 2012 at 7:48 Comment(1)
Beware of Does using activeByDefault go against maven best practices?Canterbury
W
0

You can also activate specific profile by running

mvn clean install -Pprod  

or

mvn clean install -Pdev
Weixel answered 23/1, 2019 at 16:35 Comment(1)
"When I give the command mvn clean install without specifying the build profile"Parotid

© 2022 - 2024 — McMap. All rights reserved.