Hind Forsum
Hind Forsum

Reputation: 10497

Java: my own MANIFEST.MF file doesn't take effect in a maven built jar

I'm using intelliJ to create a maven module, the directory structure is like this:

--src
  --main
    --java
      --my
        --M1.java
        --M2.java
        --M3.java
  --resources
    --META-INF
      MANIFEST.MF

And cat MANIFEST.MF

Manifest-Version: 0.1.0
Implementation-Title: test manifist
Implementation-Version: 0.0.1
Main-Class: my.M2

And the java file:

package my;
public class M2 {
    public static void main(String [] args) {
        System.out.println("M2");
    }
}

Then I "mvn package" to build the result jar file.I extracted this jar and found the jar file contains a META-INF/MANIFEST.MF, in which "Main-Class is missing":

$cat META-INF/MANIFEST.MF
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: x
Created-By: Apache Maven 3.3.9
Build-Jdk: 1.8.0_111

The content is completely different, seems my own META-INF/MANIFEST.MF didn't take any effect when I build this jar with maven. So why is this, and how to make my own file effective?

Thanks a lo.t

Upvotes: 1

Views: 684

Answers (1)

Gmugra
Gmugra

Reputation: 510

You need modify pom.xml and add maven-jar-plugin defenition: http://maven.apache.org/shared/maven-archiver/examples/manifestFile.html

Upvotes: 2

Related Questions