Repository navigation
chore: improved multi-module mvn projects - #1133
Conversation
511f4d9 to
f195a8e
Compare
| <artifactId>docker-maven-plugin</artifactId> | ||
| <version>${docker-maven-plugin.version}</version> | ||
| <configuration> | ||
| <skip>${skip.docker}</skip> |
There was a problem hiding this comment.
This is undocumented, so probably fine to remove.
| <version>${docker-maven-plugin.version}</version> | ||
| <configuration> | ||
| <skip>${skip.docker}</skip> | ||
| <skip>${non-akka-service}</skip> |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Wow, what a hack! Cool that it works.
There was a problem hiding this comment.
Yeah, sometimes I get impressed with the stuff that I manage to do in maven.
There was a problem hiding this comment.
impressed and scared are synonyms, right
There was a problem hiding this comment.
yes, synonyms for sure
|
For the records, this has nothing to do with a shared libraries containing akka components. 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> |
There was a problem hiding this comment.
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>There was a problem hiding this comment.
The reason is that this flag is then used in the plugins <skip> tag and we can't use ! to invert it.
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.dockerflag (undocumented as far as I can tell) that will skip the docker generation for theapimodule. But that's not enough.Such a setup, requires you to first install the
apiwithmvn compile installand then run the other modules, withmvn 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 theapimodule.However, when running with
-am, theexec:javaconfig is activated for all modules.So, for example: if you have a multi-module with
api,fooandbar, when runningmvn compile exec:java -am -pl foo, maven will try to runexec:javaon the aggregator pom, then onapisub-module and finally onfoo.Foo will start, but the aggregator module and
apiwill throw some exceptions.