Setting One Project as a Library for Another

How can I (if possible), set one project as a library for another, in the form of a jar? I'd like to be able to have one project for developing a library I am using in another project, and it would be nice to have them split so I could use that library in multiple projects and have them all updated regularly.

1 comment

The straightforward way is to configure jar artifact in the library project: Project Structure dialog / Artifacts. Provide proper path, set "Build on make" = Yes for more convenience. Then jar will be built on explicit make (Ctrl+F9) (not on automatic makes).

In the client project specify this jar in module's dependencies.

This way, however, has some specific. E.g. if you have library project and client project opened in two IDEA windows, then switching from one window to another does not force synchronization with external changes (because you're in the same IDEA instance). Therefore, if you rebuild a library in library project and switch to client project, you have to manually invoke synchronization (Ctrl+Alt+Y) to see the changes in jar. There are probably some other hints and issues I do not remember about.

Could one project with several modules (library and clients) be better for you?

Regards,
Alexander.

0

Please sign in to leave a comment.