-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add multi-build support in a single module #16054
Conversation
I think it'd be better instead of setting system properties to turn them into the build properties, i.e. add the properties parameter to https://github.com/quarkusio/quarkus/blob/main/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapMojo.java and set them like https://github.com/quarkusio/quarkus/blob/main/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java#L139 WDYT? Thanks for the great contribution, btw! Just in case, fyi, @famod |
Yeah, great contribution! |
I see, it makes sense but do we agree that those properties will be set as system properties at the end? Indeed, otherwise a parameter like the Quarkus profile won't be taken into account and setting the Quarkus profile is necessary to be able to fulfill the requirements of this feature request.
Good point, I'm afraid that indeed this approach won't help much in your case since the dependencies will be the same, as you mentioned (maybe a little in native mode? if it removes dead code, not sure and not tested) however it could be interesting as the next step of this improvement, WDYT? |
Besides the Quarkus profile one, would the rest work as project properties for you? Or perhaps in that case you could model all that with Maven profiles instead? I haven't checked, would setting system properties break in case of parallel builds? |
We will test it asap with @bcournaud
Good question, not tested either but I guess it should not work, however AFAIK custom Quarkus profiles can only be set thanks to a System property, an environment variable or a static field, in other words there isn't any easy way to isolate the value unless we use a dedicated ClassLoader per build, or we make |
Right, which is why I am hesitating to set system properties by default. Quarkus profile is a known exception for now. |
1ff96c9
to
8e851d0
Compare
devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java
Outdated
Show resolved
Hide resolved
Thanks for the suggestions @aloubyansky. |
@bcournaud Thanks! Could you please squash the commits and un-draft it please? |
017a15b
to
6fd0efc
Compare
@@ -30,7 +34,7 @@ | |||
/** | |||
* Builds the Quarkus application. | |||
*/ | |||
@Mojo(name = "build", defaultPhase = LifecyclePhase.PACKAGE, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, threadSafe = true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We mark it as non thread safe as long as the problem with the quarkus profile (set as a System property) is not fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, have you actually verified the system property set in one Mojo is visible in another one? You haven't I will check that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can certainly re-check this but in the past I have filed multiple issues for various maven plugins that fell in the same trap, e.g. NPEs during iterating the properties while another Maven thread added or removed a property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was that project properties of system properties? Thanks for the info @famod
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
System properties, AFAIR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aloubyansky yes I confirm that I have tested with a project with two modules, in each module I have 2 executions, in the first module, the first execution sets the Quarkus profile to foo
and the second one sets the Quarkus profile to bar
and in the second module, it does the opposite (first bar
and second foo
). I launched mvn -T 1C clean install
and ended up with a build success but incorrect Quarkus profile set at runtime (Quarkus profile set to bar
instead of foo
and vice versa).
In other words, I confirm that system properties make the plugin non thread safe unless you use the same system properties across all your modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @essobedo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aloubyansky If you want to keep it thread safe, we can try to investigate more to see how we can isolate the Quarkus profile (by relying on the ClassLoaders for example) but it won't be easy
Test Failures⚙️ jvm-linux-jdk11📦 integration-tests/kafka# Tests: 10
+ Success: 8
- Failures: 0
- Errors: 2
! Skipped: 0 ❌
|
Failing Jobs
Test Failures⚙️ jvm-linux-jdk15📦 integration-tests/kafka# Tests: 10
+ Success: 8
- Failures: 0
- Errors: 2
! Skipped: 0 ❌
|
The CI failures don't seem to be related. |
Thank you @bcournaud and @essobedo for another great contribution! |
Is there any follow up issue tracking the |
@famod We did not create any ticket for this topic. If you create one, please let me know, I can have a look asap. |
fixes #16053
Motivations
Be able to build the same module multiple times with different profiles, generating different artifacts.
Modifications
A new parameter has been added to the
BuildMojo
that contains the system properties of the plugin.These properties are added to the global system properties if they are not already defined.
Once the build is done, these plugin properties are removed from the system properties so that they are not taken into account by another build which may have different properties.
All the plugin system properties are now used during the execution
Note that if multiple executions are defined, the
quarkus.package.output-directory
property must be defined and different for each execution in order to store the resulting artifact in a specific folder for each execution (instead of overriding the artifacts at each build).