Visitar URL original
Add maven support for agent by dnestoro · Pull Request #343 · graalvm/native-build-tools · GitHub
Skip to content

Add maven support for agent - #343

Merged
dnestoro merged 27 commits into
graalvm:masterfrom
dnestoro:dnestoro/addMavenSupportForAgent
Feb 6, 2023
Merged

dnestoro merged 27 commits into
graalvm:masterfrom
dnestoro:dnestoro/addMavenSupportForAgent

Conversation

@dnestoro

Copy link
Copy Markdown
Contributor

No description provided.

@oracle-contributor-agreement oracle-contributor-agreement Bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Oct 24, 2022

@alvarosanchez alvarosanchez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a good start, but it needs quite some more work. Specially, you need to write tests.

Comment thread native-maven-plugin/src/main/java/org/graalvm/buildtools/utils/AgentUtils.java Outdated
Comment thread native-maven-plugin/src/main/java/org/graalvm/buildtools/utils/Utils.java Outdated
Comment thread samples/java-application-with-reflection/pom.xml
@dnestoro
dnestoro force-pushed the dnestoro/addMavenSupportForAgent branch from 7dae693 to 6f16252 Compare November 29, 2022 16:49

@alvarosanchez alvarosanchez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Besides the inline comments, documentation is missing

Comment thread common/utils/src/main/java/org/graalvm/buildtools/agent/AgentConfiguration.java Outdated
@dnestoro
dnestoro force-pushed the dnestoro/addMavenSupportForAgent branch from 9a98234 to 977c8ab Compare December 5, 2022 10:32
@dnestoro

Copy link
Copy Markdown
Contributor Author

Style issues will be fixed once main logic gets approval.

@sdeleuze sdeleuze left a comment

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.

Please provide feedback on this first set of questions, thanks!

Comment thread docs/src/docs/asciidoc/maven-plugin.adoc Outdated
Comment thread docs/src/docs/asciidoc/maven-plugin.adoc Outdated
Comment thread native-maven-plugin/src/main/java/org/graalvm/buildtools/utils/Utils.java Outdated

@sdeleuze sdeleuze left a comment

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.

I tested it with a simple Spring Boot generated on start.spring.io, the project only has the default:

<plugin>
  <groupId>org.graalvm.buildtools</groupId>
  <artifactId>native-maven-plugin</artifactId>
</plugin>

When running mvn clean package it throw the following exception:

[ERROR] Internal error: java.lang.NullPointerException: Cannot invoke "org.codehaus.plexus.util.xml.Xpp3Dom.getName()" because "root" is null -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: java.lang.NullPointerException: Cannot invoke "org.codehaus.plexus.util.xml.Xpp3Dom.getName()" because "root" is null
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:120)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.lang.NullPointerException: Cannot invoke "org.codehaus.plexus.util.xml.Xpp3Dom.getName()" because "root" is null
    at org.graalvm.buildtools.utils.Xpp3DomParser.getTagByName (Xpp3DomParser.java:52)
    at org.graalvm.buildtools.utils.AgentUtils.collectAgentProperties (AgentUtils.java:123)
    at org.graalvm.buildtools.maven.NativeExtension.lambda$afterProjectsRead$5 (NativeExtension.java:130)
    at java.util.Optional.ifPresent (Optional.java:178)
    at org.graalvm.buildtools.maven.NativeExtension.withPlugin (NativeExtension.java:201)

I then checked the CI run of the latest commit, but looks like checkstyle did not pass:
https://github.com/graalvm/native-build-tools/actions/runs/3688052159/jobs/6242397017

Please fix those issues and ensure your changes are properly tested.

@dnestoro
dnestoro force-pushed the dnestoro/addMavenSupportForAgent branch from fcc6bb9 to a0351fd Compare January 17, 2023 17:41
@sdeleuze

Copy link
Copy Markdown
Collaborator

When configuring:

<configuration>
	<agent>
		<enabled>true</enabled>
	</agent>
</configuration>

I see the following error:

GraalVM native-image is missing from your system.
 Make sure that GRAALVM_HOME environment variable is present.

Like the other parts of the plugin, I think it is important that it works without making GRAALVM_HOME mandatory, just with JAVA_HOME defined.

@dnestoro

dnestoro commented Jan 23, 2023 •

Copy link
Copy Markdown
Contributor Author

When configuring:

<configuration>
	<agent>
		<enabled>true</enabled>
	</agent>
</configuration>

I see the following error:

GraalVM native-image is missing from your system.
 Make sure that GRAALVM_HOME environment variable is present.

Like the other parts of the plugin, I think it is important that it works without making GRAALVM_HOME mandatory, just with JAVA_HOME defined.

I agree with this idea. The only thing I am thinking about is should I do that inside this PR or I should create separate PR. It looks like this is commonly used in many parts of the repo and not only related to the agent. What is your opinion?

@melix

melix commented Jan 23, 2023

Copy link
Copy Markdown
Collaborator

I should create separate PR. It looks like this is commonly used in many parts of the repo and not only related to the agent. What is your opinion?

Pro-tip: do not mix concerns in a single PR. Smaller, focused PRs are easier to review by peers and more likely to be merged quickly.

@sdeleuze

Copy link
Copy Markdown
Collaborator

If this is not a regression introduced by that PR, we could probably fix it in another PR but IMO we should do that before releasing NBT 0.9.20.

@dnestoro

Copy link
Copy Markdown
Contributor Author

I tested plugin with netty project, and discovered two new edge cases. Last commits cover those cases.

@dnestoro
dnestoro requested a review from vjovanov February 3, 2023 10:58
@dnestoro
dnestoro merged commit 3767dbc into graalvm:master Feb 6, 2023
@linghengqian

linghengqian commented Feb 10, 2023 •

Copy link
Copy Markdown
Contributor

I tested plugin with netty project, and discovered two new edge cases. Last commits cover those cases.

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

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants