How to create a jar without meta-inf folder in maven?

niken :

If I wanted to create a jar file without META-INF nonsense using jar utility I can pass the -M switch, which will:

   -M  do not create a manifest file for the entries

Note that this is a feature of the jar utility. If I use it, I will get a jar without the META-INF folder and included MANIFEST, basically just an archive of type jar with whatever files/directories I put in it.

How do I do this with the maven-jar-plugin? I need to do this to conform to another process. (They expect a jar with very specific file/folder layout and I cannot have a META-INF folder at the root of the jar file.)

I've got the configuration to create the jar file just right and I don't want to mess with another plugin...

Mifeet :

You can use maven-shade-plugin to achieve the desired effect:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.4.1</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
            <configuration>
                <artifactSet>
                    <includes>
                        <include>${project.groupId}:${project.artifactId}</include>
                    </includes>
                </artifactSet>
                <filters>
                    <filter>
                        <artifact>*:*</artifact>
                        <excludes>
                            <exclude>META-INF/</exclude>
                        </excludes>
                    </filter>
                </filters>
            </configuration>
        </execution>
    </executions>
</plugin>

The configuration filters out the META-INF directory and includes only the current project so that dependencies are not attached.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Maven: Exclude "META-INF/maven" folder from JAR

From Java

Exclude META-INF/maven folder from the generated jar file

From Java

How to include a config file in the "META-INF/services" folder of a JAR using Maven

From Dev

How to create jar file without java classes but with a folder using maven

From Dev

How is Minecraft able to function without a META-INF folder?

From Dev

How to access Exception object in a jsp page placed at 'META-INF/resources' folder of jar?

From Dev

How to create a jar with Maven that includes dependencies in a separate folder for each dependency

From Java

How can I create an executable jar without dependencies using Maven?

From Dev

Maven Eclipse Plugin automatically creates maven folder under META-INF

From Java

How to create a runnable jar with maven that includes dependencies in a separate "lib" folder (not an uber jar)

From Java

When building an application jar with Maven Shade, is it safe to exclude all META-INF/versions directories/files?

From Java

creating META-INF/services folder in Eclipse

From Dev

Git ignore is not ignoring folder **META-INF**

From Java

META-INF/services in JAR with Gradle

From Dev

How to create executable jar in Kotlin using maven-assembly-plugin without a main class?

From Dev

How to create a png in the resource folder of a jar/war?

From

Gradle duplicate entry error: META-INF/MANIFEST.MF (Or how to delete a file from jar)

From Java

Is it possible to have Maven "WAR" pom.xml package up my classes up in a JAR and put the JAR in the /WEB-INF/lib folder?

From Dev

Is it possible to create custom realm in tomcat without adding jar to lib folder?

From Dev

how to create jar for specific packages maven

From Java

How to create zip target instead of jar in maven?

From Java

Create a Java REST Application JAR without using Gradle/Maven?

From Dev

Create a single jar that will contain compiled classes and javadoc without Maven

From Dev

How to use maven to unpack resource folder when .jar is ran

From Java

How can I include a folder in the jar produced by Maven (not the content of the folder, the actual folder)

From Dev

How to create folder without trailing white space?

From Java

How can I add JAR files to the web-inf/lib folder in Eclipse?

From Dev

Maven include specific folder in JAR

From Dev

What are the purposes of files in META-INF folder of an APK file?

Related Related

  1. 1

    Maven: Exclude "META-INF/maven" folder from JAR

  2. 2

    Exclude META-INF/maven folder from the generated jar file

  3. 3

    How to include a config file in the "META-INF/services" folder of a JAR using Maven

  4. 4

    How to create jar file without java classes but with a folder using maven

  5. 5

    How is Minecraft able to function without a META-INF folder?

  6. 6

    How to access Exception object in a jsp page placed at 'META-INF/resources' folder of jar?

  7. 7

    How to create a jar with Maven that includes dependencies in a separate folder for each dependency

  8. 8

    How can I create an executable jar without dependencies using Maven?

  9. 9

    Maven Eclipse Plugin automatically creates maven folder under META-INF

  10. 10

    How to create a runnable jar with maven that includes dependencies in a separate "lib" folder (not an uber jar)

  11. 11

    When building an application jar with Maven Shade, is it safe to exclude all META-INF/versions directories/files?

  12. 12

    creating META-INF/services folder in Eclipse

  13. 13

    Git ignore is not ignoring folder **META-INF**

  14. 14

    META-INF/services in JAR with Gradle

  15. 15

    How to create executable jar in Kotlin using maven-assembly-plugin without a main class?

  16. 16

    How to create a png in the resource folder of a jar/war?

  17. 17

    Gradle duplicate entry error: META-INF/MANIFEST.MF (Or how to delete a file from jar)

  18. 18

    Is it possible to have Maven "WAR" pom.xml package up my classes up in a JAR and put the JAR in the /WEB-INF/lib folder?

  19. 19

    Is it possible to create custom realm in tomcat without adding jar to lib folder?

  20. 20

    how to create jar for specific packages maven

  21. 21

    How to create zip target instead of jar in maven?

  22. 22

    Create a Java REST Application JAR without using Gradle/Maven?

  23. 23

    Create a single jar that will contain compiled classes and javadoc without Maven

  24. 24

    How to use maven to unpack resource folder when .jar is ran

  25. 25

    How can I include a folder in the jar produced by Maven (not the content of the folder, the actual folder)

  26. 26

    How to create folder without trailing white space?

  27. 27

    How can I add JAR files to the web-inf/lib folder in Eclipse?

  28. 28

    Maven include specific folder in JAR

  29. 29

    What are the purposes of files in META-INF folder of an APK file?

HotTag

Archive