Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different dependencies for different build profiles

People also ask

Which dependency specifies that a dependent artifact only applies to a certain build phase?

Maven dependency scope – provided.

How do I run a specific profile in Maven?

What you should do is check the profile behavior by doing the following : set activeByDefault to true in the profile configuration, run mvn help:active-profiles (to make sure it is effectively activated even without -Pdev1 ), run mvn install .

Is it possible to add library dependencies inside a profile?

Or dependencies may be pulled from different repositories based upon the JDK version used. Just put the dependency for the release profile inside the profile declaration itself and do the same for debug .


To quote the Maven documentation on this:

A profile element contains both an optional activation (a profile trigger) and the set of changes to be made to the POM if that profile has been activated. For example, a project built for a test environment may point to a different database than that of the final deployment. Or dependencies may be pulled from different repositories based upon the JDK version used.

(Emphasis is mine)

Just put the dependency for the release profile inside the profile declaration itself and do the same for debug.

<profiles>
    <profile>
        <id>debug</id>
        …
        <dependencies>
            <dependency>…</dependency>
        </dependencies>
        …
    </profile>
    <profile>
        <id>release</id>
        …
        <dependencies>
            <dependency>…</dependency>
        </dependencies>
        …
    </profile>
</profiles>

Your groupId, artifactId should be tokenized in your profiles as properties and you can move your dependencies to the generic section.