Home > Mobile >  Make two jars from same project
Make two jars from same project

Time:09-29

I have one monolith project in Java, and now it doesn't use maven. This project is CLIENT and SERVER project and is a GUI, so there are swing forms.

With the IDE I'm currently using (JDeveloper) I can make one jar for SERVER and one jar for CLIENT.

Now I want to migrate an actual project on maven to use NetBeans IDE I must obtain two jars from the same project, SERVER and CLIENT.

Is there a way to obtain this with some maven plugin?

If there isn't, is there a way to "duplicate" a project in a submodule project to have two jars from one source?

CodePudding user response:

You have to:

  • Declare 2 maven profiles, one for the server and one for the client, and by them you can define a different build final name.
  • Finally, invoke maven two times passing the two profile names: mvn clean package -P server-profile, mvn clean package -P client-profile.

CodePudding user response:

You can make a multi-module maven project.

Configure your monolith code base in the root of the project. Check it compiles via mvn clean install.

Now add 2 submodules, client and server. Have both modules add a dependency to the root maven module.

Then filter out the classes you want to include in client.jar and server.jar via package name filtering using a <build> filter.

  • Related