Nurio Fernández
Nurio Fernández

Reputation: 514

How to share code from one project to another and control what will be compiled to the JAR file?

I want to create a cross-project library that allows me to have a common code on a project and replicate it on other projects where I want to use that cross-project library code.

I'm programming a software plugin, that I need to export as a "JAR File" with that cross-project library packages inside, but NOT the rest of the dependencies.

Is there any better way? How can I do it?

Upvotes: 0

Views: 375

Answers (2)

wi2ard
wi2ard

Reputation: 1555

Do you need versioning of that code? Meaning, one project uses an older stable version of the package while you develop a newer one. If you need versioning of the code in that package you should use something like Maven modules: a module representing your common package other modules representing your projects that use that code that would reference the first one.

Upvotes: 1

kutschkem
kutschkem

Reputation: 8163

Right-click -> Build Path -> Link Source

enter image description here

The better way is to just make the other project a dependency and put it on the classpath.

enter image description here

Upvotes: 2

Related Questions