I have two dependencies one of them is built on top of the other.
The first project is with POM
<parent>
<groupId>com.company</groupId>
<artifactId>bom</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
</parent>
<groupId>com.company.site</groupId>
<artifactId>site</artifactId>
<packaging>war</packaging>
<dependency>
<groupId>com.company.platform</groupId>
<artifactId>platform</artifactId>
</dependency>
This project is built on top of another project (dependence)
which have the following POM
<parent>
<groupId>com.company</groupId>
<artifactId>bom</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
</parent>
<artifactId>platform</artifactId>
<packaging>pom</packaging>
How can I import these two projects in Intellij so when i make changes in sources in the platform project, these projects two be available in site project.
I have access to both depositories and their sources.
Best regards.
If you must have 2 projects (instead of a single multi-module project) it's really quite simple - open two intellij windows, one for site and one for platform.
Next, you need to define group and version for platform.
<groupId>com.company.platform</groupId>
<artifactId>platform</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
Now update the pom for site with the 1.0.0-SNAPSHOT version for platform dependency.
Your workflow is like this:
make change in platform project, use Maveh Projects window to build (clean install)
switch to site project, which depends on platform-1.0.0-SNAPSHOT, use Maven Projects window to Reimport all Maven Projects
You should then see the code updates from platform in site project.
When you want to go in production you need to go from -SNAPSHOT to release (non-snapshot) dependencies.
Related
I am working on a Java project which is managed by Maven.
The project actually is composed of three sub-projects:
- Backend
- Builder
- Frontend
Every single of those projects is Maven based and the Builder works as a bridge between Frontend and backend.
In fact the Builder is the parent project for all of them.
The pom.xml of the Builder is as follows:
...
<modules>
<module>Model</module>
</modules>
...
Whereas the Model has pom.xml like this:
...
<parent>
<groupId>...</groupId>
<artifactId>Builder</artifactId>
<version>1.0.0.0</version>
</parent>
<artifactId>Model</artifactId>
<build>
*Backend build directives*
</build>
...
The problem is that from Visual studio Code i can build every single module successfully without errors but the code editor gives me "import cannot be resolved.." wherever i have dependecies towards backend.
I came to think that this is a bug of the "Java Language Support by RedHat" which cannot find dependencies ...
Has this happened to anybody?
--- Edit 28/11/2019 ---
I forgot to clearify that all of the Builder's dependencies (so towards Backend and other Util libraries) are resolved correctly as I can see those Jars inside Frontend's resolved dependencies folder.
you could try like this:
in your parent project pom.xml:
<groupId>com.blackr</groupId>
<artifactId>cloudtest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
in your child project pom.xml:
<artifactId>module</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>com.blackr</groupId>
<artifactId>cloudtest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath> //Location of the parent project's pom.xml file
</parent>
I have two projects I am working on which share some common code - I am putting this common code in to a new project called Core.
Both my projects use maven to build, and my core classes will also use maven. In Eclipse how do I configure maven to do a maven build of the core classes and then use these in the build for my two other applications?
Is there some prebuilt rule I need to specify - for example build this project, however, go build core first and use the output of that for this.
Hope that makes some sort of sense.
You can add a dependency to Core artifact in your project.
If you use M2E Eclipse plug-in, workspace artifacts are quite easy to reference in the Maven editor.
The only condition for this kind of dependency to work is that dependent artifact must be retrievable from a maven repository (eventually putting it to the local maven repository through install goal).
You could add a parent pom, with modules
<project>
<groupId>com.mypackage</groupId>
<artifactId>parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>parent</name>
<packaging>pom</packaging>
...
<modules>
<module>Core</module>
<module>MyModuleA</module>
<module>MyModuleB</module>
</modules>
...
</project>
And then just add your dependency in MyModuleA and MyModuleB like a normal dependency
<dependency>
<groupId>com.mypackage</groupId>
<artifactId>Core</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
The deploy on save option of my EAR project is not working and I don't understand why. Here is my structure:
myproject-ear, packaging: EAR
--->myproject-core, packaging: JAR (ejbs)
--->myproject-web, packaging: WAR (.xhtml pages, some javascript and CSS)
I'm using maven and I have the war references the JAR as a provided dependency.
The thing is I have a Nexus repository to handle my JAR versioning, I do not develop with my JAR project open. But if I close my JAR project and then deploy the application the fast deployment simply stops working on glassfish (it doesn't even generate a gfdeploy on my EAR target folder, it instead copies all files to the glassfish directory).
Here are my (simplified) pom files:
Father project:
<artifactId>myproject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>myproject</name>
<modules>
<module>myproject-web</module>
<module>myproject-ear</module>
</modules>
EAR project (uses maven-ear-plugin):
<parent>
<artifactId>myproject</artifactId>
<groupId>mygroupid</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>myproject-ear</artifactId>
<packaging>ear</packaging>
<name>myproject-ear</name>
<dependencies>
<dependency>
<groupId>mygroupid</groupId>
<artifactId>myproject-core</artifactId>
<version>1.0-SNAPSHOT</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>mygroupid</groupId>
<artifactId>myproject-web</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</dependency>
</dependencies>
WAR project (uses maven-war-plugin):
<parent>
<artifactId>myproject</artifactId>
<groupId>mygroupid</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>myproject-web</artifactId>
<packaging>war</packaging>
<name>myproject-web</name>
<dependencies>
<dependency>
<groupId>mygroupid</groupId>
<artifactId>myproject-core</artifactId>
<version>1.0-SNAPSHOT</version>
<type>ejb</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
It may be a bug with your version of Netbeans. Try Netbeans version 7.3 and see if it works there. The issue I mentioned says it works in 7.1.2 but I'd give 7.3 a shot first. The issue was reported resolved in 7.3 and only broke again for the 7.4/8 development builds.
You are mixing lots of different magic (NetBeans, Maven, Nexus, and auto-deploy) and it's not surprising that it doesn't work exactly the way you would like. It's not clear (from an abstract tool developer's perspective) what the right thing to do is when you are trying to include in the deployment the latest version of a project under active development (that is, a project open in Netbeans) but that project is closed. Falling back to the version in the Nexus repository probably wasn't in the mind of the Netbeans developers who implemented auto-deploy.
My suggestion is to create another workspace where you do not include the JAR as a project but rather strictly treat it as a third-party library in the Maven and NetBeans configurations. Use this workspace except for when you need to work on the JAR.
Or else just leave the JAR project open.
I have an in-development library project (module by IntelliJ definition) that i want to reference from other projects. How would i go about to reference that project in other projects ?
you can use whether Dependency or module tags in pom.xml of your project.
Depends on what you trying to do.
<dependency>
<groupId>com.mysubpro</groupId>
<artifactId>myproject</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
Or
<modules>
<module>myproject</module>
</modules>
You have to use mvn install goal. This will install your library to your local repository. Link to Maven Install Plugin. Once it is done you can have a dependency to it in your other projects.
I've got multi module maven project, where main project depend on sub-module. Every dependency of sub-module is define by version like this: ${pom.version}. I use maven release plug-in. If I try to prepare release, I've got an error about missing version of sub-module.
Example:
main pom is on version 1.0, I try to release it. Maven build every sub-module to version 1.1, then try to build parent, and then crash. Because it can't find sub-module-1.1.
I don't know how to tell maven to build, and immediate install to local-repo every sub-module witch it build. I use maven2.
My pom:
<modelVersion>4.0.0</modelVersion>
<groupId>com.voncuver</groupId>
<artifactId>voncuver</artifactId>
<packaging>pom</packaging>
<version>1.1-SNAPSHOT</version>
<name>multimodule</name>
<modules>
<module>mod1</module>
<module>mod2</module>
</modules>
(...)
<dependencyManagement>
<dependencies>
<dependency>
<artifactId>mod1</artifactId>
<groupId>com.voncuver</groupId>
<version>${pom.version}</version>
</dependency>
<dependency>
<artifactId>mod2</artifactId>
<groupId>com.voncuver</groupId>
<version>${pom.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
(...)
You should probably post a bit more of your project structure, but typically a multimodule project looks like this:
project
mod1
mod2
mod3
pom.xml
The main pom.xml would have "pom" packaging type, and have a section in it to build everything else:
<packaging>pom</packaging>
<modules>
<module>mod1</module>
<module>mod2</module>
<module>mod3</module>
</modules>
Then, the surest way to make sure things build properly is to execute:
mvn clean install
Without the "install", it's highly possible that things might not be found in the maven reactor, especially depending on what version of maven you are using (and a few other factors).