Skip to content
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

[MJLINK-83] Implement multiple launcher elements #202

Merged
merged 2 commits into from
Jul 18, 2024

Conversation

pedro-w
Copy link
Contributor

@pedro-w pedro-w commented Apr 5, 2024

This is a simple change to allow the Maven plugin to generate more than one launcher in a jlink image. The jlink tool itself already supports this, but there was no way to pass the required invocation onto it from Maven.

Following this checklist to help us incorporate your
contribution quickly and easily:

  • This JIRA issue has been filed for the change
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [MJLINK-XXX] - Fixes bug in ApproximateQuantiles,
    where you replace MJLINK-XXX with the appropriate JIRA issue. Best practice
    is to use the JIRA issue title in the pull request title and in the first line of the
    commit message.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean verify to make sure basic checks pass. A more thorough check will
    be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its clean verify).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

@vietj
Copy link

vietj commented Jul 14, 2024

I do support this feature that is useful

@olamy
Copy link
Member

olamy commented Jul 15, 2024

sounds good. Could you please add a simple test for this new feature?

@pedro-w
Copy link
Contributor Author

pedro-w commented Jul 15, 2024

I have added a new test class as requested @olamy

@olamy
Copy link
Member

olamy commented Jul 15, 2024

I have added a new test class as requested @olamy

Thanks. I would prefer avoid using the technique of reflection and prefer using something such https://github.com/apache/maven-compiler-plugin/blob/master/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTestCase.java

@pedro-w
Copy link
Contributor Author

pedro-w commented Jul 15, 2024

I will look into that. I based the first attempt on the existing test

@olamy
Copy link
Member

olamy commented Jul 15, 2024

I will look into that. I based the first attempt on the existing test

good point. Another technique is available here https://github.com/apache/maven-invoker-plugin/blob/1bd7bb2d009b40d747fad3808458d984c4abde21/src/test/java/org/apache/maven/plugins/invoker/InvokerMojoTest.java#L50

@pedro-w
Copy link
Contributor Author

pedro-w commented Jul 16, 2024

I've been able to do it using your second suggested method, i.e. using org.apache.maven.api.plugin.testing.MojoExtension.setVariableValueToObject

The calls now look like this:

        JLinkMojo mojo = new JLinkMojo();
        setVariableValueToObject(mojo, "launcher", "com.example.Launch");

What do you think? I just couldn't get the first method, using the @InjectMojo annotations and associated mechanisms to work at all. It seemed to be a problem with the dependencies and their versions.

@olamy
Copy link
Member

olamy commented Jul 16, 2024

I've been able to do it using your second suggested method, i.e. using org.apache.maven.api.plugin.testing.MojoExtension.setVariableValueToObject

The calls now look like this:

        JLinkMojo mojo = new JLinkMojo();
        setVariableValueToObject(mojo, "launcher", "com.example.Launch");

What do you think? I just couldn't get the first method, using the @InjectMojo annotations and associated mechanisms to work at all. It seemed to be a problem with the dependencies and their versions.

Yup sorry I realised I sent a link on plugins now build with Maven 4.
All good

@pedro-w
Copy link
Contributor Author

pedro-w commented Jul 18, 2024

OK if I understand correctly we're going back to reflection because setVariableValueToObject is (as far as I can see) only in version 4.0.0-SNAPSHOT of the plugin test harness. When Maven 4 becomes widespread we can revisit.

Also I fixed a warning from plugin:descriptor and force-pushed the branch.

Is that everything?

@olamy olamy merged commit e554ca5 into apache:master Jul 18, 2024
15 checks passed
@pedro-w pedro-w deleted the multiple-launchers branch July 19, 2024 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants