I have a single java project that contains 3 different classes that each has a main(). I have a single pom.xml file for the entire project.
I would like Maven to make a jar for each of those classes with their dependencies.
How can I do that??
I have a single java project that contains 3 different classes that each has a main(). I have a single pom.xml file for the entire project.
I would like Maven to make a jar for each of those classes with their dependencies.
How can I do that??
If you have three main classes that are each a separate application, then in all likelihood, you should have four jars: one for each main class and one for the code that's shared between them. Maven is very tightly bound to the idea of "one artifact per module", and if you try to go against that, you're heading down a dark and dangerous path. The natural way to express this structure in Maven is in five or six modules:
And 4-6: a submodule for each of the main classes along with supporting code and configuration specific to that main class/application.
On the file system, this solution would look like:
<project folder>
- pom.xml
- parent-module
- pom.xml
- common
- pom.xml
- app1
- pom.xml
- app2
- pom.xml
- app3
- pom.xml
Then you'd use something like the assembly plugin or appassembler to create distributions with appropriate configurations, libraries, and startup scripts all packaged together.