I have a maven project with two modules : core and webapp.
The webapp module is a war file to be deployed to wildfly. It has a dependency to the core module.
I can run mvn clean package in the parent directory of my modules. I am able to deploy de war file manually to wildfly and it works. Unfortunately if I run mvn wildfly:deploy in the webapp directory I get :
Failed to execute goal on project webapp: Could not resolve dependencies for project gbt:webapp:war:1.0-SNAPSHOT: Could not find artifact gbt:core:jar:1.0-SNAPSHOT
What shall I do to deploy the war file with the wildfly plugin ?
parent pom
<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>gbt</groupId>
<artifactId>unite_compte</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<version.server.bom>25.0.1.Final</version.server.bom>
<version.microprofile.bom>25.0.1.Final</version.microprofile.bom>
<jakartaee.version>8.0.0</jakartaee.version>
<version.wildfly.maven.plugin>2.1.0.Final</version.wildfly.maven.plugin>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
<dependencyManagement>
<dependencies>
<!-- importing the jakartaee8-with-tools BOM adds specs and other useful artifacts as managed dependencies -->
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>wildfly-jakartaee8-with-tools</artifactId>
<version>${version.server.bom}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>${jakartaee.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${version.wildfly.maven.plugin}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<modules>
<module>core</module>
<module>webapp</module>
</modules>
</project>
webapp pom :
<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>
<parent>
<groupId>gbt</groupId>
<artifactId>unite_compte</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>gbt</groupId>
<artifactId>webapp</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>gbt</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<!--finalName>${project.artifactId}</finalName-->
<finalName>unite_compte</finalName>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
core pom
<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>
<parent>
<groupId>gbt</groupId>
<artifactId>unite_compte</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>gbt</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
</build>
</project>
You need to run mvn install, or the artifact for the core module is built but never installed into the local repository and cannot be resolved when building the webapp module.
Related
The IDEA app told me that Invalid packaging for parent POM org.springframework.boot:spring-boot-starter-web:1.5.9.RELEASE, must be "pom" but is "jar" while I packaged my easy-start spring-boot application, how to solve this problem?
My platform is macOS 10.15.7 with 3 JDKs(1.8, 11, 14), and I am using maven-3.6.3, my maven settings are also changed the JDK to 1.8 and 11
The pom.xml file is as followed:
<?xml version="1.0" encoding="UTF-8"?>
<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>org.example</groupId>
<artifactId>SpringBoot-01-HelloWorld</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<parent>
<artifactId>spring-boot-starter-web</artifactId>
<groupId>org.springframework.boot</groupId>
<version>1.5.9.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
The parent POM should be the Spring Boot parent project
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>
Lets say I have
1. a bom project(named as bom)
2. a jar project(named as A)
3. a war project(named as B)
bom project has jackson-data version as 2.8.5 and 2.8.1 in properties and in dependencymanagement section 2.8.5 for jackson-data.
project A which inherits bom declares jackson-data dependency in it with version 2.8.1.
project B depends on project A and inherits bom. it does not declare the jackson-data in its dependency
now when I look at lib dir of Project B, jackson-data version is 2.8.5 where as project A is declaring it as 2.8.1.
irrespective of what is declared in dependency it is taking the version declared in bom. is there any way to resolve the transitive dependency of jackson-data in project B as it is declared in project A means a version of 2.8.1 and not 2.8.5 while using the bom?
Below are the poms
BOM PROJECT
<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>com.test</groupId>
<artifactId>bom</artifactId>
<version>1.1</version>
<packaging>pom</packaging>
<properties>
<jackson-databind.version>2.8.5</jackson-databind.version>
<jackson-databind.version.A>2.8.1</jackson-databind.version.A>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.test</groupId>
<artifactId>A</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-databind.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
pom of project A
<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>
<parent>
<groupId>com.test</groupId>
<artifactId>bom</artifactId>
<version>1.1</version>
</parent>
<groupId>com.test</groupId>
<artifactId>A</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.1</version>
</dependency>
</dependencies>
</project>
Project B
<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>
<parent>
<groupId>com.emirates.ibe</groupId>
<artifactId>bom</artifactId>
<version>1.1</version>
</parent>
<groupId>com.test</groupId>
<artifactId>B</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>com.test</groupId>
<artifactId>A</artifactId>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warName>B</warName>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
DependencyManagement overrides transitive dependencies. This is what happens here (and this is how it's meant to be).
If you want a different version, either change the dependencyManagement or override in the project in which you use A
I have the following hierarchy:
my-app
\__ pom.xml
\__ jar-module
\__ pom.xml
\__ webapp-module
\__ pom.xml
\__ core-module
\__ pom.xml
Where core-module acts as a library providing common code for webapp-module and jar-module.
webapp-module works just fine, it's generating a war as expected and the code from core-module is being used.
The problem is with jar-module. I have no idea why, but jar-module isn't outputting a jar, even when I select to run (in IntelliJ IDEA) a simple main with a println() it does run, but there's no jar on the target folder.
How can I solve this and make the jar-module output a jar?
I am not very experienced with Maven, my goal is to be able to use the same Jersey code on a local Glassfish and in a jar to be deployed at AWS Lambda Serverless Java Container so I can easily test it locally before deployment.
I would appreciate any corrections on my hierarchy and on pom errors as well.
my-app pom.xml has a packaging of pom, but core-module and jar-module have a packaging of jar and webapp-module has a packaging of war.
here are the POMs:
my-app POM:
<?xml version="1.0" encoding="UTF-8"?>
<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>com.example.myapp</groupId>
<artifactId>myapp</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>core-module</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
core-module POM:
(I also tried it with <packaging>pom</packaging> and no jar skip properties, it didn't work)
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<artifactId>myapp</artifactId>
<groupId>com.example.myapp</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>webservice-core</artifactId>
<packaging>jar</packaging>
<modules>
<module>../jar-module</module>
<module>../webapp-module</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.deploy.skip>true</maven.deploy.skip>
<jar.skipIfEmpty>true</jar.skipIfEmpty>
<maven.install.skip>true</maven.install.skip>
<javax-ws-rs-version.version>2.1</javax-ws-rs-version.version>
<jersey.version>2.26</jersey.version>
</properties>
<dependencies>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>${javax-ws-rs-version.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey.version}</version>
</dependency>
</dependencies>
</project>
webapp-module POM:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>core-module</artifactId>
<groupId>com.example.myapp</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>webapp-module</artifactId>
<packaging>war</packaging>
<name>webapp Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<jersey.version>2.26</jersey.version>
</properties>
<dependencies>
<dependency>
<artifactId>core-module</artifactId>
<groupId>com.example.myapp</groupId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>${jersey.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>webapp</finalName>
</build>
</project>
jar-module POM:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<artifactId>core-module</artifactId>
<groupId>com.example.myapp</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>jar-module</artifactId>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<jersey.version>2.26</jersey.version>
<maven-shade-plugin.version>3.1.0</maven-shade-plugin.version>
</properties>
<dependencies>
<dependency>
<artifactId>core-module</artifactId>
<groupId>com.example.myapp</groupId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.amazonaws.serverless</groupId>
<artifactId>aws-serverless-java-container-jersey</artifactId>
<version>0.8</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version>
<configuration> <createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
my-app is your parent module and rest are child so provide a dependencies order in parent project pom so that when you build the project ,maven will provide the dependencies as you provided in parent module.
<modules>
<module>core-module</module>
</modules>
Provide the proper ordering like parent and child modules to understand the maven for building.
my-app
<modules>
<module>core-module</module>
<module>jar-module</module>
<module>web-module</module>
</modules>
core-module
no <modules>
This is a clean hierarchy, mirrored by the directory hierarchy.
There is a difference between modules and there container and the parent relation, and other subtleties. So maybe this helps.
This application was built 15 years ago, I guess. The client has sought an upgrade/modification of this app, which I am not aware of.
I have built some POM.xml scripts. When I tried to upload it in development server, it was expecting a .WAR file inside the .EAR that I had uploaded.
Here is my pom.xml script. Please suggest some modifications.
<groupId>itaras</groupId>
<artifactId>itaras</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>ear</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>1.0</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<finalName>MyEarFile</finalName>
<version>5</version>
<generatedDescriptorLocation>$D:/itaras/ITARAS_Branch_3Aug2017/itaras/WebContent</generatedDescriptorLocation>
<modules>
<webModule>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<uri>appITARAS.war</uri>
<bundleFileName>appITARAS.war</bundleFileName>
<contextRoot>/ITARAS</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
You need a parent pom like this :
<?xml version="1.0" encoding="UTF-8"?>
<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>itaras</groupId>
<artifactId>itaras</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>itaras-ear</module>
<module>itaras-war</module>
</modules>
</project>
Then you will have a war project which is a child/module of the parent. This will be your existing project like:
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>itaras</groupId>
<artifactId>itaras</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>itaras-war</artifactId>
<packaging>war</packaging>
.....
Then you will have an ear project which will include the war project as a dependency, something like:
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>itaras</groupId>
<artifactId>itaras</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>itaras-ear</artifactId>
<packaging>ear</packaging>
<dependencies>
<dependency>
<groupId>itaras</groupId>
<artifactId>itaras-war</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
I have a maven project with 4 subprojects, let's say the following structure:
Main
|- core (jar)
|- webapp1 (war)
|- webapp2 (war)
|- webapp3 (war)
The three webapp subprojects depends on core subproproject. So the poms are like:
Main (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>myGroup</groupId>
<artifactId>MyArtifact</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<properties>
</properties>
<repositories>
</repositories>
<modules>
<module>core</module>
<module>webapp1</module>
<module>webapp2</module>
<module>webapp3</module>
</modules>
...
</project>
Core (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>
<artifactId>core</artifactId>
<packaging>jar</packaging>
<parent>
<groupId>MyGroup</groupId>
<artifactId>MyArtifact</artifactId>
<version>1.0</version>
</parent>
...
</project>
And web app poms are like this:
<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>
<artifactId>webapp1</artifactId>
<version>1.1.0-A1</version>
<packaging>war</packaging>
<parent>
<groupId>MyGroup</groupId>
<artifactId>MyArtifact</artifactId>
<version>1.0</version>
</parent>
<dependencies>
<dependency>
<groupId>MyGroup</groupId>
<artifactId>core</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
...
</project>
Everything worked fine during months when i execute 'mvn package' on the project's root folder and deploy the wars being generated.
But now i want to deploy an Ear instead of separate War files so i added a subproject called earproject. With the following 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>
<artifactId>earproject</artifactId>
<packaging>ear</packaging>
<parent>
<groupId>MyGroup</groupId>
<artifactId>MyArtifact</artifactId>
<version>1.0</version>
</parent>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10.1</version>
<configuration>
<finalName>EarName</finalName>
<version>5</version>
<generatedDescriptorLocation>${basedir}/src/main/applicatio/META-INF</generatedDescriptorLocation>
<modules>
<webModule>
<groupId>MyGroup</groupId>
<artifactId>webapp1</artifactId>
<bundleFileName>webapp1.war</bundleFileName>
<contextRoot>/webapp1</contextRoot>
</webModule>
<webModule>
<groupId>MyGroup</groupId>
<artifactId>webapp2</artifactId>
<bundleFileName>webapp2.war</bundleFileName>
<contextRoot>/webapp2</contextRoot>
</webModule>
<webModule>
<groupId>MyGroup</groupId>
<artifactId>webapp3</artifactId>
<bundleFileName>webapp3.war</bundleFileName>
<contextRoot>/webapp3</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>MyGroup</groupId>
<artifactId>core</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>MyGroup</groupId>
<artifactId>webapp1</artifactId>
<type>war</type>
<version>1.0</version>
</dependency>
<dependency>
<groupId>MyGroup</groupId>
<artifactId>webapp2</artifactId>
<type>war</type>
<version>1.0</version>
</dependency>
<dependency>
<groupId>MyGroup</groupId>
<artifactId>webapp3</artifactId>
<type>war</type>
<version>1.0</version>
</dependency>
</dependencies>
</project>
Whith this configuration when i run 'mvn clean' and 'mvn package' the ear file is generated but the war files inside the ear file contains an invalid old version of the core.jar.
If i check target directories on webapp projects the War files has a right core.jar version. It seems like EAR packaging uses an old version of the jar that is in my mvn repository, but i don't know why, because on the separate war files maven puts the recently created core.jar.
Why is this happening? Do i need to specify anything more on earproject's pom.xml?
I think the problem you are describing can be solved easily. In appearance Maven ear plugin is getting the core jar file from the repository instead of the new compiled one. I don't know the reason of this plugin's behaviour but I found this issue long time ago.
You should install your jar libraries in the local repository by using the following command
mvn clean install
instead of
mvn package
which only generates the artifacts