문제

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.

도움이 되었습니까?

해결책

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

다른 팁

Either create a top level maven module (parent of war and jars) and execute mvn clean install

---pom.xml
   |
   |dispatcher---pom.xml (war)
   |qualityTool----pom.xml (jar)
   |mailTemplates----pom.xml (jar)
   |referentiel----pom.xml (jar)
   |tools----pom.xml (jar)

or use --also-make command line option to make dependencies as well

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top