Maven generate jar dependencies then war

Emowpy

I'm using m2e Maven Plugin for Eclipse. I'm having 5 eclipse projects. A web application project and then 4 projects as jars dependencies for my web application.

I would like to know how can I package jars before including them in the WAR using "mvn clean install" on war project.

Here's my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>dispatcher</groupId>
<artifactId>dispatcher</artifactId>
<version>4.0</version>
<packaging>war</packaging>
<build>
    <plugins>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <warSourceDirectory>WebContent</warSourceDirectory>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>referentiel</groupId>
        <artifactId>referentiel</artifactId>
        <version>4.7</version>
    </dependency>
    <dependency>
        <groupId>mailTemplates</groupId>
        <artifactId>mailTemplates</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>qualityTool</groupId>
        <artifactId>qualityTool</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>tools</groupId>
        <artifactId>tools</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
    ...
    ..
    .
</dependencies>
</project>

Thank you in advance.

Festus Tamakloe

The answer of @Jigar Joshi is good but i thing you need a view of structure which can help you to understand quickly what we mean.

I. Create a top level maven module (parent of war and jars) You habe already the 5 moduls that you need. Now create a new Maven project as parent which must contain only a pom.xml file.

parent project pom

 <project...>               
            <groupId>groupId</groupId>
            <artifactId>parent-pom</artifactId>
            <version>1.0-SNAPSHOT</version>
            <packaging>pom</packaging>
        <name>Define parent pom </name>
      <!-- modul -->
  <project>

II. Put your jar projects first as modul and at the end the war project. If you have another dependencies in the jar projects you may also try to order them consequently.

parent project pom

 <modules>
        <module>referentiel</module> <!-- jar -->
        <module>mailTemplates</module> <!-- jar -->
        <module>qualityTool</module> <!-- jar -->
        <module>tools</module> <!-- jar -->
        <module>dispatcher</module> <!-- war-->
    </modules>

III. in all other project put the parent reference into the poms

   <parent>
       <groupId>groupId</groupId>
       <artifactId>parent-pom</artifactId>
       <version>1.0-SNAPSHOT</version>
    <parent>

IV. Now you can go to inside the new created parent project and run from there

mvn clean install

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Generate jar file in Maven with dependencies and tests

From Dev

Maven - maven-war-plugin to generate jar and install it to maven local repository

From Dev

Building jar with dependencies maven

From Dev

Generate War file using Maven

From Dev

Generate a jar for maven

From Dev

Include JAR Maven project into WAR Maven project

From Dev

Maven not adding all dependencies to jar

From Dev

Using Maven in Ant for jar dependencies

From Dev

executable jar with dependencies using maven

From Dev

Maven jar without dependencies by default

From Dev

Maven Including test Scoped Transitive Dependencies in WAR

From Dev

Maven building a jar with dependencies unpacked inside the JAR

From Dev

Maven generate zip instead of just WAR file

From Dev

how to generate a checksum for a war file in maven

From Dev

Generate war file from existing maven project

From Dev

Maven generate zip instead of just WAR file

From Dev

Build war with maven plus a jar with a subset of classes

From Dev

Copy war dependency mentioned in maven jar module

From Dev

How to use maven shade to build jar and war

From Dev

MAVEN build does not generate jar

From Dev

Maven jar dependencies are displayed outside `Maven Dependencies` view

From Dev

How to generate a jar with internal dependencies bundled and external dependencies as external jars?

From Dev

How to include maven dependencies in a jar file?

From Dev

maven: including selected dependencies for single jar

From Dev

Maven dependencies regarding javax.persistence JAR?

From Dev

Maven dependency plugin copy jar with dependencies

From Dev

Maven packaging project as executuble JAR with dependencies

From Dev

Intellij Maven: Create jar with all library dependencies

From Dev

what are the jboss-client.jar maven dependencies?

Related Related

  1. 1

    Generate jar file in Maven with dependencies and tests

  2. 2

    Maven - maven-war-plugin to generate jar and install it to maven local repository

  3. 3

    Building jar with dependencies maven

  4. 4

    Generate War file using Maven

  5. 5

    Generate a jar for maven

  6. 6

    Include JAR Maven project into WAR Maven project

  7. 7

    Maven not adding all dependencies to jar

  8. 8

    Using Maven in Ant for jar dependencies

  9. 9

    executable jar with dependencies using maven

  10. 10

    Maven jar without dependencies by default

  11. 11

    Maven Including test Scoped Transitive Dependencies in WAR

  12. 12

    Maven building a jar with dependencies unpacked inside the JAR

  13. 13

    Maven generate zip instead of just WAR file

  14. 14

    how to generate a checksum for a war file in maven

  15. 15

    Generate war file from existing maven project

  16. 16

    Maven generate zip instead of just WAR file

  17. 17

    Build war with maven plus a jar with a subset of classes

  18. 18

    Copy war dependency mentioned in maven jar module

  19. 19

    How to use maven shade to build jar and war

  20. 20

    MAVEN build does not generate jar

  21. 21

    Maven jar dependencies are displayed outside `Maven Dependencies` view

  22. 22

    How to generate a jar with internal dependencies bundled and external dependencies as external jars?

  23. 23

    How to include maven dependencies in a jar file?

  24. 24

    maven: including selected dependencies for single jar

  25. 25

    Maven dependencies regarding javax.persistence JAR?

  26. 26

    Maven dependency plugin copy jar with dependencies

  27. 27

    Maven packaging project as executuble JAR with dependencies

  28. 28

    Intellij Maven: Create jar with all library dependencies

  29. 29

    what are the jboss-client.jar maven dependencies?

HotTag

Archive