native-build-tools icon indicating copy to clipboard operation
native-build-tools copied to clipboard

Add agent modes to Maven plugin

Open lazar-mitrovic opened this issue 2 years ago • 5 comments

Similar to #230 for Gradle plugin, we should implement something similar for the Maven plugin:

<configuration>
    <agent>
        <enabled>true</enabled>
        <defaultMode>standard</defaultMode>
        <disabledPhases>
            <phase>test</phase>
        </disabledPhases>
        <modes>
            <standard>
            </standard>
            <conditional>
                <userCodeFilterPath>path-to-filter.json</userCodeFilterPath>
                <extraFilterPath>path-to-another-filter.json</extraFilterPath>
            </conditional>
            <direct>
                <options>
                    <option>config-output-dir={output_dir}</option>
                    <option>experimental-configuration-with-origins</option>
                </options>
            </direct>
        </modes>
        <commonOptions>
            <callerFilterFiles>filter.json</callerFilterFiles>
            <accessFilterFiles>filter.json</accessFilterFiles>
            <builtinCallerFilter>true</builtinCallerFilter>
            <builtinHeuristicFilter>true</builtinHeuristicFilter>
            <enableExperimentalPredefinedClasses>false</enableExperimentalPredefinedClasses>
            <enableExperimentalUnsafeAllocationTracing>false</enableExperimentalUnsafeAllocationTracing>
            <trackReflectionMetadata>true</trackReflectionMetadata>
        </commonOptions>
        <metadataCopy>
            <inputPhases>
                <phase>main</phase>
                <phase>test</phase>
            </inputPhases>
            <outputDirectories>
                <dir>src/main/resources/META-INF/native-image</dir>
            </outputDirectories>
        </metadataCopy>
    </agent>
</configuration>

lazar-mitrovic avatar Jun 29 '22 14:06 lazar-mitrovic

Concrete use case that will hopefully be solved by this issue : allowing Spring native agent sample to remove this usage of maven-antrun-plugin

Unrelated : I am quite puzzled by the DevXP people get with everything in red in the IDE : image

I think this is related to our usage of a Maven extension to parse the XML.

@lazar-mitrovic Could you please detail why this is needed? I would like to explore if there is a path where at least most common parts of the XML config can discoverable and not in red like that.

sdeleuze avatar Jul 12 '22 11:07 sdeleuze

The reason why those elements are in red is because the generated META-INF/maven/plugin.xml has all the descriptions as <description></description>.

When building a Maven plugin with Maven, those are taken from the Javadoc. In the case of our Gradle-based build, I'm not sure yet what is the missing piece that makes them to be empty.

alvarosanchez avatar Jul 12 '22 14:07 alvarosanchez

Sorry, I misread your comment. What I described would cause the existing config elements to not have documentation (eg by pressing F1).

agent in particular is in red because it's not part of plugin.xml, as is being read by NativeExtension as you described.

One possible workaround would be to add agent and its nested options as @Parameters to any mojo (even if unused now). But probably it's not worth it since this task will precisely revamp agent configuration, and by doing so, we would need to add such @Parameters

alvarosanchez avatar Jul 13 '22 05:07 alvarosanchez

So after the refactoring, will users have proper autocompletion and not anymore everything in red in IDEs?

sdeleuze avatar Jul 15 '22 07:07 sdeleuze

Yes, as part of this task, agent and all its structure should be defined as @Parameter in AbstractNativeMojo, which will make them be present in plugin.xml and therefore autocomplete

alvarosanchez avatar Jul 15 '22 07:07 alvarosanchez