简体   繁体   中英

maven-jar-plugin does not generate MANIFEST

I cant generate MANIFEST file using maven... I try everything and I didnt find the solution. The jar file is generate correct, but manifest is missing.

This is the part of my pom.xml:

    <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <useDefaultManifestFile> true </useDefaultManifestFile>
                <!-- archive> <manifest> <mainClass>net.menago.core.main.Menago</mainClass> 
                    </manifest> 
                </archive -->
                <!-- archive>
                    <index>true</index>
                    <manifest>
                        <addClasspath>true</addClasspath>
                    </manifest>
                    <manifestEntries>
                        <mode>development</mode>
                        <url>${project.url}</url>
                        <key>value</key>
                    </manifestEntries>
                </archive-->
            </configuration>
        </plugin>

As you can see there are some commented codes which does not work too. I've tried mvn clean install, compile, package...

Thanks for any advice!

检查您的包装元素是否设置了价值包

<packaging>bundle</packaging>

Use this instead:

<plugins>
  <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.9.0</version>
    <configuration>
      <source>${java.version}</source>
      <target>${java.version}</target>
    </configuration>
  </plugin>
  <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
  </plugin>
</plugins>

May be this will work

<configuration> 
                    <archive> 
                      <manifest> <mainClass>net.menago.core.main.Menago</mainClass>                                  
                        <index>true</index>                  
                            <addClasspath>true</addClasspath>                   
                        <manifestEntries>
                            <mode>development</mode>
                            <url>${project.url}</url>
                            <key>value</key>
                        </manifestEntries>
                      </manifest>
                    </archive>
      </configuration>

Clearly your pasted segment will not work due to the comments, so I make the assumption that you have posted what you have to show what you have been trying to use.

The correct usage of <manifestEntries> is as so:

      <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <archive>
                    <manifestEntries>
                        <yourKey>your value</yourKey>
                    </manifestEntries>
                </archive>
            </configuration>
      </plugin>

This is at odds with your concurrent use of <useDefaultManifestFile> which will produce a standard output.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM