Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change deployed artifact name based on profile

I have in a web application's pom file, a build profile, which does some necessary things (in my code) for qa testing.

I have this code on svn and this code is compiled in Hudson, which deploys artifacts in nexus..

Hudson has two jobs, one for qa profile (-P qa) and one for customers.

What i need is that i change in my qa profile the artifact's name during deploy phase, so that nexus has two different war files, one for qa and one for customer.

I use (after Google search) the following which looks like it does nothing in hudshon!

    <profile>
        <id>qa</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>2.5</version>
                    <configuration>
                        <classifier>qa</classifier>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

any ideas someone?

like image 400
Alexandros Avatar asked Nov 16 '10 16:11

Alexandros


1 Answers

You actually need to set the "classifier" configuration option on the plugin that's building the package that's being deployed: maven-(ear|ejb|jar|rar|war|shade)-plugin:

For instance, to build a WAR with a qa classifier, you would do the following:

<profile>
    <id>qa</id>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <classifier>qa</classifier>
                </configuration>
            </plugin>
        </plugins>
    </build>
</profile>

Also, instead of setting the classifier you could set any of the following (most default to project.build.finalName, so setting that property updates many of these):

  • General
    • project.build.finalName
  • War Plugin
    • warName
  • Ear|Jar|Rar|Shade Plugin
    • finalName
  • EJB Plugin
    • jarName

One final note: I never realized this before, but looking over the documentation, it looks like the RAR plugin doesn't support the "classification" option. Shade does support the classifier concept, but does it via the "shadedClassifierName" property.

like image 99
nivekastoreth Avatar answered Oct 12 '22 23:10

nivekastoreth