How to supress maven-javadoc-plugin run form parent pom.xml? - maven

I have a pom.xml https://repo1.maven.org/maven2/com/miglayout/miglayout-swing/5.2/miglayout-swing-5.2.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>com.miglayout</groupId>
<artifactId>miglayout-parent</artifactId>
<version>5.2</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>miglayout-swing</artifactId>
<packaging>jar</packaging>
<name>MiGLayout Swing</name>
<description>MiGLayout - Java Layout Manager for Swing</description>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>miglayout-core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
with this sources https://repo1.maven.org/maven2/com/miglayout/miglayout-swing/5.2/
And I got the following error:
INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 52.475 s
[INFO] Finished at: 2021-07-13T14:12:16+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.0.0:jar (attach-javadocs) on project miglayout-swing: MavenReportException: Error while generating Javadoc:
[ERROR] Exit code: 1 - Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
[ERROR] javadoc: error - The code being documented uses modules but the packages defined in https://docs.oracle.com/javase/8/docs/api/ are in the unnamed module.
Please tell me how to completely TURN OFF maven-javadoc-plugin? I need to build this project without javadoc.
Thank you

You can set the property maven.javadoc.skip to true, i.e. in your <properties> section add something like
<maven.javadoc.skip>true</maven.javadoc.skip>

Related

How to build the simplest multi module Maven project using Windows command line?

I have multi module project which is very simple.
Directory structure:
C:\acme-project\parent
C:\acme-project\alpha
C:\acme-project\beta
Logical structure:
parent
/ \
alpha <- beta
I cannot build the beta because it depends on the alpha. And Meven doesn't want to build the alpha during the beta's build process!
C:\acme-project\beta> mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building beta 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.company:alpha:jar:1.0-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.263 s
[INFO] Finished at: 2017-03-28T15:00:34+03:00
[INFO] Final Memory: 16M/220M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project beta: Could not resolve dependencies for project com.company:beta:jar:1.0-SNAPSHOT: The following artifacts could not be resolved: com.company:alpha:jar:1.0-SNAPSHOT: Could not find artifact com.company:alpha:jar:1.0-SNAPSHOT -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
My POMs :
C:\acme-project\parent\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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.company</groupId>
<artifactId>parent</artifactId>
<version>1</version>
<packaging>pom</packaging>
<modules>
<module>../alpha</module>
<module>../beta</module>
</modules>
</project>
C:\acme-project\alpha\alpha.com :
<?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>parent</artifactId>
<groupId>com.company</groupId>
<version>1</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>alpha</artifactId>
<version>1.0-SNAPSHOT</version>
</project>
C:\acme-project\beta\beta.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>
<groupId>com.company</groupId>
<artifactId>parent</artifactId>
<version>1</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<artifactId>beta</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.company</groupId>
<artifactId>alpha</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
I can build the acme-project running mvn package in C:...\parent. But in case of more complex project parent could have 100 sub-modules. And obviously I don't want to build 98 modules (others that beta doesn't depend on) just to make Maven happy.
If you want to build just the projects that beta depends on, go to the root aggregator (i.e., the project with all the <modules>; parent in your case) and then ask Maven to build only beta and its dependencies in the current reactor:
cd parent
mvn package --projects com.company:beta --also-make
FYI, this can be abbreviated:
mvn package -pl :beta -am
In your minimal example, the above command will still build everything (as beta depends on alpha and implicitly on the parent), but in larger reactors it will build just the minimal subset necessary to build beta.

Maven versions-maven-plugin versions plugin 2.2 -- Maven Uncle Situation

