How do I execute maven plugin for parent module only? - maven

So I created this small maven plugin, that would connect to the database server and create all the tables I need for the project. Thing is, that the project consists of multiple modules and I want the plugin to be defined in the parent one. Yet it needs to be executed only once, not separately for each module. I thought that adding "<inherited>false</inherited>" to the plugin configuration would be enough, but apparently it's not.
Here's the pom of my parent 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>rpg</groupId>
<artifactId>rpg-build</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>rpg-build</name>
<modules>
<module>../rpg-web</module>
<module>../rpg-service</module>
<module>../rpg-commons</module>
<module>../rpg-maven-plugin</module>
</modules>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.2.9</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>rpg.maven.plugin</groupId>
<artifactId>rpg-maven-plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<inherited>false</inherited>
</plugin>
</plugins>
<finalName>${artifactId}</finalName>
</build>
</project>

Answered in comments:
You should add #aggregator annotation to your plugin's mojo. – Andrew
Logvinov Apr 1 '13 at 12:40

Related

quarkus dependency not in lib folder

Quarkus noob question.
Quarkus version: 2.3.1.Final
After building (with mvn package), I can see all my projects jar files in target/quarkus-app/lib/main. eg. uk.co.mycompany.my-project1-0.0.1-SNAPSHOT.jar, uk.co.mycompany.my-project2-0.0.1-SNAPSHOT.jar, etc.
I can also see a lot of other dependencies, which I'm assuming is gathered from the projects pom files.
However, when I add a new dependency, in this case jakarta.ws.rs-api, I can't see it under the lib folder.
I've tried an mvn clean package but it just results in the same jar files as before.
How does quarkus build the list of jars? Where does it get them from?
EDIT
Child project 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mycompany</groupId>
<artifactId>mycompany-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>mycompany-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.ws.rs</groupId>
<artifactId>jboss-jaxrs-api_2.1_spec</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
</project>
Building project pom excerpt
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>2.3.1.Final</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>build</goal>
<goal>generate-code</goal>
<goal>generate-code-tests</goal>
</goals>
</execution>
</executions>
</plugin>

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 dependencies not downloading for MRunit

I am new to Maven. I have created a Java Project for MRunit testing and converted it into Maven Project. I have added below dependencies into pom.xml file.
However I don't see the Maven Dependencies folder or any downloads from the internet into the project. Please guide me.
<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>MRUnitTest</groupId>
<artifactId>MRUnitTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<dependencies>
<dependency>
<groupId>org.apache.mrunit</groupId>
<artifactId>mrunit</artifactId>
<version>0.9.0-incubating</version>
<classifier>hadoop1</classifier>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.2.1</version>
</dependency>
</dependencies>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
You will not find org.apache.mrunit with classifier hadoop1. remove the classifier property and the maven command
The dependencies are at the wrong place. Move it outside the build/plugin block, i.e
<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>MRUnitTest</groupId>
<artifactId>MRUnitTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.mrunit</groupId>
<artifactId>mrunit</artifactId>
<version>0.9.0-incubating</version>
<classifier>hadoop1</classifier>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.2.1</version>
</dependency>
</dependencies>
<build>
....
</build>
</project>
The classifier us fine according to mrunit doc. But you are selecting hadoop 1 with it.

error during build EAR file in Maven

I'm facing the followinf issue :
Failed to execute goal
org.apache.maven.plugins:maven-ear-plugin:2.7:generate-application-xml
(default-generate-application-xml) on project UserAdminEAR:
Artifact[war:com.syril.administration:UserAdmin] is not a dependency
of the project. -> [Help 1]
what is the solution for this kind of error?
my pom.xml is
<modelVersion>4.0.0</modelVersion>
<groupId>UserAdminEAR</groupId>
<artifactId>UserAdminEAR</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>UserAdmin</name>
<packaging>ear</packaging>
<dependencies>
<dependency>
<groupId>com.syril.dao</groupId>
<artifactId>dataAccess</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.syril.service</groupId>
<artifactId>UserAdminService</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.7</version>
<configuration>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<modules>
<jarModule></jarModule>
<javaModule>
<groupId>com.syril.dao</groupId>
<artifactId>dataAccess</artifactId>
<includeInApplicationXml>true</includeInApplicationXml>
</javaModule>
<webModule>
<groupId>com.syril.service</groupId>
<artifactId>UserAdminSL</artifactId>
<contextRoot>/UserAdminSL</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
You will have to add the war as a dependency to the project too, not only in the plugin configuration.
<project ...>
<modelVersion>4.0.0</modelVersion>
<groupId>com.syril.administration</groupId>
<artifactId>UserAdminEAR</artifactId>
<version>YOUR_VERSION_HERE</version>
<packaging>ear</packaging>
<dependencies>
<!-- some other dependencies here -->
...
<!-- Here is the dependency to the war that is referenced in the ear plugin -->
<dependency>
<groupId>com.syril.administration</groupId>
<artifactId>UserAdmin</artifactId>
<version>YOUR_VERSION_HERE</version>
<type>war</type>
</dependency>
</dependencies>
...
</project>
Edit
The <webModule/> artifact is not in your <dependencies/> list. That is what I was suggesting.
Add the following:
<dependency>
<groupId>com.syril.service</groupId>
<artifactId>UserAdminSL</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>war</type>
</dependency>
OR
Change the <webModule/>:
<webModule>
<groupId>com.syril.service</groupId>
<artifactId>UserAdminService</artifactId>
<contextRoot>/UserAdminSL</contextRoot>
</webModule>
That is of course if UserAdminService is the same as UserAdminSL which I think.

Resources