1

I have two projects in Eclipse, the first project depends on maven, the second project which dependent on the first one does NOT depend on maven.

The first project downloads external libraries like jar files and natives to the .m2 maven folder. However the second project gives a ClassNotFoundException since it cant find the jar files and the native files from the first project.

Is it possible to link these downloaded jars+dlls with the second project without having to reference in the build path->libraries in the second project properties?

I would appreciate any help.

4

2 回答 2

2

In your Maven project, use Assembly plugin to create an Uber-jar that contains the project build artifact and all its dependencies (mvn assembly:assembly -DdescriptorId=jar-with-dependencies). Then, reference that from project #2, either with a relative path or by using an ant build task to copy it into your other project's lib directory (assuming you have such a directory). Also, although it's frowned upon, you could configure the assembly plugin so that your Uber jar artifact always has the same finalName.

于 2013-03-31T01:50:01.490 回答
1

Is it possible to link these downloaded jars+dlls with the second project without having to reference in the build path->libraries in the second project properties?

I don't think so.

But maybe you could create a 3rd project (which is a Maven project) that depends on the first one, and on the JAR (or whatever) file created by the 2nd one as a non-repository dependency.

Having said that, anything you do is going to be a bit of a hack. You'd be better of either turning the 2nd project into a proper Maven project, or creating a custom build script that manually pulls the 2nd project's dependencies from somewhere. (I think that Ivy could help you with that ... assuming you use Ant in the 2nd project.)

于 2013-03-31T00:46:04.393 回答