-1

I have created war packing of my project and on same pom.xml file, I have included below plugin to create the jar as well. Everything work fine, it creates jar and war file both.

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <executions>
            <execution>
                <id>make-a-jar</id>
                <phase>compile</phase>
                <goals>
                    <goal>jar</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

Now my question is, how I can merge the two jars? I want to include the content of one jar into the jar created above. Means copying the content of one jar into other while creating other jar in maven.

Lokesh Paunikar
  • 1,679
  • 5
  • 21
  • 26
  • What do you mean merge the two jars? You say you have only one jar, and a war. Do you perhaps want to include the jar inside the WEB-INF/lib of the war? – Gimby Sep 01 '15 at 14:52
  • possible duplicate of [Is it possible to create an "uber" jar containing the project classes and the project dependencies as jars with a custom manifest file?](http://stackoverflow.com/questions/1832853/is-it-possible-to-create-an-uber-jar-containing-the-project-classes-and-the-pr) – Derrops Sep 01 '15 at 14:55

1 Answers1

-1

This solved my issue,

<plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-dependency-plugin</artifactId>
     <executions>
       <execution>
         <id>${project.artifactId}</id>
         <phase>generate-sources</phase>
         <goals>
           <goal>unpack</goal>
         </goals>
         <configuration>
           <artifactItems>
             <artifactItem>
               <groupId>groupId_for_jar_to_copy</groupId>
               <artifactId>artifactId_for_jar_to_copy</artifactId>
               <version>version_for_jar_to_copy</version>
               <type>jar</type>
               <overWrite>false</overWrite>
               <outputDirectory>${project.build.directory}/classes</outputDirectory>
             </artifactItem>
           </artifactItems>
         </configuration>
       </execution>
     </executions>
   </plugin>

   <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <executions>
            <execution>
                <id>make-a-jar</id>
                <phase>compile</phase>
                <goals>
                    <goal>jar</goal>
                </goals>
                <configuration>
                    <finalName>jar_file_name</finalName>                   
                </configuration>
            </execution>
        </executions>
    </plugin>
Lokesh Paunikar
  • 1,679
  • 5
  • 21
  • 26