Maven assembly plugin not loading dependency from local repository - maven

I am trying to build a parent project containing several sub-modules and a "packaging" sub-module - exactly as described under https://maven.apache.org/plugins/maven-assembly-plugin/examples/multimodule/module-binary-inclusion-simple.html
The sub-modules get built and installed in the local repository, but when the "packaging" sub-module gets built, maven complains about not being able to find one of the other sub-modules - instead it tries to download it from the Central Maven Nexus (where it can't find it, of course).
Anyone have an idea what I could be missing?
package/pom.xml:
<?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>group</groupId>
<artifactId>parent</artifactId>
<version>CURRENT</version>
</parent>
<groupId>group</groupId>
<artifactId>package</artifactId>
<version>CURRENT</version>
<packaging>pom</packaging>
<name>package module</name>
<properties>
<project.reporting.outputEncoding>ISO-8859-15</project.reporting.outputEncoding>
<project.build.sourceEncoding>ISO-8859-15</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>group</groupId>
<artifactId>common</artifactId>
<version>CURRENT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>group</groupId>
<artifactId>metaserviceclient</artifactId>
<version>CURRENT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>group</groupId>
<artifactId>hierarchyclient</artifactId>
<version>CURRENT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>distro-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>package.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
package/package.xml
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>bin</id>
<formats>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>group:*</include>
</includes>
<binaries>
<includeDependencies>true</includeDependencies>
<unpack>false</unpack>
<outputDirectory>opt/lib</outputDirectory>
<outputFileNameMapping>${artifactId}.${extension}</outputFileNameMapping>
</binaries>
</moduleSet>
</moduleSets>
</assembly>
hierarchyclient/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>group</groupId>
<artifactId>hierarchyclient</artifactId>
<name>Hierarchy client</name>
<parent>
<groupId>group</groupId>
<artifactId>parent</artifactId>
<version>CURRENT</version>
</parent>
<dependencies>
<dependency>
<groupId>xom</groupId>
<artifactId>xom</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>group</groupId>
<artifactId>common</artifactId>
<version>CURRENT</version>
</dependency>
<dependency>
<groupId>junit-addons</groupId>
<artifactId>junit-addons</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
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>parent</artifactId>
<groupId>group</groupId>
<version>CURRENT</version>
<packaging>pom</packaging>
<modules>
<module>hierarchyclient</module>
<module>common</module>
<module>metaserviceclient</module>
<module>package</module> <!-- responsible for package preparation -->
</modules>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<fork>true</fork>
<compilerVersion>1.8</compilerVersion>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>ISO-8859-15</project.build.sourceEncoding>
<project.reporting.outputEncoding>ISO-8859-15</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
maven output:
[15:27:28][INFO] --- maven-install-plugin:2.3.1:install (default-install) # hierarchyclient ---
[15:27:28][INFO] Installing /opt/frisk/teamcity_prd1/work/ac40d96bc266d196/hierarchyclient/target/hierarchyclient-CURRENT.jar to /opt/frisk/home/friskpkg/.m2/repository/group/hierarchyclient/CURRENT/hierarchyclient-CURRENT.jar
[15:27:28][INFO] Installing /opt/frisk/teamcity_prd1/work/ac40d96bc266d196/hierarchyclient/pom.xml to /opt/frisk/home/friskpkg/.m2/repository/group/hierarchyclient/CURRENT/hierarchyclient-CURRENT.pom
and later
[15:27:31][group:package] Downloading: http://$REPOSITORY/nexus/content/groups/public/group/hierarchyclient/CURRENT/hierarchyclient-CURRENT.pom
[15:27:31][group:package] Downloading: http://repo.maven.apache.org/maven2/coba/frisk/legacy/hierarchyclient/CURRENT/hierarchyclient-CURRENT.pom
[15:27:31][group:package] Failed to execute goal on project package: Could not resolve dependencies for project group:package:pom:CURRENT: Failed to collect dependencies for [group:common:jar:CURRENT (compile), group:metaserviceclient:jar:CURRENT (compile), group:hierarchyclient:jar:CURRENT (compile), junit:junit:jar:4.12 (test)]

Related

What are the best practices for creating a quarkus multi-module project?

I want to create a multi-module quarkus project, here's what I did :
Create a normal qurakus project by IDEA
Right click on the project folder and select "Add Module", Added 3 sub-modules : "controller","res","package".
I want the "package" module to be an uber-jar, as a runnable jar that contains all the other modules, so I modified the pom.xml file of each module :
this is the root module pom.xml :
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://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>
<groupId>io.github.jiayaoO3O</groupId>
<artifactId>yirgacheffe</artifactId>
<packaging>pom</packaging>
<version>1.0.0-SNAPSHOT</version>
<modules>
<module>controller</module>
<module>res</module>
<module>package</module>
</modules>
<properties>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus-plugin.version>1.13.0.Final</quarkus-plugin.version>
<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.version>1.13.0.Final</quarkus.platform.version>
<surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.jboss.jandex</groupId>
<artifactId>jandex-maven-plugin</artifactId>
<version>1.0.8</version>
<executions>
<execution>
<id>make-index</id>
<goals>
<goal>jandex</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus-plugin.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>build</goal>
<goal>generate-code</goal>
<goal>generate-code-tests</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemPropertyVariables>
<native.image.path>
${project.build.directory}/${project.build.finalName}-runner
</native.image.path>
<java.util.logging.manager>org.jboss.logmanager.LogManager
</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>
</profiles>
</project>
this is the controller module pom.xml :
<?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">
<parent>
<artifactId>yirgacheffe</artifactId>
<groupId>io.github.jiayaoO3O</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>controller</artifactId>
<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
</properties>
</project>
this is the res module pom.xml :
<?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">
<parent>
<artifactId>yirgacheffe</artifactId>
<groupId>io.github.jiayaoO3O</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>res</artifactId>
<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
</properties>
</project>
this is the package module pom.xml :
<?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">
<parent>
<artifactId>yirgacheffe</artifactId>
<groupId>io.github.jiayaoO3O</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>package</artifactId>
<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>io.github.jiayaoO3O</groupId>
<artifactId>controller</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>io.github.jiayaoO3O</groupId>
<artifactId>res</artifactId>
<version>${project.parent.version}</version>
</dependency>
</dependencies>
</project>
At the end, I added the application.properties file to the resources folder of the "package" module, adding the required configuration.
Finally, I ran mvn clean package in the root module, and got the package-1.0.0-SNAPSHOT-runner.jar file, which worked perfectly.
So the question I want to ask is, are my steps above, the best practice for building multi-module quarkus projects? Are there any issues that I am not aware of?
The structure described in the question looks reasonable. I would suggest the following improvements though:
there is no need to repeat maven.compiler.source and maven.compiler.target properties in the child modules, they are inherited from the <parent>;
there is no need to run quarkus-maven-plugin in all modules, move it to the package module;
same applies to the profile native.
Keep the jandex-maven-plugin configured for all modules, as described in the Quarkus - Working with multi-module projects.
I have found this sample multi module Quarkus project:
https://github.com/Rashmini/Quarkus-multimodule-project
Edit:
The above project is a bit old, I created a new sample multi-module project with Quarkus 2.4.2 Final, which contains two modules quickstart-core and quickstart-rest, with jandex-maven-plugin for CDI bean discovery.
https://github.com/bgizdov/quarkus-2-multi-module-project-quickstart

Issue while adding maven dependency

I am new to Maven and have been trying to configure an existing web project to Maven project.
I am getting the below error on adding hibernate dependencies.
**cvc-complex-type.2.4.a: Invalid content was found starting with element 'dependency'. One of '{"http://maven.apache.org/POM/4.0.0":parent, "http://maven.apache.org/POM/4.0.0":name, "http://maven.apache.org/POM/
4.0.0":description, "http://maven.apache.org/POM/4.0.0":url, "http://maven.apache.org/POM/4.0.0":prerequisites, "http://maven.apache.org/POM/4.0.0":issueManagement, "http://maven.apache.org/POM/4.0.0":ciManagement,
"http://maven.apache.org/POM/4.0.0":inceptionYear, "http://maven.apache.org/POM/4.0.0":mailingLists, "http://maven.apache.org/POM/4.0.0":developers, "http://maven.apache.org/POM/4.0.0":contributors, "http://
maven.apache.org/POM/4.0.0":licenses, "http://maven.apache.org/POM/4.0.0":scm, "http://maven.apache.org/POM/4.0.0":organization, "http://maven.apache.org/POM/4.0.0":build, "http://maven.apache.org/POM/4.0.0":profiles,
"http://maven.apache.org/POM/4.0.0":modules, "http://maven.apache.org/POM/4.0.0":repositories, "http://maven.apache.org/POM/4.0.0":pluginRepositories, "http://maven.apache.org/POM/4.0.0":dependencies, "http://
maven.apache.org/POM/4.0.0":reports, "http://maven.apache.org/POM/4.0.0":reporting, "http://maven.apache.org/POM/4.0.0":dependencyManagement, "http://maven.apache.org/POM/4.0.0":distributionManagement, "http://
maven.apache.org/POM/4.0.0":properties}' is expected.**
The pom.xml is as below -
<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>Adore_india</groupId>
<artifactId>Adore_india</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.10.Final</version>
</dependency>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
A <dependency> tag must be a child of <dependencies>
so add <dependencies> and </dependencies> arround it
<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>Adore_india</groupId>
<artifactId>Adore_india</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.10.Final</version>
</dependency>
</dependencies>
<build>
...

Maven Parent - child project issue

I have parent project - selenium and child project as project 1 , my intention is to have all the reusable classes in parent and test in child.When i try to run the test from child project i got the below error , could any one please help me."Failed to execute goal on project project1: Could not resolve dependencies for project com.aero:project1:pom:
1.0-SNAPSHOT: The following artifacts could not be resolved: com.automation:parentproject:jar:1.0-SNAPSHOT".I tried mvn clean and mvn install at parent project first and child project then executed mvn surefire:test but got the above exception.
Note: When i first build the parent project it doesnot generated the .jar file in the .M2 path
pom.xmL
-------
<?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.automation</groupId>
<artifactId>parentproject</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<modules>
<module>project1</module>
</modules>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
<version>2.52.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.2.1.RELEASE</version>
</dependency>
</dependencies>
</project>
Child 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">
<parent>
<artifactId>selenium</artifactId>
<groupId>com.automation</groupId>
<version>1.0-SNAPSHOT</version>
</parent> <modelVersion>4.0.0</modelVersion>
<artifactId>project1</artifactId>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.automation</groupId>
<artifactId>parentproject</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
1- you child pom referencing the wrong parent artifact.
2- direct dependency to "parentproject" should be removed, since its parent and not a dependency.
Parent:
<?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.automation</groupId>
<artifactId>parentproject</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<modules>
<module>project1</module>
</modules>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>
<dependency><--!You are not using the Java bindings (i.e. Python, C#, or Ruby) and would like to use HtmlUnit Driver-->
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
<version>2.52.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.2.1.RELEASE</version>
</dependency>
</dependencies>
Child:
<?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">
<parent>
<artifactId>parentproject</artifactId>
<groupId>com.automation</groupId>
<version>1.0-SNAPSHOT</version>
</parent> <modelVersion>4.0.0</modelVersion>
<artifactId>project1</artifactId>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
...
</dependency>
</dependencies>
hope this helps

Maven deployment with Cargo plugin - Invalid property for deployable

The deployment to the Glassfish server fails because the Cargo plugin has an invalid property.
I have a multi module Maven project with this parent 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.skb</groupId>
<artifactId>ProjectMonkeybutler</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>ProjectMonkeybutler</name>
<modules>
<module>ProjectMonkeybutler-ear</module>
<module>ProjectMonkeybutler-web</module>
<module>ProjectMonkeybutler-ejb</module>
</modules>
<dependencies>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>4.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
</repositories>
I would like to execute an auto redeployment to my Glassfish server but this is not possible from the parent pom because it is not a war/ear file which will be produced. I integrated the Cargo plugin into the ear project but the deployment is not successful.
My pom.xml for the ear project.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" x mlns: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>ProjectMonkeybutler</artifactId>
<groupId>com.skb</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.skb.monkeybutler.ear</groupId>
<artifactId>ProjectMonkeybutler-ear</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>ear</packaging>
<name>ProjectMonkeybutler-ear</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.8</version>
<configuration>
<version>6</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.7</version>
<configuration>
<container>
<containerId>glassfish4x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.hostname>localhost</cargo.hostname>
<cargo.remote.username>admin</cargo.remote.username>
<cargo.remote.password>password</cargo.remote.password>
<cargo.remote.port>50447</cargo.remote.port>
<cargo.glassfish.domain.name>/domain1</cargo.glassfish.domain.name>
</properties>
</configuration>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<type>ear</type>
<properties>
<context>/monkeybutler-dev</context>
</properties>
</deployable>
</deployables>
</configuration>
<dependencies>
<dependency>
<groupId>org.glassfish.deployment</groupId>
<artifactId>deployment-client</artifactId>
<version>3.2-b06</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.skb</groupId>
<artifactId>ProjectMonkeybutler-ejb</artifactId>
<version>1.0-SNAPSHOT</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>com.skb</groupId>
<artifactId>ProjectMonkeybutler-web</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</dependency>
</dependencies>
The error after
mvn cargo:deploy
ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.4.7:redeploy (default-cli) on project ProjectMonkeybutler-ear: Execution default-cli of goal org.codehaus.cargo:cargo-maven2-plugin:1.4.7:redeploy failed: Invalid property [context] for deployable type [ear]: org.codehaus.cargo.container.deployable.EAR.setContext([Ljava.lang.String;) -> [Help 1]
The context property is only allowed for WARs.
See the column Deployable Type in the documentation: http://cargo.codehaus.org/Maven2+Plugin+Reference+Guide#Maven2PluginReferenceGuide-prop2

maven-ear-plugin - How to manipulate Manifest.MF of webModule and ejbModule?

I have a multimodule maven project with the following structure:
app (parent)
-- pom.xml
-- app-ear
-- pom.xml
-- app-ejb
-- src
-- pom.xml
-- app-web
-- src
-- pom.xml
app/pom.xml
This is my app/pom.xml (parent project) where I put all my application dependencies:
<?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.mycompany</groupId>
<artifactId>app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>app</name>
<url>http://maven.apache.org</url>
<modules>
<module>app-ejb</module>
<module>app-web</module>
<module>app-ear</module>
</modules>
<dependencies>
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>ejb-api</artifactId>
<version>3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javaee</groupId>
<artifactId>javaee-api</artifactId>
<version>5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.0.9</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-components-ui</artifactId>
</dependency>
<dependency>
<groupId>org.richfaces.core</groupId>
<artifactId>richfaces-core-impl</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-bom</artifactId>
<version>4.2.0.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.4</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
app-ejb/pom.xml
This is my app-ejb/pom.xml:
<?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>app</artifactId>
<groupId>com.mycompany</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>app-ejb</artifactId>
<packaging>ejb</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.3</version>
<configuration>
<ejbVersion>3.0</ejbVersion>
</configuration>
</plugin>
</plugins>
</build>
</project>
This is my app-web/pom.xml:
<?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>app</artifactId>
<groupId>com.mycompany</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>app-web</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>app-ejb</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>app-web</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
</build>
</project>
app-ear/pom.xml
And finally this is my app-ear/pom.xml where I have the detais about how generate my app.ear file:
<?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>app</artifactId>
<groupId>com.mycompany</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>app-ear</artifactId>
<packaging>ear</packaging>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>app-ejb</artifactId>
<type>ejb</type>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>app-web</artifactId>
<type>war</type>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>app</finalName>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.7</version>
<configuration>
<version>5</version>
<unpackTypes>war</unpackTypes>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<skinnyWars>true</skinnyWars>
<modules>
<webModule>
<groupId>com.mycompany</groupId>
<artifactId>app-web</artifactId>
<bundleFileName>app-web.war</bundleFileName>
<contextRoot>/app</contextRoot>
</webModule>
<ejbModule>
<groupId>com.mycompany</groupId>
<artifactId>app-ejb</artifactId>
<bundleFileName>app-ejb.jar</bundleFileName>
</ejbModule>
<jarModule>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
</jarModule>
<jarModule>
<groupId>org.richfaces.core</groupId>
<artifactId>richfaces-core-api</artifactId>
</jarModule>
<jarModule>
<groupId>org.richfaces.core</groupId>
<artifactId>richfaces-core-impl</artifactId>
</jarModule>
<jarModule>
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-components-api</artifactId>
</jarModule>
<jarModule>
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-components-ui</artifactId>
</jarModule>
<jarModule>
<groupId>net.sourceforge.cssparser</groupId>
<artifactId>cssparser</artifactId>
</jarModule>
<jarModule>
<groupId>org.w3c.css</groupId>
<artifactId>sac</artifactId>
</jarModule>
<jarModule>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</jarModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
</project>
My problem is that app.ear/app-web.war!META-INF/MANIFEST.MF and app.ear/app-ejb.jar!META-INF/MANIFEST.MF looks like this:
Manifest-Version: 1.0
Build-Jdk: 1.6.0_24
Class-Path: lib/javax.faces-2.0.9.jar lib/richfaces-core-api-4.2.0.Fin
al.jar lib/richfaces-core-impl-4.2.0.Final.jar lib/richfaces-componen
ts-api-4.2.0.Final.jar lib/richfaces-components-ui-4.2.0.Final.jar li
b/cssparser-0.9.5.jar lib/sac-1.3.jar lib/guava-10.0.1.jar lib/jsr305
-1.3.9.jar
Created-By: Apache Maven
Archiver-Version: Plexus Archiver
And I really have to remove the Class-Path entry from these MANIFEST.
Why? Because it seems that RichFaces is being loaded two times in classpath of my application. (One from app.ear/lib folder and another from app.ear/app-web.war!META-INF/MANIFEST.MF Class-Path entry). And when I try to deploy app.ear in my Application Server (Oracle Weblogic 10.3.5) I get some errors like that:
INFO: Unsanitized stacktrace from failed start...
java.lang.IllegalArgumentException: duplicate key: class javax.faces.validator.RequiredValidator
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:115)
at com.google.common.collect.RegularImmutableMap.<init>(RegularImmutableMap.java:72)
at com.google.common.collect.ImmutableMap$Builder.fromEntryList(ImmutableMap.java:221)
at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:207)
at org.richfaces.javascript.ClientServiceConfigParser.parseConfig(ClientServiceConfigParser.java:53)
at org.richfaces.application.ValidatorModule.createClientScriptService(ValidatorModule.java:65)
at org.richfaces.application.ValidatorModule.configure(ValidatorModule.java:60)
at org.richfaces.application.ServicesFactoryImpl.init(ServicesFactoryImpl.java:27)
It's weird that if I run mvn package in my app-web project, the Class-path entry does not go to app-web.war/META-INF/MANIFEST.MF. It only occurs when I run mvn package in my app parent project.
So, how could I remove the Class-path entry of webModule and ejbModule MANIFEST file?
I found a similar problem in this thread but without a solution.
I appreciate any help.
Thanks,
Mauricio
You need to add the following entry in your app-ear/pom.xml inside the configuration tag
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Created-On>${build.timestamp}</Created-On>
<Ant-Version>${ant.version}</Ant-Version>
<Java-Version>${ant.java.version}</Java-Version>
</manifestEntries>
</archive>
In general the addDefaultImplementationEntries tag that is set to false prevents all default entries (like the one you want) to be written in the manifest. afterwards you can add whatever you want to include. I added some samples fo that you can see.

Resources