Reputation: 2335
I have a maven 'project A' that depends on another open source artifact available in the Maven repo. However, I have downloaded the code of that artifact to my local disk and made modifications to it's code which I want in my project A. Is there any way I can link these two such that when project A is built the jar for the artifact is also built from my local disk without including this artifact into a parent pom? Basically I don't need a parent pom because in the final build I will be contributing this code back to the open source project and just referring to the project via a dependency in my pom.
Upvotes: 0
Views: 602
Reputation: 2717
It is very easy to share a project within a machine. Here is the generic answer.
<dependency>
<groupId>mygrp</groupId>
<artifactId>B</artifactId>
<version>use-the-right-version</version>
</dependency>
In your case the opensource project is "project B". Just do a "mvn install " on the opensource project.
The opensource project is already declared as a dependency. It will be available for your project ( project A )
You can import both of them into eclipse, then you can edit them simultaneously.
Upvotes: 0
Reputation: 41
Execute mvn install
on the opensource project to package and install on your local repo. After that you can add the dependency to your project A.
Upvotes: 0
Reputation: 7894
Unless I have misunderstood you, it sounds to me like you want to use a multi-module maven project:
http://books.sonatype.com/mvnex-book/reference/multimodule.html
You would use a parent POM like this to build the modules:
<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>your.groudId</groupId>
<artifactId>simple-parent</artifactId>
<packaging>pom</packaging>
<version>1.0</version>
<name>Multi Module Simple Parent Project</name>
<modules>
<module>open-source-project-modified</module>
<module>project-a</module>
</modules>
</project>
This will build open-source-project-modified
first (your modified version on local disk), followed by project-a
(also on local disk and dependent on the open source modified project). The order of the modules in the POM should be in terms of dependencies.
The structure of your project on disk would be:
simple-parent/
|_____pom.xml (the POM listed above)
|_____open-source-project-modified/
|_____project-a/
If you look in the introduction section of the link I provided, there is an examples zip file you can download:
http://www.sonatype.com/books/mvnex-book/mvnex-examples.zip
In the zip file, go to mvnexbook-examples-1.0/ch-multi/simple-parent and you will find this very structure.
Upvotes: 1