tags:

views:

70

answers:

6

Is there any way I can copy one pom.xml dependencies into other pom.xml

Update: Well, I have project A and Project B.

Project B is using some dependencies ( like Junit.jar, commons-httpclient, commons-collections, struts)

In the Project A : I would like to copy all project B dependencies in some out folder

This I can specify manually all dependencies jars of Project B in Project A but I would like to do automatically some script in Project A pom.xml.

Note: I don't want to build the project B in Project A pom.xml , I am building Project B separately

Does this make any sense?

+1  A: 

While I understand the spirit of the question (and only the spirit), the relation between project A and project B is still unclear so I'm not sure of the best way to implement this. Here are the options.

First solution: leverage transitive dependencies. There are some rules about them, but basically, if you declare a dependency on Project B in Project A, you'll get some of its dependencies transitively.

Second solution: use inheritance.

Third option: use another project of type pom to group the dependencies and declare a dependency on this pom.

Pascal Thivent
A: 

-- content moved to the original question --

skylab
Hi pascal, Any suggestions regarding the question?
skylab
+1  A: 

If I understand well what you mean, keep only the dependencies in project B pom.xml. If you need something else in this pom, create another directory level B1, and push every other elements in it. Then makes B pom.xml a pom packaging with one module:B1.

Then you can make project B pom.xml the parent of project A pom.xml. A will inherit dependencies from B.

kabado
A: 

I think, I haven't put clear question.

Lets put this way,

is there any way I can copy a group of jars from Repository into some out put directory?

I am looking into Assembly plugin but , i am not getting much.

Any help?

skylab
A: 

I think the maven invoker plugin does pretty much exactly what you need:

http://maven.apache.org/plugins/maven-invoker-plugin/install-mojo.html


Or create a java class using the maven API, programmatically build a maven project and export the dependencies

start here: http://maven.apache.org/ref/2.2.1/maven-project/apidocs

read a model: http://maven.apache.org/ref/2.0.8/maven-model/apidocs/org/apache/maven/model/io/xpp3/MavenXpp3Reader.html

construct a MavenProject object using the model: http://maven.apache.org/ref/2.2.1/maven-project/apidocs/org/apache/maven/project/MavenProject.html#MavenProject(org.apache.maven.model.Model%29

resolve and export the dependencies

Sean

seanizer
A: 

Hi Sean, Do you have any example of Invoker plugin to copy a group of jar,

Can you please provide some example, that would really helpful to me.

Thanks

skylab