Skip to content

maven-native-image exec agent not generating target/ META-INF/native-image directory #803

@warrenc5

Description

@warrenc5

Describe the problem
Guys - the plugin product is fantastic but the documentation is terribly difficult for me to follow/comprehend.

I've been working with maven and graal native images for a long time.
And have contributed to graalvm bug reporting previously. So please accept my constructive criticism kindly.

I love the way you use maven profiles but I think you should focus on the acutal plugin features with skip options clearly used and let the dev refactor their pom to use profiles and execution ids. Certainly mention them for larger project build optimizations as they are increadibly powerful.

There are exisiting 'defacto standards' for maven plugin documentation and your presenting seems mixed between a man page and a learn by example, but because you don't seem to have a complete cohesive example you have to keep annotating and referencing.. i.e. but it can be enabled in the pom.xml file - customize the plugin within the block.

I know nothing is perfect - I wrote https://github.com/warrenc5/jarwalker https://github.com/warrenc5/jain-slee-js https://github.com/warrenc5/graaljs-autobox and now I'm writing https://github.com/warrenc5/graalson https://github.com/warrenc5/graalson-trax and https://github.com/warrenc5/json-transformer - certainly not perfect :)

I am referring to https://github.com/warrenc5/json-transformer/blob/master/pom.xml

The exec is not picking up the graal agent from the native-maven-plugin and I'm unsure why.

I know/think the agent should generate a native-image directory in the target directory and then I can copy that to src/main/resources/META-INF for native-image compilation.

I understand how agents are loaded by java (--javaagent:) but I don't see that happening on the exec using mvn -X test. Should it happen automagically or do I need to add the jvmArgs to the exec plugin? - I can see how it could with surefire but exec plugin is isolated by the fork.

I looked at to see if there was a configure-agent mojo..

mvn help:describe -Dplugin=org.graalvm.buildtools:native-maven-plugin -Dfull

I am missing something conceptually but I don't know what and can't glean it from the documentation I briefly looked the examples - but couldn't find any thing relevant. Sorry.

There seems to be a duplication error in the documentation with the xml fragment - those two plugin configurations appear exactly the same. Then you refer to exec:exec@native but I don't see that defined anywhere

Is that my conflation? Should there be an additional configuration in the plugins?

https://graalvm.github.io/native-build-tools/latest/maven-plugin.html#agent-support-running-application

[DEBUG] Executing command line: [java, -classpath, /home/wozza/code/json-transformer/target/classes:/home/wozza/.m2/repository/mobi/mofokom/graalson-trax/1.0.3-SNAPSHOT/graalson-trax-1.0.3-SNAPSHOT.jar:/home/wozza/.m2/repository/org/slf4j/slf4j-api/2.0.7/slf4j-api-2.0.7.jar:/home/wozza/.m2/repository/mobi/mofokom/graalson/1.0.5-SNAPSHOT/graalson-1.0.5-SNAPSHOT.jar:/home/wozza/.m2/repository/org/graalvm/polyglot/polyglot/25.0.1/polyglot-25.0.1.jar:/home/wozza/.m2/repository/org/graalvm/sdk/collections/25.0.1/collections-25.0.1.jar:/home/wozza/.m2/repository/org/graalvm/sdk/nativeimage/25.0.1/nativeimage-25.0.1.jar:/home/wozza/.m2/repository/org/graalvm/sdk/word/25.0.1/word-25.0.1.jar:/home/wozza/.m2/repository/org/graalvm/js/js-language/25.0.1/js-language-25.0.1.jar:/home/wozza/.m2/repository/org/graalvm/regex/regex/25.0.1/regex-25.0.1.jar:/home/wozza/.m2/repository/org/graalvm/truffle/truffle-api/25.0.1/truffle-api-25.0.1.jar:/home/wozza/.m2/repository/org/graalvm/shadowed/icu4j/25.0.1/icu4j-25.0.1.jar:/home/wozza/.m2/repository/org/graalvm/shadowed/xz/25.0.1/xz-25.0.1.jar:/home/wozza/.m2/repository/org/graalvm/truffle/truffle-runtime/25.0.1/truffle-runtime-25.0.1.jar:/home/wozza/.m2/repository/org/graalvm/sdk/jniutils/25.0.1/jniutils-25.0.1.jar:/home/wozza/.m2/repository/org/graalvm/truffle/truffle-compiler/25.0.1/truffle-compiler-25.0.1.jar:/home/wozza/.m2/repository/jakarta/json/jakarta.json-api/2.1.3/jakarta.json-api-2.1.3.jar, JsonT, test-classes/template.js, test-classes/ALL_FINES.json, all_fines_nsw.json, UTF8]

I think it should be something including the agentlib -

-agentlib:native-image-agent

This blocked worked - but I would like to use the confuration to configure the agent - and I don't know how that works.

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>3.0.0</version>
    <executions>
        <execution>
            <id>java-agent</id>
            <goals>
                <goal>exec</goal>
            </goals>
            <phase>test</phase>
            <configuration>
                <executable>java</executable>
                <workingDirectory>${project.build.directory}</workingDirectory>
                <arguments>
                    <argument>-agentlib:native-image-agent=config-output-dir=${basedir}/target/native-image/</argument>
                    <argument>-classpath</argument>
                    <classpath/>
                    <argument>${mainClass}</argument>
                </arguments>
            </configuration>
        </execution>
    </executions>
</plugin>

I'm confused - Any clarity your can provide around this is greatly appreciated - thanks for your time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions