Search code examples
mavenbuildalfresco

Maven Best-Practices for Customized Builds with Plugins/Extensions?


I'm looking for advice on how to build artifacts that are composed of combinations of multiple modules without repeating a lot of boilerplate for all possibilities:

We have a software that is deployed as a .war into Tomcat and as an .amp into Alfresco running on the same Tomcat instance.

Everything related to Alfresco / .amp does not matter for the scope of the question. For simplicity just assume a single .war artifact in regards to Maven.

We use the open-core model and have a free version that consists of some code that ends up in an .amp and a .war file that contains the Angular-Frontend and several backend libraries.

We have at the moment two plugins in our software - each plugin provides an additional .amp file and adds a .jar / config files to the .war and we have lot's of extensions - each extensions overwrites/extends some Angular-Frontend files and also adds XML-configuration to the .war and/or .amp

Now I'm trying to migrate to Maven from an ancient ant-based build setup that basically just copies the plugins/extensions on deploy time over the base-install.

I need to be able to create configurations like: core + plugin-a + extension-b or core + plugin-a + plugin-b + extension-c - so that I have several .amp artifacts and a single .war artifact for each configuration.

It would be nice if it's also possible to aggregate extensions like core + plugin-a + plugin-b + extension-c + extension-d

At the moment I'm using the maven assembly plugin for the .war and the maven-frontend-plugin for angular and the assembly-plugin just copies the compiled artifacts into the war.

The .war itself is a maven module.

I could go on with this strategy and create modules for every extensions and every plugin but then I will need a module for every possible combination of the extensions and plugins.

To make it worse some extensions/plugins are commercial and live in different repositories - so I can't just add everything to the open-core POM.

I've looked into profiles but I'm not sure if that would solve my problem - as I need something like a central registry for all the submodules?

Somethink like mvn clean package -Pextension-a,extension-b,plugin-a that creates the artifacts would be great.

How to tackle this problem with Maven? Are there projects with these requirements where I can look how it's solved there?


Solution

  • In the end I've found Bazel with jvm_rules_external.

    The concept of WORKSPACE files that allow dependencies using git/maven/http/etc.pp is perfect for this. Beeing able to also build the Angular frontend using Bazel and create lightweight Docker images as well as the cached incremental builds make it a perfect fit.

    However transitioning from Maven to Bazel is not straight forward but after learning the concepts I won't look back!