I am currently trying to migrate a multi-app project from Ant to Maven.
At the moment the project consists of multiple packages, creating some kind of dependency tree, without circular dependencies. The leaves of this tree are "application" packages, containing a Main. Intermediate nodes are "library" packages, used by other library "packages" or "application" packages.
The nodes are allowed to "grow together" to a single node or leaf.
I figured out, that those packages should probably be grouped into maven modules and I now have a structure similar to this:
root
- lib1
- lib1A (depends on lib1)
- lib1B (depends on lib1)
- app1A (depends on lib1A)
- lib2 (depends on lib1B)
- lib2A (depends on lib2)
- lib2B (depends on lib2)
- app2 (depends on lib2A and lib2B)
- lib3 (depends on lib2A and lib2B)
- app3A (depends on lib3)
- app3B (depends on lib3)
Basically a library and an application can depend on one or more other libraries.
Now I would like to be able to build each app on it's own and create an executable jar for it.
The way I am trying to do it now is the following:
- configure the
pom.xmlof everyappto usemaven-assembly-pluginto create an executable jar. - Build each needed module for a specific app.
- Build the app-module, which results in a executable jar.
So the build for app2 would build lib1, lib1A and lib1B, lib2, lib2A and lib2B and finally app2.
However, to automate the build, I would need to create a build-script for every app, which takes care of building all needed dependecies, which maven should already do by itself.
Also, if I want to build multiple apps at once, I would need to build all libraries multiple times, or track the already built modules by myself.
As I am new to maven, I am not sure if that's the correct way to manage such a multi-app project.
So I am asking for some advice on how to correctly manage this use case.
EDIT:
To clarify what I would like to be able to do:
- build a single app with it's dependencies, without building all apps (running maven on the parent pom).
- build multiple apps (not all) with their dependencies, without building the dependencies multiple times.