Option to skip if Graal already made exe - #374
Conversation
| String goalsStr = pe.getGoals().toString().toLowerCase(); | ||
| String confStr = pe.getConfiguration().toString().toLowerCase(); | ||
|
|
||
| if (!goalsStr.contains("compile") || pe.getPhase() == null) { | ||
| continue; | ||
| } | ||
| if (confStr.contains("<skip>true") || confStr.contains("<skipNativeBuild>true")) |
There was a problem hiding this comment.
There is no way to detect that without parsing the whole configuration? What if there be <skip>true but not related to Graal plugin, eg. to skip tests?
There was a problem hiding this comment.
It's not parsing the whole configuration, only the fragment from a specific execution, for example:
confStr=>>><?xml version="1.0" encoding="utf-8"?>
<configuration>
<buildargs combine.children="append">
<buildarg>--no-fallback</buildarg>
<buildarg>--no-fallback</buildarg>
<buildarg>--no-fallback</buildarg></buildargs>
<imagename>xxxxxxxxxx</imagename>
<mainclass>com.example.xxxxxxxxxx</mainclass>
<metadatarepository>
<enabled>true</enabled>
</metadatarepository>
<isdetectionenabled>true</isdetectionenabled>
</configuration><<<
Note it's not checking the file-pom, only xml recreated from already parsed and merged effective pom. Also it ignores executions that don't have "compile" word in them, so it shouldn't interfere with things like metadata gathering / merging.
I'm certain there will be cases when it will fail, but it should suffice for 90%+ of typical format+compile+shade+package projects. Certainly for the ones in which the user just copy-pastes and slightly modifies the parts relevant to Graal and Launch4j.
p.s. I have no idea why "--no-fallback" is repeated, it's just a basic Micronaut project, using their generator, with simplest Launch4j fragment added.
Rationale:
As it is now, if you create a simple Micronaut app and just add Launch4j with minimal/typical configuration, it will create the exe as normal with a normal build, but also during a packaging=native-image build, overwriting the one made by Graal.
I made a quick fix that adds skipIfNativeImage param that does just that, tries to detect if Graal was already executed during the current build. It could use some more testing, but it works with the projects I'm working on right now