Skip to content

chore: improved multi-module mvn projects - #1133

Merged
octonato merged 1 commit into
mainfrom
octonato/non-akka-service-flag
Dec 18, 2025
Merged

octonato merged 1 commit into
mainfrom
octonato/non-akka-service-flag

Conversation

@octonato

@octonato octonato commented Nov 12, 2025 •

Copy link
Copy Markdown
Contributor

I run into this while testing an akka project composed of different mvn sub-modules.

First, the build will try to create a docker image for the aggregator pom. This is useless because it's a pom without source folder.

Then, in my case, there were an API module with an event class shared by the other modules. This one was not an akka service, but just some shared library.

We do have a skip.docker flag (undocumented as far as I can tell) that will skip the docker generation for the api module. But that's not enough.

Such a setup, requires you to first install the api with mvn compile install and then run the other modules, with mvn compile exec:java -pl other-module.

This is awkward way of doing it.
Instead, one should do mvn compile exec:java -am -pl other-module.
When using -am, we don't need to first build and install the api module.

However, when running with -am, the exec:java config is activated for all modules.

So, for example: if you have a multi-module with api, foo and bar, when running mvn compile exec:java -am -pl foo, maven will try to run exec:java on the aggregator pom, then on api sub-module and finally on foo.

Foo will start, but the aggregator module and api will throw some exceptions.

@octonato
octonato force-pushed the octonato/non-akka-service-flag branch from 511f4d9 to f195a8e Compare November 12, 2025 13:44
<artifactId>docker-maven-plugin</artifactId>
<version>${docker-maven-plugin.version}</version>
<configuration>
<skip>${skip.docker}</skip>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is undocumented, so probably fine to remove.

<version>${docker-maven-plugin.version}</version>
<configuration>
<skip>${skip.docker}</skip>
<skip>${non-akka-service}</skip>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More explicit flag. It's not about build docker or not, it's about indicating that this is not an akka service project and therefore some things can be disabled.

POMs without a source directory are typically a pom aggregator
for those projects we can skip docker and run configuration
-->
<missing>src</missing>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When on an aggregator pom, typically the parent of a multi-module maven project, we can safely assume it's a non-akka-service.

Actually, we can assume this for any maven project without a src dir.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, what a hack! Cool that it works.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sometimes I get impressed with the stuff that I manage to do in maven.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

impressed and scared are synonyms, right

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, synonyms for sure

@octonato

Copy link
Copy Markdown
Contributor Author

For the records, this has nothing to do with a shared libraries containing akka components.
This is something that is not yet automatically supported by the build.

This only helps when having shared libraries with POJOs and alike.

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<skip.docker>false</skip.docker>
<skip.deploy>true</skip.deploy>
<non-akka-service>false</non-akka-service>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or would it make sense to have the property in the positive instead? So use akka-service, default true, and set to false as needed:

<properties>
  <akka-service>false</akka-service>
</properties>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason is that this flag is then used in the plugins <skip> tag and we can't use ! to invert it.

@aludwiko aludwiko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@octonato
octonato merged commit bd2d49a into main Dec 18, 2025
1 check passed
@octonato
octonato deleted the octonato/non-akka-service-flag branch December 18, 2025 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants