Maven does not generate a MANIFEST file with maven jar plugin

Lua Mia :

I try to generate a .zip file with maven (mvn package) and want to have a MANIFEST file in the zip too. The jar file itself does work. I tried to generate a MANIFEST file with maven jar plugin, but it did not work. Do I Have to do something else to get a MANIFEST file, or is it enough to use this plugin? The parent pom (parent of the parent I showed) has maven assembly plugin. (I´m completely new to maven)

pom.xml file of the parent pom:

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.6</version>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

pom.xml file of the module:

<build>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.6</version>
    <configuration>
      <archive>
        <manifest>
          <mainClass>org.jis.Main</mainClass>
          <addClasspath>true</addClasspath>
        </manifest>
      </archive>
    </configuration>
</plugin>
</plugins>

csenga :

In your case maven must be called like:

mvn clean package assembly:single

The other way to achive same result is to modify your pom:

  <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.0.0</version>
        <configuration>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id> 
            <phase>package</phase> <!-- bind to the packaging phase -->
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
 </plugin>

then run:

mvn clean package

ref: https://maven.apache.org/plugins/maven-assembly-plugin/usage.html

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=472939&siteId=1