0

have two profiles to build a dependent jar for a web application (one for tomcat and the other is for websphere). Here what I'm trying is to run those two profiles in one go to build those jars together.

mvn help:active-profiles -o -Dmaven.test.skip=true clean install -PTOMCAT,WEBSPHERE

As a result of these executions we are expecting acme-tomcat-0.0.1-SNAPSHOT.jar and acme-web-0.0.1-SNAPSHOT.jar but along with these a default jar is also being created acme-0.0.1-SNAPSHOT.jar. It seems this because of the default execution.

How can we avoid this default execution to avoid the generation of default acme-0.0.1-SNAPSHOT.jar. We have referred a couple of solutions here in SO to arrive this and also we have made a similar post earlier but which will not help us in this scenario. Any pointers would be helpful.

Profile configuration looks like

<profiles>
    <profile>
        <id>TOMCAT</id>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-jar-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>tom-jar</id>
                            <phase>package</phase>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                            <configuration>
                                <finalName>${project.artifactId}-tomcat-${project.version}</finalName>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build> 
        <dependencies>
            <dependency>
                <groupId>org.apache.activemq</groupId>
                <artifactId>activemq-core</artifactId>
                <version>5.7.0</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.geronimo.specs</groupId>
                <artifactId>geronimo-j2ee-management_1.1_spec</artifactId>
                <version>1.0.1</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.javaee</groupId>
                <artifactId>jboss-jms-api</artifactId>
                <version>1.1.0.GA</version>
            </dependency>
        </dependencies>
    </profile>
    <profile>
        <id>WEBSPHERE</id>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-jar-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>web-jar</id>
                            <phase>package</phase>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                            <configuration>
                                <finalName>${project.artifactId}-web-${project.version}</finalName>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build> 
        <dependencies>
            <dependency>
                <groupId>org.apache.activemq</groupId>
                <artifactId>activemq-core</artifactId>
                <version>5.4.3</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.activemq</groupId>
                <artifactId>geronimo-j2ee-management_1.0_spec</artifactId>
                <version>1.0</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.javaee</groupId>
                <artifactId>jboss-jms-api</artifactId>
                <version>1.1.0.GA</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>
    </profile>
</profiles>

Thanks, San

Community
  • 1
  • 1
kallada
  • 1,829
  • 4
  • 33
  • 64
  • 2
    Could you please take a look here: http://stackoverflow.com/questions/4101750/disable-the-execution-default-jar – Volodymyr Kozubal Mar 30 '16 at 18:24
  • Hi Thanks for the pointer, now I changed the execution id of my TOMCAT profile to default-jar to override the default execution. Now the pom works as intended. But is it the correct way? – kallada Mar 30 '16 at 18:39
  • 1
    The correct way is not using profiles to begin with actually. Why not have 2 separate projects: one tomcat specific and one websphere specific? Both inheriting from a common POM? – Tunaki Mar 30 '16 at 19:38
  • we are helpless in this regard as we are working on a legacy project – kallada Mar 30 '16 at 19:56

1 Answers1

0

Using the pointer from Volodymyr Kozubal, changed the execution id of my TOMCAT profile to:

<execution>
   <id>default-jar</id>
   .........
 </execution>

to override the default execution.

Thank you all

Community
  • 1
  • 1
kallada
  • 1,829
  • 4
  • 33
  • 64