I have 2 maven projects, Faction and Games.Games depends of Faction, so there's the dependency in my pom.xml.
<dependency>
<groupId>net.onima</groupId>
<artifactId>onimaFaction</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
They both are a project of my workspace.
Whenever I change the code in Faction, I would like to have the changes also in API and not install every changes, do you know how to do?
EDIT:
This is working for one project, but not for the other see :
Screenshot:
I think you describe a situation when you work on one project that has two modules,
In maven its called a multi-module project.
So basically you need to create a module with a packagine 'pom' that will list two modules:
- Games
- Faction
Each module will have its own 'src/main/....' layout as well as its own pom.xml.
All in all the project will look like this:
my-project
|___ pom.xml
|___ [ games ]
| |___ pom.xml
| |___ src/{main/test} etc.
|___ [ faction ]
|___ pom.xml
|___ src/{main/test} etc.
The 'root' pom.xml should look like this (snippet that illustrates the multi module only):
<groupId>...</groupId>
<artifactId>...<groupId>
<packaging>pom</packaging>
<modules>
<module>games</module>
<module>faction</module>
</modules>
The poms for games and faction modules should be like you have now.
Then, open the 'root' pom as a project in an IDE and you should be set.
I think what you'r trying to do is make Games a Module of Faction:
<?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.yourdomain</groupId>
<artifactId>faction</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>games</module>
</modules>
</project>
where Games has its own pom.xml/project and can be in a subdirectory in the Faction directory.
<?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.yourdomain</groupId>
<artifactId>games</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<dependencies.../>
</project>
Related
I am working on spring boot application(with rest calls included) and i want to host it on heroku. Application works perfectly in my local machine.
Below is the Project Structure
.git
foldera
|
Mainclass
Pom.xml
folderb
|
other javacode
pom.xml
folderc
|
other javacode
pom.xml
Pom.xml(within root folder)
pom.xml of root folder is shown 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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
</parent>
<groupId>root</groupId>
<artifactId>pomroot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Server Spring Boot</name>
<description>Spring boot server for svmapp</description>
<properties>
<java.version>1.8</java.version>
</properties>
<modules>
<module>./foldera</module>
</modules>
</project>
I am using ./foldera to refer to subfolder using module tag. but this is not working.
All the folders are maven folders and added to the classpath. Now what i need is that from parent folder i want to refer to the Pom.xml of folder a.
How to achieve this?
I'm struggling with this issue for a while now, i have a maven project in IntelliJ with 2 maven modules.
When i'm in the java folder (sources root) of my 2nd module, when i create a class, i can reference to the classes of my other project. But when i'm inside a package in the java folder, i am no longer able to use there classes of the other project.
Thanks in advance,
Link to images:
http://imgur.com/a/6wyYM
My POM.xml from the parent project:
<?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>
<packaging>pom</packaging>
<groupId>com.ucll.da</groupId>
<artifactId>project2</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>domain</module>
<module>webApp</module>
<module>rest</module>
</modules>
</project>
The POM files from domain and rest are basically the same:
<?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>project2</artifactId>
<groupId>com.ucll.da</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<artifactId>domain</artifactId>
</project>
I found my solution but i don't really know why it works now.
My java files in the first Maven module (domain) were not inside a package, just inside the map Java. When I created a new package inside this Java map, and moved all my java files there, I could use these classes inside the other Maven module.
I have a maven project that contains two submodules, one depends on there other.
The project has no code but maven is ok with that. If I perform mvn package it passes ok and generates (empty) jar files.
However if I do mvn dependency:list I get the following error:
Failed to execute goal on project foob-two: Could not resolve dependencies for project com.example.foob:foob-two:jar:1.0.0-SNAPSHOT: Failure to find com.example.foob:foob-one:jar:1.0.0-SNAPSHOT in [Repo]
It seems like the maven dependency plugin only works after the modules have been uploaded to the local repo.
Strangely if I do the dependency list at the same time as package, ie mvn package dependency:list, it works. So it seems that maven has a different dependency resolution mechanism in some contexts.
Can anyone explain the behaviour? Can I run mvn dependency:list as a standalone command?
Here's the root pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.foob</groupId>
<artifactId>foob</artifactId>
<packaging>pom</packaging>
<version>1.0.0-SNAPSHOT</version>
<modules>
<module>foob-one</module>
<module>foob-two</module>
</modules>
</project>
Here's the first subproject:
<?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>
<groupId>com.example.foob</groupId>
<artifactId>foob</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>foob-one</artifactId>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.0</version>
</dependency>
</dependencies>
</project>
Here's the second project:
<?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>
<groupId>com.example.foob</groupId>
<artifactId>foob</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>foob-two</artifactId>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
<dependencies>
<dependency>
<groupId>com.example.foob</groupId>
<artifactId>foob-one</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
mvn dependency:list can be run on its own. It appears as if your project is failing because of missing dependencies. Try mvn install first.
how to make one module depends on another module artifact in maven multi-modules
This is how I create my multi-module maven project:
parent-module
mvn archetype:generate
archetypeGroupId : multimodule-project
archetypeArtifactId : parent-module
module-A
mvn archetype:generate
archetypeGroupId : multimodule-project
archetypeArtifactId : module-A
parent-module is the parent of module-A
After editing archetypeArtifactId from the parent pom
archetypeArtifactId : parent-module-edit
I get the error:
Some problems were encountered while building the effective model for multimodule-project:module-A:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.felix:maven-bundle-plugin is missing. # multimodule-project:module-A:[unknown-version], D:\mmvnproject\module-A\pom.xml, line 54, column 12
How should I go about properly editing a maven project archetypeArtifactId? Is there a database where these settings are stored, so that one would have to edit them there too, and not only the pom?
UPDATE
parent-module pom
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>multimodule-project</groupId>
<artifactId>parent-module</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>parent-module</name>
<modules>
<module>module-A</module>
</modules>
</project>
module-A 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>
<artifactId>module-A</artifactId>
<version>1.0</version>
<packaging>bundle</packaging>
<parent>
<groupId>multimodule-project</groupId>
<artifactId>parent-module</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
</project>
Your module-A pom is wrong you should have the underneath pom to make it works :
<?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>
<artifactId>module-A</artifactId>
<version>1.0</version>
<packaging>bundle</packaging>
<parent>
<groupId>multimodule-project</groupId>
<artifactId>parent-module</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
</project>
EDIT : Update to add some thoughts because you have corrected your original post.
There is something weird with the archetype you are using. Normally, if it was well conceived you just have to execute mvn archetype:generate once. I think because your archetype is not already a multimodule project what is explained your difficulties to set your workspace correctly with it.
If you can modify your archetype by following this tutorial for creating a good multi-module archetype, I do think it will be easier to use.
This is a basic question, I'm just not really familiar with maven multi-module structures. Say, I have a web application. And I want to connect some modules to it (some services). Do I need to make a web app just one of the modules, dependent from some others, and then run it? At first I thought I could run the whole project, but this option turns out to be inactive in my IDE (I'm using NetBeans now), which made me think I should run something like a main module (a web app in this case). Is it so? Thanks in advance.
If you have a multi-module project you need a structure like the following which will also be represented by the folder structure as well.
+-- root (pom.xml)
+--- module-1
+--- module-2
+--- module-war
Whereas the root module contains a thing like this:
<project ..>
<groupId>com.test.project</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<modules>
<module>module-1</module>
<module>module-2</module>
<module>module-war</module>
</modules>
</project>
In the module-1 your pom should look like this:
<project ..>
<parent>
<groupId>com.test.project</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>module-1</artifactId>
dependencies for the module
</project>
in module-2 it look more or less the same..and in the war module it looks like:
<project ..>
<parent>
<groupId>com.test.project</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<packaging>war</packaging>
<artifactId>module-war</artifactId>
dependencies for the module
</project>
If you have dependencies between the modules for example module-1 depends on module-2 it looks like the following in module-1:
<project ..>
<parent>
<groupId>com.test.project</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>module-1</artifactId>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>module-2</artifactId>
<version>{project.version}</version>
</dependency>
..other dependencies..
</dependencies>
</project>
To build and package your project you will go to parent folder and do simply a
mvn clean package