0

I am using maven assembly plugin to build the jar in my project. I've got 2 profiles and each of them builds a jar with a different main class. I wanted to know if there is any method of running both the profiles serially. So, that when I run the mvn install command, I get both the jars in my target.

This is the part of the pom building the jar for different profiles:

    <profiles>
    <profile>
        <id>main</id>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>2.3.1</version>
                    <executions>
                        <execution>
                            <id>default-jar</id>
                            <phase>none</phase>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>2.4.1</version>
                    <executions>
                        <execution>
                            <id>make-assembly-1</id>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                            <configuration>
                                <finalName>event-distributor-main</finalName>
                                <descriptorRefs>
                                    <descriptorRef>jar-with-dependencies</descriptorRef>
                                </descriptorRefs>
                                <archive>
                                    <manifest>
                                        <addClasspath>true</addClasspath>
                                        <classpathPrefix>lib/</classpathPrefix>
                                        <mainClass>com.adobe.highbeam.xenon.distributor.EventsDistributorMain</mainClass>
                                    </manifest>
                                </archive>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.3</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
    <profile>
        <id>retry</id>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>2.3.1</version>
                    <executions>
                        <execution>
                            <id>default-jar</id>
                            <phase>none</phase>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>2.4.1</version>
                    <executions>
                        <execution>
                            <id>make-assembly-1</id>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                            <configuration>
                                <finalName>event-distributor-retry</finalName>
                                <descriptorRefs>
                                    <descriptorRef>jar-with-dependencies</descriptorRef>
                                </descriptorRefs>
                                <archive>
                                    <manifest>
                                        <addClasspath>true</addClasspath>
                                        <classpathPrefix>lib/</classpathPrefix>
                                        <mainClass>com.adobe.highbeam.xenon.distributor.EventsDistributorRetry</mainClass>
                                    </manifest>
                                </archive>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.3</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>
ptntialunrlsd
  • 794
  • 8
  • 23
  • You want to activate the two profiles with `mvn -Pmain,retry clean install`? – Tunaki Nov 05 '16 at 20:00
  • But that just installs the one with retry! – ptntialunrlsd Nov 05 '16 at 20:04
  • 1
    Well sure, they override each other. They have the same Maven coordinates, you need to add a classifier in order to distinguish them. See also http://stackoverflow.com/a/38484021/1743880 the final name is not the name used when installing / deploying. This linked answer (of mine) will clarify the distinction, I hope. – Tunaki Nov 05 '16 at 20:10
  • `mvn -Pmain,retry clean install` worked when I changed the execution id of both. Thanks! :) – ptntialunrlsd Nov 06 '16 at 11:15

0 Answers0