Skip to content

Option to skip if Graal already made exe - #374

Open
Lilianne-Blaze wants to merge 3 commits into
orphan-oss:mainfrom
Lilianne-Blaze:patch11
Open

Option to skip if Graal already made exe#374
Lilianne-Blaze wants to merge 3 commits into
orphan-oss:mainfrom
Lilianne-Blaze:patch11

Conversation

@Lilianne-Blaze

Copy link
Copy Markdown
Contributor

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

Comment on lines +983 to +989
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"))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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?

@Lilianne-Blaze Lilianne-Blaze Jun 12, 2024

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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants