I have 3 projects - A, B and C.
A has dependencies on B and C, and I deploy A to Tomcat in eclipse.
I want A to deploy with the workspace versions of A and B. I don't want my workspace copy of project C to be picked up (instead I want the installed version in ~/.m2/ to be picked up).
I can achieve this by closing project C in Eclipse. However, I want to keep project C open.
Is this possible?
You can execute mvn install on your project C with a closed version in your pom.xml file, let's say 1.0. This will leave a 1.0 version of your project C deliverable in your ~/.m2.
Make sure project A pom.xml and project B pom.xml depend on version 1.0 of project C.
For example, Project A and B pom.xml:
...
<dependency>
<groupId>myproject</groupId>
<artifactId>C</artifactId>
<version>1.0</version>
</dependency>
...
Then you can just change the version in your project C pom.xml to, let's say 2.0, and then tell Eclipse to update all your maven projects.
Project C pom.xml:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>myproject</groupId>
<artifactId>C</artifactId>
<version>2.0</version>
...
The situation will be:
Eclipse A project depending on Eclipse B project and ~/.m2/.../C/1.0/C.jar.
Eclipse B project depending on ~/.m2/.../C/1.0/C.jar.
Eclipse C project open but out of the tomcat deploy.
This way you can always adjust maven dependencies back in A and B in order to depend on your development version of C, or just keep them depending on your closed version of C.jar
Related
I have maven inheritance setup for my project build. Project A is defined as parent on Project B and Project C.
Inheritance on Project B pom.xml is as below
<parent>
<artifactId>Project A</artifactId>
<groupId>path to Project A</groupId>
<version>2</version>
<relativePath/>
</parent>
<build>
</build>
<dependencies>
<dependency>
<groupId>path to Project C</groupId>
<artifactId>Project C</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
Version of Project C; used as dependency on Project B is defined in Project A which is parent to both B and C and many of other builds.
Problem is when Project C and Project B are updated :-
I build Project C first, which is a success.
I build Project A, with updated version of project C, which also is success on node <Node 01> of Jenkins. Note, I cannot update the version of Project A ( this because there are other child pom those are also using verison 2).
But on executing Project B, which gets executed on <Node 02> of JENKINS, it fails because it could not find updated version of Project C via Project A. If we point and run Project B on <Node 01> where Project A was built, Project B succeeds as well.
So the question is, is there a way to force the build for Project B to always pull the defined version of parent pom ;Project A, even if that version is already present on the Jenkins <Node 02> (from earlier or other build) and then run the project B specific build.
Thanks in advance
I have two projects A, and B.
Project A depends on Project B. Project B depends on a library C which depends on a library D.
I own both A and B but they live in separate code bases and are independent. Project B is like an internal common helper library.
- A
-- B
--- C (version 1.1)
---- D (version 1.1)
I want to upgrade D to a newer minor version, let's say 1.5.
So in B's pom.xml file, I imported D (v1.5) directly. Then excluded D from C. Example:
<dependency>
<groupId>D</groupId>
<artifactId>foobar</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>C</groupId>
<artifactId>fizzbuzz</artifactId>
<version>1.1</version>
<exclusions>
<exclusion>
<groupId>D</groupId>
<artifactId>foobar</artifactId>
</exclusion>
</exclusions>
</dependency>
Next if I run
[~/projectB] $ mvn dependency:tree
I confirm that only 1.5 is used, not 1.1. Next I build a new local snapshot of B. And specify Project A to use that one.
My problem is when I build Project A, it continues to use v1.1 and ignores the exclusion in B.
This always returns 1.1 instead of the 1.5 that I want.
[~/projectA] $ mvn dependency:tree
Project A never imports C or D directly, it only get library D from importing Project B.
I've tried:
Reloading the maven imports
Running mvn clean install numerous times.
Deleting the folders from my .m2/ directory to force reimports
I'm out of troubleshooting ideas. Does anyone else have any tips?
Say I have a multi module maven project that builds components A and B.
Now I want to make a B a separate maven project but B has a dependency on A.
A also has a dependency on C. Because A has to be run in JAVA 7 and B has to be run on JAVA 8
C is a jar, but in C's pom the packaging is bundle.
<groupId>C</groupId>
<artifactId>C</artifactId>
<version>1.0.0</version>
<packaging>bundle</bundle>
After building A, I'm building B.
I'm declaring A as a dependency in the pom with a correct version, and in the local repository, C.jar exist.
But when I try to build B,
mvn clean install
[ERRROR] Failed to execute on project B: Could not resolve dependencies for B.jar:1.0.0: Could not find artifact B:bundle:1.0.0 in <artifactory_url>
This worked perfectly when I had a parent pom and had them as modules
How can I just make the dependency in B, A, to pick up the jar file from the artifactory without using the pom?
We have project A that builds into a jar file and project B that includes a dependency on project A. Somehow when Jenkins builds project B it doesn't always pick the latest version of project A even though it's within the version range.
For example I just did the build on Project B and even though the latest version of project A is projectA-1.0.20160425-2125.54.jar it picked up the earlier version which is core-1.0.20160422-1926.49.jar.
How could this be resolved so that Project B always picks up the latest Project A build within the range?
Here are more details...
In Jenkins, Project A is built using this Maven3 line:
clean pmd:pmd deploy -P buildServer -DversionMajor=1 -DversionMinor=0 -DbuildNumber=$BUILD_NUMBER
In Jenkins, Project B is built using this Maven3 line:
clean pmd:pmd deploy generate-sources javadoc:jar source:jar -DversionMajor=7 -DversionMinor=0 -DbuildNumber=$BUILD_NUMBER
Here are excerpts from pom.xml files for both projects...
Project A:
<groupId>vod</groupId>
<artifactId>projectA</artifactId>
<version>${versionMajor}.${versionMinor}.${maven.build.timestamp}.${buildNumber}</version>
Project B:
<groupId>vod</groupId>
<artifactId>projectB</artifactId>
<version>${versionMajor}.${versionMinor}.${maven.build.timestamp}.${buildNum
<dependency>
<groupId>vod</groupId>
<artifactId>projectA</artifactId>
<version>[1.0,2.0)</version>
</dependency>
I would use -SNAPSHOT classifier when defining version, this is a standard maven mechanism. That is:
Define project A version as 1.2-SNAPSHOT, that way the world SNAPSHOT will be automatically replaced by a timestamp at build time.
Then on project B reference A with 1.2-SNAPSHOT, that way maven will automatically picked the A build with the greatest timestamp. I recommend to take a look at this short article about SNAPSHOTs: http://www.tutorialspoint.com/maven/maven_snapshots.htm
I've got two Maven projects, A, that generates a jar, and B, that generates a war, in my Eclipse Workspace. A is a dependency of B, and, as such, is in B's POM.
My problem is that A is not being deployed to a .jar in /lib/ when I run a Tomcat server with B.
It seems strange A appears in B's Maven dependencies as a folder, not as jar. Is this anomalous in some manner? If so, how can I fix it?
If this is not the problem, perhaps it's with Tomcat. Do I need to configure it somehow to accommodate this dependency schema (in which the dependency appears as a folder)?
Thanks!
--
EDIT: After manually exporting the .war file of B, I've discovered that A is being put in /lib/ as an empty .ear file.
Here is a screenshot of the dependency been displayed as a folder:
Here are the relevant parts of the POM of A:
<groupId>br.com.reglare</groupId>
<artifactId>rule-model</artifactId>
<packaging>jar</packaging>
<version>1.8</version>
And B:
<dependency>
<groupId>br.com.reglare</groupId>
<artifactId>rule-model</artifactId>
<version>1.8</version>
</dependency>
#urir: Yes, it fails to find a class defined in A: http://990fca173882239e.paste.se/
The dependency should be defined in your pom in this format:
<dependency>
<groupId>xmlbeans</groupId>
<artifactId>xmlpublic</artifactId>
<version>2.2.0</version>
</dependency>
Also to view the dependecy tree use the 'dependency:tree' directive as follows:
mvn clean compile dependency:tree
If the dependecy is still not in the WEB-INF/lib folder of the war, then run the compile with the debugging flag and look for errors:
mvn -X clean compile
Assuming you are using m2e in eclipse to manage the webapp, you need to install m2e-wtp. You should also be able to find it within eclipse in the marketplace. It takes care of making sure that when you launch a maven web project through eclipse it gets all the dependencies in the right place. Once you install the plugin, you may want to delete your project and import it again as an "existing maven project" then the plugin will get it all setup correctly. Applying it after-the-fact has been iffy for me.