Hi all,

I have a default pom file in our codebase that has "war" packaging.

We wanted to also generate a normal jar file (lean) and a fat jar with 
dependencies along with the war file in our build using the same pom.xml.

$ mvn -version
Apache Maven 2.2.1 (r801777; 2009-08-06 12:16:01-0700)
Java version: 1.7.0_45
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x" version: "10.8.5" arch: "x86_64" Family: "mac"

We added the following plugins - maven–assembly-plugin to generate the far jar 
and maven-jar-plugin to generate the lean jar.


            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
                <executions>
                    <execution>
                        <id>assembly-all</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </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>
              </execution>
          </executions>
      </plugin>

On mvn clean install,
It is generating all the 3 files : war, lean jar and far jar.

But the problem is the jar-with-dependencies (fat jar) generated is getting 
built in the wrong way. Its size becomes double that of the same jar built by 
using Maven 3.0.4 (yes, I tried upgrading the maven to 3.0.4 to test and 
everything is good
With maven 3).

The problem is only with maven 2 and to me it looks like since the overall 
packaging phase of the pom is war , it is generating a wrong fat jar using the 
maven-assembly-plugin.  Many src classes are missing from the fat jar.

Anyone faced this issue with maven 2 and war packaging. Maven 3.0.4 is just 
fine while generating the fat jar.

Does maven-assembly-plugin have some restrictions with maven 2 and war 
packaging ?

Is there an alternate plugin to generate a jar with dependencies other than 
maven-assembly-plugin ?

Thanks in advance
Narayanan

Reply via email to