Skip to content

Commit 60f77f0

Browse files
committed
Add add-metadata-hints goal to Maven Plugin
Update the maven plugin with a new `add-metadata-hints` goal that can be used to bundle hints obtained from the metadata repository into the jar.
1 parent e678c5b commit 60f77f0

File tree

8 files changed

+619
-393
lines changed

8 files changed

+619
-393
lines changed

docs/src/docs/asciidoc/maven-plugin.adoc

+17
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,23 @@ This may be interesting if there's no specific metadata available for the partic
660660
include::../../../../samples/native-config-integration/pom.xml[tag=metadata-force-version]
661661
----
662662

663+
=== Adding metadata respoistory files
664+
665+
By default, repository metadata will be used only when your native image is generated.
666+
In some situations, you may want to include the metadata directly inside your jar.
667+
668+
Adding metadata to your jar can be useful when some other process is responsible for converting your jar into a native image.
669+
For example, you might be generating a shaded jar and using a https://paketo.io/[Paketo buildpack] to convert it to a native image.
670+
671+
To include metadata repository inside your jar you can use the `add-metadata-hints` goal.
672+
Typically the goal will be included an execution step where by default it will be bound to the `generate-resources` phase:
673+
674+
.Configuring the `add-metadata-hints` goal to execute with the `generate-resources` phase
675+
[source,xml,indent=0]
676+
----
677+
include::../../../../samples/native-config-integration/pom.xml[tag=add-metadata-hints-execution]
678+
----
679+
663680
[[javadocs]]
664681
== Javadocs
665682

native-maven-plugin/src/functionalTest/groovy/org/graalvm/buildtools/maven/MetadataRepositoryFunctionalTest.groovy

+19
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,23 @@ class MetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunctionalTes
175175
outputContains "Failed to download from https://httpstat.us/404: 404 Not Found"
176176
}
177177

178+
void "it can include hints in jar"() {
179+
given:
180+
withSample("native-config-integration")
181+
182+
when:
183+
mvn '-X', '-PaddMetadataHints', '-DskipTests', 'package'
184+
185+
then:
186+
buildSucceeded
187+
188+
and:
189+
file("target/classes/META-INF/native-image/org.graalvm.internal/library-with-reflection/1.5/reflect-config.json").text.trim() == '''[
190+
{
191+
"name": "org.graalvm.internal.reflect.Message",
192+
"allDeclaredFields": true,
193+
"allDeclaredMethods": true
194+
}
195+
]'''
196+
}
178197
}

0 commit comments

Comments
 (0)