I have three modules of a project, getting developed as two seperate jars and one WAR. WAR is referring to two other jar. Please see the details below-
1.processDAO-this is a java Project producing a jar(processDAO.jar)
2.ProcessModel-this is a java project producing a jar(processModel.jar). And in pom.xml it is referring (processDAO.jar)
3.ProcessWebApp-this is Main web app project as War producing (processWebApp.WAR). Now this is using (processModel.jar)
Now currently after each development when I need to build the WAR file I first build -(processDAO.jar)
then 2nd- processModel.jar
and in last I build ProcessWebApp.WAR
So each time I have to follow this sequential build process. Now, I want whenever I go to build my ProcessWebApp.WAR other dependency gets build automatically in same sequential manner(1->2->3).
Any advice on this will be very helpful.
Environment I am using Eclipse which have mavenplugin. I just right click on every project and do RunAs 'Maven install'.
1.processDAO.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>processDAO</groupId>
<artifactId>processDAO</artifactId>
<version>2.0</version>
<packaging>jar</packaging>
2.ProcessModel.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>ProcessModel</groupId>
<artifactId>ProcessModel</artifactId>
<version>2.0</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>processDAO</groupId>
<artifactId>processDAO</artifactId>
<version>2.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
3.ProcessWebApp.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>ProcessWebApp</groupId>
<artifactId>ProcessWebApp</artifactId>
<version>2.0</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>ProcessModel</groupId>
<artifactId>ProcessModel</artifactId>
<version>2.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
Listen there several issues with the way you have created your pom or what you want to achieve.
A minor comment on the existing samples is to fix the <groupid> element usually it is something of com.xxx.my.company and is not identical with the artifact id.
Now from what I understand it seems that you are still changing the code on the dependent modules, so that means you are releasing SNAPSHOT versions (otherwise you wont need to check the compatibility of your libs every time right?). See this question on using xxx-SNAPSHOT here
Also check the use of the -U flag mvn clean install -U . See mvn -help.
-U,--update-snapshots Forces a check for missing
releases and updated snapshots on
remote repositories
This is usually achieved by use of a parent project POM, the only purpose of which is to build the modules that it depends on. When creating the POM, specify the packaging type as 'POM' and then specify your WAR and JARs as module elements. There's a pretty good example and description of this on Sonatype's site here.
Related
Is there any way to break a standard Spring Boot Maven project into multi modules?
Let's say i have a package for models, one for controllers, one for dao and another one for ui. Can i split them to separate modules somehow?
I am using IntelliJ Ultimate if matters.
yes it is possible.
create a directory per each module in your project, and add for every one of the separate POM.
At the project root level at the main POM(reactor) you will reference each one of them.
Example for reactor :
<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>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<packaging>pom</packaging>
<name>...</name>
<modules>
<module>sub-module-a</module>
<module>sub-module-b</module>
<module>sub-module-c</module>
</modules>
</project>
And when you will build your project, you will do it from the reactor.
for more details you can check maven documentation:
https://books.sonatype.com/mvnex-book/reference/multimodule.html
I have a question about my maven configuration on my MAC Intellij. I get an error that ${a-web.version} "properties in parent definition are prohibited" within parent tag in child POM.xml and that properties is defined in parent POM.xml.
But this same configuration works well on my Windows Intellij.
Below is my parent 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>***</groupId>
<artifactId>a-web</artifactId>
<packaging>pom</packaging>
<version>${a-web.version}</version>
<name>a-web project</name>
<url>http://***</url>
<properties>
<a-web.version>1.0.0</a-web.version>
</properties>
<modules>
<module>a-core</module>
<module>a-web</module>
</modules>
</project>
And this is my child POM.xml that configure a parent block.
<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>a-web</artifactId>
<groupId>***</groupId>
<version>${a-web.version}</version>
<relativePath>../</relativePath>
</parent>
<artifactId>aweb-web</artifactId>
<version>${a-web.version}</version>
<packaging>war</packaging>
<name>aweb-web</name>
</project>
I've tried many methods from stackoverflow, but no one can fix it. I want to know why this Maven config have different behaviour in Mac and windows and how to fix it.
I have run into a very similar situation when the project started using parent version properties in the commit I have just pulled. The project would not build and felt "ill-imported". An attempt to show effective pom failed with no details presented by IDEA.
As #khmarbaise pointed out in the comments[1], there are some restrictions for properties usage in maven <parent> declarations - the most notable is maven 3.5+ is required. The IDEA might not be using maven new enough (the bundled one in the latest IDEA I have installed was too old) so I had to switch to local install using Settings > Build, Execution, Deployment > Build Tools > Maven > Maven Home Directory. Once pointed to newer version, it did not start to work immediately - some of the restart/rebuild/reimport routines caused the new setting to be effective and the project to successfully import and build again.
Despite the maven version requirement was enforced in pom, it have not caused IDEA to complain the maven version it uses is old. The lack of any details that IDEA fails to inspect the project with the maven it uses did not helped either. Now when everything else works, it still says "Properties in parent definition are prohibited" in pom files.
[1] https://maven.apache.org/maven-ci-friendly.html
Setting property revision in parent pom.xml and then inherit it into children, fixed the issue for me.
<groupId>com.java</groupId>
<artifactId>test</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>
<name>Test</name>
<description>Demo project for Spring Boot</description>
<modules>
<module>backend</module>
<module>frontend</module>
</modules>
<properties>
<revision>1.0.0-SNAPSHOT</revision>
</properties>
In the child's pom.xml:
<parent>
<artifactId>com.java</artifactId>
<groupId>test</groupId>
<version>${revision}</version>
</parent>
<artifactId>backend</artifactId>
I use Maven 3.6.1
Work for me in Idea 18.2:
1) Don't use embeded Maven. Install Maven from official site! It's help me (^_^)
2) You can try to add groupId in child pom, put <groupId>com.iqiyi.lego.web</groupId> before line <artifactId>legoweb-web</artifactId>.
Try this code:
<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>lego-web</artifactId>
<groupId>com.iqiyi.lego.web</groupId>
<version>${lego-web.version}</version>
<relativePath>../</relativePath>
</parent>
**<groupId>com.iqiyi.lego.web</groupId>**
<artifactId>legoweb-web</artifactId>
<version>${lego-web.version}</version>
<packaging>war</packaging>
<name>legoweb-web</name>
</project>
because your maven version is lower than 3.5.2, try to use version that >=3.5.2,when the ide intellij idea bundled maven version is lower than 3.5.2,try to download zip set to use your own maven instead of the bundled one.
by the way,although maven lower than 3.5.2 show error in intellij idea,but it works ok,you can "mvn package" success.
I think it's because when you push the compiled jar to central maven or private maven such as nexus, you can find the version in META-INF/maven/xxxxx/pom.xml of sub project is
<version>${lego-web.version}</version>
not real value <version>1.0.0</version>.so when you want to release a single jar, you cannot get the true version
It is the IntelliJ IDEA bug.
At least in the IntelliJ IDEA 2019.2 (Ultimate Edition)
Build #IU-192.5728.98, built on July 23, 2019
I am trying to create a maven multi-module project. the project is created successfully but when I am trying to use one module as a dependency of another module, it throws an exception. When I create a module using eclipse, I was selecting packaging as a jar, but when the module is created, the packaging tag was not mention in child pom.xml and I manually insert the packaging tag as a jar.
following is my parent 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>com.netsol</groupId>
<artifactId>empirecl</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
-------------------------
<modules>
<module>empirecl-web</module>
<module>empirecl-dao</module>
<module>empirecl-service</module>
<module>empirecl-api</module>
</modules>
Dao Child 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>
<groupId>com.netsol</groupId>
<artifactId>empirecl</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>empirecl-dao</artifactId>
<packaging>jar</packaging>
<name>empirecl-dao</name>
------------------------
Service Child 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>
<groupId>com.netsol</groupId>
<artifactId>empirecl</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>empirecl-service</artifactId>
<packaging>jar</packaging>
<name>empirecl-service</name>
<dependencies>
<dependency>
<groupId>com.netsol</groupId>
<artifactId>empirecl-dao</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
</dependency>
------------------------------------------
The Dao module maven clean and install successfully, but when i trying to use service module, it will generate an following exception:
[ERROR] Failed to execute goal on project empirecl-service: Could not resolve dependencies for project com.netsol:empirecl-service:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at com.netsol:empirecl-dao:jar:0.0.1-SNAPSHOT: Failed to read artifact descriptor for com.netsol:empirecl-dao:jar:0.0.1-SNAPSHOT: Could not find artifact com.netsol:empirecl:pom:0.0.1-SNAPSHOT -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project empirecl-service: Could not resolve dependencies for project com.netsol:empirecl-service:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at com.netsol:empirecl-dao:jar:0.0.1-SNAPSHOT
I am trying the find to solution from web, but still the solution is not found. In eclipse when i open the Dependency Hierarchy of service module, it shown the DAO module as a folder not jar. below is the screen shot of Dependency Hierarchy of service module.
In case anybody comes back to this, I think the problem here was failing to install the parent pom first, which all these submodules depend on, so the Maven Reactor can't collect the necessary dependencies to build the submodule.
So from the root directory (here D:\luna_workspace\empire_club\empirecl) it probably just needs a:
mvn clean install
(Aside: <relativePath>../pom.xml</relativePath> is not really necessary as it's the default value).
In my case I forgot it was packaging conflict jar vs pom. I forgot to write
<packaging>pom</packaging>
In every child pom.xml file
My solution was to insert <packaging>pom</packaging> between artifactId and version
<groupId>com.onlinechat</groupId>
<artifactId>chat-online</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>server</module>
<module>client</module>
<module>network</module>
</modules>
This what worked for me -
Go to Java build path --> Order and Export(check JRE system libraries and maven dependencies) in my case these 2 were unchecked.
My solution:
remove all projects in current workspace
import all again
maven update project (Alt + F5) -> Select All and check Force Update of Snapshots/Releases
maven build (Ctrl + B) until there is nothing to build
It worked for me after the second try.
For me, adding the following block of code under <dependency management><dependencies> solved the problem.
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<version>3.0.1-b06</version>
</dependency>
Check with your VPN connection, if you are working in home.
Delete or close all other projects, and restart netbeans IDE, and try again.
I'm trying to figure out how to use the JClouds-Chef library to configure VMs. According to their Installation Guide I can just create a pom.xml that looks like:
<?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>
<properties>
<jclouds.version>1.7.3</jclouds.version>
</properties>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-all</artifactId>
<version>${jclouds.version}</version>
</dependency>
</dependencies>
</project>
And run mvn dependency:copy-dependencies and it should pull down all the JARs that JClouds-Chef requires.
So I did this, and then added all the JARs (there were a lot) to my project's buildpath. I then tried to create ChefContext instance (like their tutorials show examples of):
ChefContext context = null;
And Eclipse can't resolve/find the ChefContext class. After scanning the JARs that Maven downloaded, sure enough, ChefContext doesn't appear anywhere!
So I ask: **what are the exact steps I need to get all the JARs that comprise JClouds-Chef and all of its dependencies?*
You must explicitly add chef to your dependencies stanza:
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>chef</artifactId>
<version>${jclouds.version}</version>
</dependency>
You can consult chef-basics in jclouds-examples for a working example.
Adding that dependency should be enough. Alternatively, if you want to use Enterprise Chef specific features, you can add the following one instead:
<dependency>
<groupId>org.apache.jclouds.provider</groupId>
<artifactId>enterprisechef</artifactId>
<version>${jclouds.version}</version>
</dependency>
That's the only thing you need to configure. jclouds will take care of installing Chef and all the required dependencies in the nodes you provision.
I've installed the following maven module to my local maven repository
EWS Maven Module but the IDE (Eclipse in this case) doesn't seem to know about the following class `GetUserAvailabilityRequest.
Interestingly, I can run a mvn compile on my project that uses the dependency above successfully.
I can even see the class file in the jar file under my Maven Dependencies in Eclipse.
Does anyone know why this might be occurring ?
Edit #tolitius:
ews-java is a dependency for my project, not the project I'm trying to import
Here is the pom file in question:
<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.conf</groupId>
<artifactId>conferenceclient</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>microsoft.exchange</groupId>
<artifactId>exchange-ws-api</artifactId>
<version>1.1.4-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Turns out that the class in question is not public. It had nothing to do with Maven or Eclipse or anything.I wasn't looking at the class since I didn't have the source attachment.