4

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?

kei1aeh5quahQu4U
  • 143
  • 1
  • 9
  • 23

2 Answers2

2

This answer is bit speculative, as I do not know anything about Alfresco.

Have you thought about writing a Maven plugin that downloads an extension/plugin (maybe as zip file from your repository?), unpacks it and applies it to your project?

Then you could call the maven plugin with different lists of extensions/plugins.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • hey, thanks for looking at it - just ignore the alfresco parts - they don't really matter it's basically just like a zip of jars and there is a maven plugin from alfresco for it. but it does not matter - the main problem is how to compose this stuff - I've found the maven tiles plugin: https://github.com/repaint-io/maven-tiles that would at least reduce boilerplate. – kei1aeh5quahQu4U Aug 03 '20 at 22:06
  • As for writing a dedicated plugin: Yeah, I've thought about that and it's probably my last resort but we are small team and even from a look at the sonatype maven book this is probably not as straight forward. But it's a good idea. I guess what I'm planning to do is not really in scope for maven "out of the box" - I've also throught about ditching that idea and try to implement a plugin-system to avoid the "single .war for all combinations" problem... – kei1aeh5quahQu4U Aug 03 '20 at 22:12
1

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!

kei1aeh5quahQu4U
  • 143
  • 1
  • 9
  • 23