maven copy a particular dependency jar to a specific directory in the .war file

Kiran Mohan

I am trying out a Simple Java Web Start project based on the Oracle Tutorial. I am using maven to package it as a webapp and deploy it to application server. The full source code is available here

https://github.com/KiranMohan/dynamic-tree-javaws-sample-project

The maven project structure is like

parent  
|--lib
|--webapp

The webapp module is a maven war module. It is required to package lib.jar at the root of webapp.war. NOT under WEB-INF/lib.

How to achieve this in maven?

Kiran Mohan

I found that the right way to do this is to use the maven-dependency-plugin. Since "lib.jar" is not used in the compile phase of "webapp" module, it is only a package time dependency. Using maven-dependency-plugin, I can copy lib.jar to any required directory during the prepare-package phase. The maven-war package would then include the lib.jar in the .war package.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
        <execution>
            <id>copy</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>copy</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>[ group id ]</groupId>
                        <artifactId>[artifact id]</artifactId>
                        <version>[ version ]</version>
                        <outputDirectory>${project.build.directory}/${project.artifactId}</outputDirectory>                                 
                    </artifactItem>
                </artifactItems>
                <!-- other configurations here -->
            </configuration>
        </execution>
    </executions>
</plugin>

Update: There is a webstart-maven-plugin that does a better job of packaging javaws applications. See my sample project
https://github.com/KiranMohan/dynamic-tree-javaws-sample-project
for details

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 dependency plugin copy jar with dependencies

From Dev

Packaging separate jar file to war file in maven

From Java

how to copy dependency sources to a directory in maven

From Java

Copy directory from a jar file

From Dev

Maven Copy Folder Before War File Generation

From Dev

Copy dependency of a maven project to specific folder

From Dev

Create war file with Windows batch and exclude specific directory without maven ant etc

From Dev

How to copy war file into a particular destination using batch command?

From Dev

Copy file into specific directory in java

From Java

How to download maven dependency as *.jar file?

From Dev

maven dependency jar file displayed as folder icon

From Dev

Maven not finding dependency with only jar file

From Dev

How to read war-file manifest in its jar-dependency?

From Java

Maven: how to copy artifact to specific directory?

From Dev

How to include maven dependency libraries in war file using Ant build

From Dev

Maven - why is jar file generated along with war file?

From Java

Maven - Generate Jar and War

From Dev

Dockerfile copy jar file from another directory

From Java

How to tell Maven to include the jar dependency, not the subproject source directory in Eclipse?

From Dev

The POM for org.apache.maven.plugins:maven-war-plugin:jar:3.0 is missing, no dependency information available

From Dev

maven: how to build the dependency from source.jar to jar files and put the jar file as it dependency?

From Java

Maven plugin to delete jar file when building war

From Dev

spring boot maven how to build both war and jar file

From Dev

Maven ant task to add system path jar to WAR file

From Java

How to download sources for an specific JAR dependency of a Maven project

From Java

Maven dependency to jar in Nexus

From Dev

How to Copy Only the Directories with a specific File in that directory

From Dev

Find the biggest file with criteria and copy it to a specific directory

From Java

Maven clean install not including sqlite dependency for executable jar file

Related Related

  1. 1

    Maven dependency plugin copy jar with dependencies

  2. 2

    Packaging separate jar file to war file in maven

  3. 3

    how to copy dependency sources to a directory in maven

  4. 4

    Copy directory from a jar file

  5. 5

    Maven Copy Folder Before War File Generation

  6. 6

    Copy dependency of a maven project to specific folder

  7. 7

    Create war file with Windows batch and exclude specific directory without maven ant etc

  8. 8

    How to copy war file into a particular destination using batch command?

  9. 9

    Copy file into specific directory in java

  10. 10

    How to download maven dependency as *.jar file?

  11. 11

    maven dependency jar file displayed as folder icon

  12. 12

    Maven not finding dependency with only jar file

  13. 13

    How to read war-file manifest in its jar-dependency?

  14. 14

    Maven: how to copy artifact to specific directory?

  15. 15

    How to include maven dependency libraries in war file using Ant build

  16. 16

    Maven - why is jar file generated along with war file?

  17. 17

    Maven - Generate Jar and War

  18. 18

    Dockerfile copy jar file from another directory

  19. 19

    How to tell Maven to include the jar dependency, not the subproject source directory in Eclipse?

  20. 20

    The POM for org.apache.maven.plugins:maven-war-plugin:jar:3.0 is missing, no dependency information available

  21. 21

    maven: how to build the dependency from source.jar to jar files and put the jar file as it dependency?

  22. 22

    Maven plugin to delete jar file when building war

  23. 23

    spring boot maven how to build both war and jar file

  24. 24

    Maven ant task to add system path jar to WAR file

  25. 25

    How to download sources for an specific JAR dependency of a Maven project

  26. 26

    Maven dependency to jar in Nexus

  27. 27

    How to Copy Only the Directories with a specific File in that directory

  28. 28

    Find the biggest file with criteria and copy it to a specific directory

  29. 29

    Maven clean install not including sqlite dependency for executable jar file

HotTag

Archive