views:

534

answers:

1

Hi, I have made following changes to the POM.xml file for adding a manifest file that i have kept in \resources\META-INF But am unable to create an executable jar file.

<build>
  <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.0.2</version>
    <configuration>
        <source>1.5</source>
        <target>1.5</target>
          <archive>
            <manifest>
            <mainClass>com.mypackage.myMainClass</mainClass>
            <!--addClasspath>false</addClasspath-->
            </manifest>
            <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
          </archive>
        </configuration>
    </plugin>
  </plugins>
</build>

Any suggestions?

+2  A: 

use the maven-assembly-plugin.

Example:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <archive>
                    <manifest>
                        <mainClass>foo.bar.Main</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
     </plugins>
</build>
dfa
Thanks the executable jar gets created but somehow i got double entry for all the resources in the jar. i.e i had duplicate resources.
krisp
I had used mvn assembly:assembly to build the jar
krisp
that is really weird. May be it is a bug?
dfa