Maven is 3.1.0.
I'm using versions-maven-plugin:2.2 in my project's pom.xml (as shown below). Apart from the usual pom.xml file configuration, I'm just showing the main code snapshot 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>
<artifactId>tools-parent</artifactId>
<version>0.0.7-SNAPSHOT</version>
<packaging>pom</packaging>
<description>
Infrastructure related to the "vapp" and
"deployer" utilities.
</description>
<parent>
<groupId>com.company.product</groupId>
<artifactId>deploy-parent</artifactId>
<version>0.0.6-SNAPSHOT</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.9.4</version>
<configuration>
<connectionType>connection</connectionType>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<!-- Make sure that only non-snapshot versions are used for the dependencies. Only active when property 'snapshotDependencyAllowed' is false. -->
<id>enforce-no-snapshots</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<skip>${snapshotDependencyAllowed}</skip>
<rules>
<requireReleaseDeps>
<message>No Snapshots Allowed!</message>
</requireReleaseDeps>
<requireReleaseVersion>
<message>No Snapshots Allowed!</message>
</requireReleaseVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Now, when I run: mvn clean install, it builds successfully.
NOTE: In my project, I have a parent section, where I'm dependent upon deploy-parent artifact whose group id "com.company.product" is the same group id what I want to tools-parent artifact (whose pom.xml I have pasted above) but deploy-parent is an artifact of another repository/project.
When I run: mvn versions:set -DnewVersion=0.0.7, I get the following error message.
[INFO] ------------------------------------------------------------------------
[INFO] Building tools-parent 0.0.7-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.2:set (default-cli) # tools-parent ---
[INFO] Searching for local aggregator root...
[INFO] Local aggregation root: /user/home/u100123/giga/tools
[INFO] Processing change of com.company.product:tools-parent:0.0.7-SNAPSHOT -> 0.0.7
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] tools-parent .................................... FAILURE [1.093s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.404s
[INFO] Finished at: Fri May 01 20:44:22 GMT-00:00 2015
[INFO] Final Memory: 12M/246M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:versions-maven-plugin:2.2:set (default-cli) on project tools-parent: Execution default-cli of goal org.codehaus.mojo:versions-maven-plugin:2.2:set failed. NullPointerException -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
NOW, when I change the versions-maven-plugin version back to 2.1 (which what I was using earlier), the above mvn versions:set -DnewVersion=0.0.7 command is working successfully and pom.xml file is successfully getting changed to <version>0.0.7</version> for tools-parent artifact.
With version 2.2, it's giving me the error and not changing the version to 0.0.7.
Any reasons why 2.2 is failing? What can be done to resolve it?
It seems like some bug.
Solution:
1. I have to add <groupId>com.company.product</groupId> property outside of ... section as well i.e. for tools-parent, NOW version-maven-plugin:2.2 is working fine i.e. I added the top line (as shown below). The only thing is, what's the use of parent section then (apart from inheriting the main code of what deploy-parent is brining to tools-parent project). Why groupId needs to be defined output of parent section for artifactId tools-parent when it's already there in the parent section for versions-maven-plugin:2.2 to work successfully.
The most important thing is: This issue occurs only in case your pom.xml for a project/module has a <parent> section where the parent section's artifactId is not the parent of the project itself (a typical - Maven Uncle situation) i.e. if tools-parent artifact is defined in the parent section of another module (lets say tools-child) then version 2.2 will work successfully. But if tools-child's parent section is not containing the artifactId as "tools-parent" and is something else for ex: deploy-parent/some-different-project-artifact (which resides in a different project in your source control tool) then, for tools-child artifactId, we need groupId value also set outside of the parent section as well (even if the groupId of parent section's artifactId is same/different to tools-child's groupId).
<groupId>com.company.product</groupId>
<artifactId>tools-parent</artifactId>
<version>0.0.7-SNAPSHOT</version>
<packaging>pom</packaging>
<description>
Infrastructure related to the "vapp" and
"deployer" utilities.
</description>
<parent>
<groupId>com.company.product</groupId>
<artifactId>deploy-parent</artifactId>
<version>0.0.6-SNAPSHOT</version>
</parent>
--OR
2. Switch back to versions-maven-plugin:2.1
Just to add to part 2 of Arun's answer, the way to use version 2.1 of the plugin is:
mvn org.codehaus.mojo:versions-maven-plugin:2.1:set org.codehaus.mojo:versions-maven-plugin:2.1:commit -DnewVersion=0.0.7
You have to specify the full group-id and artifact-id.
Found this bug reported on the issue:
https://github.com/mojohaus/versions-maven-plugin/issues/51
I ran into a NPE too but it turns out the reason was a different one than suggested earlier. I debugged the versions-maven-plugin and found out that the NPE was caused by a missing <version> declaration of a dependency in the listed in the <dependencyManagement>. This can be reproduced with the following listing:
<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</groupId>
<artifactId>npe</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>NPE Example</name>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<!-- missing <version>4.2.0.RELEASE</version> -->
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
</dependencies>
</project>

Maven Packing Type Based on Profile

I am using a found example on stackoverflow that dynamically changes the packaging type based on profile
Changing packaging based on active profile in pom
This is a snippet of my 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.scene7.is.qa</groupId>
<artifactId>jorogumo</artifactId>
<packaging>${packaging.type}</packaging>
...
<profile>
<id>JorogumoReportingWebApp</id>
<properties>
<packaging.type>war</packaging.type>
<final.name>jorogumo</final.name>
</properties>
...
Based on the upvotes from the answer link above I am assuming this should work, but I receive an error when cleaning
$ mvn clean
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.scene7.is.qa:jorogumo:0.0.1-SNAPSHOT (/Users/xyz/working/_workspaces/Scene7/java/jorogumo/pom.xml) has 1 error
[ERROR] Unknown packaging: ${packaging.type} # line 10, column 13
Am I missing something? Or is this the wrong approach?
My end goal is to share common java classes between the web app and the command line jar.
I ended up creating a default packing.type property with a value:
<modelVersion>4.0.0</modelVersion>
<groupId>com.scene7.is.qa</groupId>
<artifactId>jorogumo</artifactId>
<packaging>${packaging.type}</packaging>
...
<properties>
<packaging.type>war</packaging.type>
</properties>
<profiles>
<profile>
<id>JorogumoReportingWebApp</id>
<properties>
<packaging.type>war</packaging.type>
<final.name>jorogumo</final.name>
</properties>
...

Should the EAR pom inherit a parent

This is as much a question about the use of maven <dependencymanagement> section as much as it is about how and EAR module should play out.
I have a typical use case. Following are the maven modules
parent
api
ejb
web
ear
ear has api, ejb and web listed as its dependencies and inherits from parent like the other modules.
Here is the dependency management section for parent.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.4</version>
</dependency>
</dependencyManagement>
and for ejb I have a dependency (not under dependency management section but a dependency) with an explicit override of the version.
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>2.5</version>
</dependency>
When I build the whole project from the parent (since they are aggregated in the parent pom), the EAR project creates the end EAR artificat.
So far so good, but the problem arises in the way the dependencies resolve. My instinct would be that because the ejb module lists spring core version 2.5 explicitly, that would get packaged as the dependency. But what actually happens is that the EAR module being a child of the parent pom uses the version mentioned in the dependency management section of the parent and ends up taking 3.4 as the spring core version.
After a lot of study I was convinced that this is as per the Maven documentation. But what I now think about is if I combine the strategy of having the parent pom controlling all dependency versions with the strategy of the EAR module inheriting the parent, I am essentially 'stuck' with (in some cases) what the parent defines with no chance to override it.
Although one could argue that one should ideally have the same version of the jar throughout, there are some situations you run into where you would like to override some dependency versions.
What is the correct approach to let me be able to override a version? The use of spring in this example is just for example purposes. It could be any other jar.
Dependency Management actually allow you to centralize the management of dependency versions without having to add dependencies within all children (talking about common dependencies). This brings much help when having multi-inheritance level project where children get the could get the transitive dependencies from the parent pom just like your project.
Concerning version override, don't be mistaken because you can override the inherited dependency version just by declaring it in the sub-module who needs to have its own version of some artifact.
Here is a sample showcase of that, stating a straightforward project with name root and having two sub-modules; blessed-module the one that inherite his parent artifact version and an odd-module which has chosen his own path and so his own artifact version:
root
\+ blessed-module
+ odd-module
The parent pom will state the centralized dependencies having below descriptor (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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>dependency.management.showcase</groupId>
<artifactId>root</artifactId>
<packaging>pom</packaging>
<version>1.0</version>
<modules>
<module>blessed-module</module>
<module>odd-module</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.2.8.RELEASE</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
The child modules will be as follows, starting with the good blessed-module:
<?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>
<groupId>dependency.management.showcase</groupId>
<artifactId>root</artifactId>
<version>1.0</version>
</parent>
<artifactId>child-module</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
</dependencies>
</project>
and the pom.xml file of the odd-module:
<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>root</artifactId>
<groupId>dependency.management.showcase</groupId>
<version>1.0</version>
</parent>
<artifactId>odd-module</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>2.5</version>
</dependency>
</dependencies>
</project>
Now no further actions are needed, jsut go navigate to the root home path and execute below maven command from a terminal to have all dependencies tree shown in front of you
mvn dependency:tree
You will see the sub-modules with slightly different versions of the spring-core artifact:
[INFO] ------------------------------------------------------------------------
[INFO] Building root 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # root ---
[INFO] dependency.management.showcase:root:pom:1.0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building child-module 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # child-module ---
[INFO] dependency.management.showcase:blessed-module:jar:1.0
[INFO] \- org.springframework:spring-core:jar:3.2.8.RELEASE:compile
[INFO] \- commons-logging:commons-logging:jar:1.1.3:compile
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building odd-module 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # odd-module ---
[INFO] dependency.management.showcase:odd-module:jar:1.0
[INFO] \- org.springframework:spring-core:jar:2.5:compile
[INFO] \- commons-logging:commons-logging:jar:1.1:compile
[INFO] ------------------------------------------------------------------------

How to build a multi-module maven project in jenkins

I have a projects structure as follows:
ProjectParent
- pom.xml
ProjectApp
-pom.xml
ProjectAPI
-pom.xml
ProjectModels
-pom.xml
ProjectServices
-pom.xml
Etc..
ProjectModels/ProjectsServices are dependencies within ProjectAPI/ProjectApp.
Should I create separate jobs within Jenkins to build each module separately?
I created a job for ProjectAPP but get the following error below (Have set goals and actions to "clean install":
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myproject-app 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://maven.springframework.org/snapshot/com/myproject/myproject-common-config/0.0.1-SNAPSHOT/myproject-common-config-0.0.1-SNAPSHOT.pom
[WARNING] The POM for com.myproject:myproject-common-config:jar:0.0.1-SNAPSHOT is missing,
no dependency information available
Downloading: http://maven.springframework.org/snapshot/com/myproject/myproject-entities/0.0.1-SNAPSHOT/myproject-entities-0.0.1-SNAPSHOT.pom
[WARNING] The POM for com.myproject:myproject-entities:jar:0.0.1-SNAPSHOT is missing, no
dependency information available
Downloading: http://maven.springframework.org/snapshot/com/myproject/myproject-services/0.0.1-SNAPSHOT/myproject-services-0.0.1-SNAPSHOT.pom
[WARNING] The POM for com.myproject:myproject-services:jar:0.0.1-SNAPSHOT is missing, no
dependency information available
Downloading: http://maven.springframework.org/snapshot/com/myproject/myproject-persistence/0.0.1-SNAPSHOT/myproject-persistence-0.0.1-SNAPSHOT.pom
[WARNING] The POM for com.myproject:myproject-persistence:jar:0.0.1-SNAPSHOT is missing, no
dependency information available
Downloading: http://maven.springframework.org/snapshot/com/myproject/myproject-common-config/0.0.1-SNAPSHOT/myproject-common-config-0.0.1-SNAPSHOT.jar
......
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project myproject-app: Could not resolve dependencies
for project com.myproject:myproject-app:war:0.0.1-SNAPSHOT: The
following artifacts could not be resolved:
com.myproject:myproject-common-config:jar:0.0.1-SNAPSHOT,
com.myproject:myproject-entities:jar:0.0.1-SNAPSHOT,
com.myproject:myproject-services:jar:0.0.1-SNAPSHOT,
com.myproject:myproject-persistence:jar:0.0.1-SNAPSHOT: Could not find
artifact com.myproject:myproject-common-config:jar:0.0.1-SNAPSHOT in
org.springframework.maven.snapshot
(http://maven.springframework.org/snapshot)
ProjectParent 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.myproject</groupId>
<artifactId>myproject-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>myproject-entities</module>
<module>myproject-services</module>
<module>myproject-persistence</module>
<module>myproject-app</module>
<module>myproject-merchant</module>
<module>myproject-common-config</module>
<module>myproject-api</module>
</modules>
<dependencyManagement>
<dependencies>
...
</dependencies>
</dependencyManagement>
<repositories>
...
</repositories>
<build>
...
</build>
<properties>
...
<myproject-entities-version>0.0.1-SNAPSHOT</myproject-entities-version>
<myproject-services-version>0.0.1-SNAPSHOT</myproject-services-version>
<myproject-persistence-version>0.0.1-SNAPSHOT</myproject-persistence-version>
</properties>
</project>
ProjectApp Pom
<?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>com.myproject</groupId>
<artifactId>myproject-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>myproject-app</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>myproject-app</name>
<url>http://maven.apache.org</url>
<dependencies>
...
<dependency>
<groupId>com.myproject</groupId>
<artifactId>myproject-common-config</artifactId>
<version>${myproject-common-config}</version>
</dependency>
<dependency>
<groupId>com.myproject</groupId>
<artifactId>myproject-entities</artifactId>
<version>${myproject-entities-version}</version>
</dependency>
<dependency>
<groupId>com.myproject</groupId>
<artifactId>myproject-services</artifactId>
<version>${myproject-services-version}</version>
</dependency>
<dependency>
<groupId>com.myproject</groupId>
<artifactId>myproject-persistence</artifactId>
<version>${myproject-persistence-version}</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<myproject-common-config>0.0.1-SNAPSHOT</myproject-common-config>
<myproject-entities-version>0.0.1-SNAPSHOT</myproject-entities-version>
<myproject-services-version>0.0.1-SNAPSHOT</myproject-services-version>
<myproject-persistence-version>0.0.1-SNAPSHOT</myproject-persistence-version>
</properties>
</project>
Am I using the wrong goals? Do I need to chain a number of commands? i.e. build other modules first?
I'm using Maven 3.
NOTE: I changed the target to "clean install" against the ParentProject Pom and everything builds correctly.
Thanks
The problem is that you can't create a project solely for the ProjectApp module because it depends on the other modules below the ProjectApp parent. If you don't deploy those modules to your maven repository, maven is not able to find them in the repository nor in the build reactor.
Instead you should create the job for the parent. This will build the necessary modules.
You may also work with the option also-make-dependants when you have a job for ProjectApp, but I haven't any experience with this.
Had the same problem, and SpaceTrucker answer helped me.
Hence I just run something like:
.../ProjectParent$ mvn -am -pl ProjectApp test

Resources