Using maven assembly plugin to create ZIP file containing a fat jar (jar-with-dependencies)

Marc Giombetti

I am using the maven assembly-plugin and I want to create a ZIP file, which among other files contains a fat jar (jar-with-dependencies). I cannot create this in one run using mvn package. I can either uncomment the configuration for the descriptor or uncomment the jar-with-dependencies part.

The build section of the pom.xml is as follows:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <descriptors>
                    <descriptor>src/main/assembly/dist.xml</descriptor>
                </descriptors>
                <finalName>sample-documentum-downloader</finalName>
            </configuration>

            <executions>
                <execution>
                    <id>jar-with-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <configuration>
                        <finalName>${project.artifactId}</finalName>
                        <appendAssemblyId>false</appendAssemblyId>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                        <archive>
                            <manifest>
                                <addClasspath>true</addClasspath>
                                <mainClass>com.foo.DownloadDocuments</mainClass>
                            </manifest>
                        </archive>
                    </configuration>
                </execution>

                <execution>
                    <id>assemble-all</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

and the dist.xml is:

<assembly>
<id>dist</id>
<formats>
    <format>zip</format>
</formats>
<files>
    <file>
        <source>target/${project.artifactId}.jar</source>
        <outputDirectory>/</outputDirectory>
    </file>
    <file>
        <source>data/input/docId.txt</source>
        <outputDirectory>data/input/</outputDirectory>
    </file>
    <file>
        <source>data/export/exported_files_will_be_created_here.txt</source>
        <outputDirectory>data/export/</outputDirectory>
    </file>
    <file>
        <source>src/main/resources/dfc.properties</source>
        <outputDirectory>/</outputDirectory>
    </file>
    <file>
        <source>src/main/resources/dfc.keystore</source>
        <outputDirectory>/</outputDirectory>
    </file>

</files>
<fileSets>
    <fileSet>
        <directory>${project.basedir}</directory>
        <includes>
            <include>*.cmd</include>
            <include>README.pdf</include>
        </includes>
        <useDefaultExcludes>true</useDefaultExcludes>
    </fileSet>
</fileSets>

How can I restructure to create a ZIP including the far JAR in one run.

Thanks for your support.

Tunaki

The problem is that you declared the <configuration> element global to the plugin. This means that all executions will inherit that configuration: assemble-all but also jar-with-dependencies. As such, the inherited <descriptors> is probably messing with the <descriptorRefs>.

You need to move that <configuration> element to the specific assemble-all execution, just like you did for the jar-with-dependencies execution.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Maven: Is it possible to create a fat jar containing only dependencies and a jar with only application code?

From Dev

How to configure a manifest file of a jar file by using the maven assembly plugin?

From Dev

Maven assembly plugin: dependency jars are not included, fat jar without jars

From Java

How to exclude dependencies from maven assembly plugin : jar-with-dependencies?

From Dev

Using Maven to create Javadocs as a zip file instead of a jar file

From Java

Optional jar inclusion in fat jar in maven plugin

From Dev

Is the content of the Maven Assesmnly plugin's jar-with-dependencies descriptorRef documented as an example assembly descriptor file anywhere?

From Java

spring-boot-maven-plugin doesn't create fat jar

From Java

Maven assembly plugin not producing jar-with-dependencies any more, why?

From Java

Include Maven profile name in assembly-plugin built (with dependencies) jar

From

Building a fat jar using maven

From Dev

Maven shade plugin - Jar and dependencies

From Dev

tests fat jar with maven shade-plugin

From Dev

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

From Dev

remove all dependencies of a jar within a maven assembly

From Dev

How to create and include a zip file inside a tar using maven assembly plugin

From Dev

How do I create an executable jar file including dependencies where the main class is in Test, using Maven

From Dev

How to force adding provided dependency to fat jar using sbt-assembly plugin?

From Java

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

From Java

How can I create an executable JAR with dependencies using Maven?

From Dev

How can I create an executable/runnable JAR with dependencies using Maven?

From Java

maven-dependency-plugin generates duplicate files in jar-with-dependencies.jar file

From Java

Renaming a fat jar with Maven

From Java

Maven Assembly Plugin : Resources are copied at root of jar

From Dev

Maven dependency plugin copy jar with dependencies

From Java

How to add local jar to fat jar as a dependency using maven?

From Dev

How to bundle a JAR file with its dependencies using maven

From Dev

Maven assembly plugin zips the jar.original content and not the executable jar

From Dev

Execution order of maven-assembly-plugin and maven-jar-plugin

Related Related

  1. 1

    Maven: Is it possible to create a fat jar containing only dependencies and a jar with only application code?

  2. 2

    How to configure a manifest file of a jar file by using the maven assembly plugin?

  3. 3

    Maven assembly plugin: dependency jars are not included, fat jar without jars

  4. 4

    How to exclude dependencies from maven assembly plugin : jar-with-dependencies?

  5. 5

    Using Maven to create Javadocs as a zip file instead of a jar file

  6. 6

    Optional jar inclusion in fat jar in maven plugin

  7. 7

    Is the content of the Maven Assesmnly plugin's jar-with-dependencies descriptorRef documented as an example assembly descriptor file anywhere?

  8. 8

    spring-boot-maven-plugin doesn't create fat jar

  9. 9

    Maven assembly plugin not producing jar-with-dependencies any more, why?

  10. 10

    Include Maven profile name in assembly-plugin built (with dependencies) jar

  11. 11

    Building a fat jar using maven

  12. 12

    Maven shade plugin - Jar and dependencies

  13. 13

    tests fat jar with maven shade-plugin

  14. 14

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

  15. 15

    remove all dependencies of a jar within a maven assembly

  16. 16

    How to create and include a zip file inside a tar using maven assembly plugin

  17. 17

    How do I create an executable jar file including dependencies where the main class is in Test, using Maven

  18. 18

    How to force adding provided dependency to fat jar using sbt-assembly plugin?

  19. 19

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

  20. 20

    How can I create an executable JAR with dependencies using Maven?

  21. 21

    How can I create an executable/runnable JAR with dependencies using Maven?

  22. 22

    maven-dependency-plugin generates duplicate files in jar-with-dependencies.jar file

  23. 23

    Renaming a fat jar with Maven

  24. 24

    Maven Assembly Plugin : Resources are copied at root of jar

  25. 25

    Maven dependency plugin copy jar with dependencies

  26. 26

    How to add local jar to fat jar as a dependency using maven?

  27. 27

    How to bundle a JAR file with its dependencies using maven

  28. 28

    Maven assembly plugin zips the jar.original content and not the executable jar

  29. 29

    Execution order of maven-assembly-plugin and maven-jar-plugin

HotTag

Archive