How to deploy an artifact that uses classifiers and profiles with Maven

Categories Development, Java

Sometimes, when one of your modules is used by different applications, but requires slight changes, you want to create different artifacts, that can be direct dependencies of those applications.

You can do this by using profiles and classifiers.

You can create your pom, the usual way, with profiles…more here, then apply classifiers to the package plugin inside your profile, like this:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
<configuration>
<classifier>standalone</classifier>
</configuration>
</execution>
</executions>
</plugin>

This will produce an artifact with finalName

${artifactId}-${version}-${clasifier}

that will be accessible by specifying the classifier in your dependency.

Just remember to use executions because it will not work otherwise. It will build the artifacts, but will not deploy them.

1 thought on “How to deploy an artifact that uses classifiers and profiles with Maven

  1. Excellent blog you have here but I was curious about if you knew of any discussion boards that cover the same topics discussed here?
    I’d really love to be a part of group where I can get suggestions from
    other knowledgeable individuals that share the same interest.

    If you have any recommendations, please let me know. Kudos!

Leave a Reply

Your email address will not be published. Required fields are marked *