Skip to content

Commit d17200a

Browse files
committed
Rename metadataRepository and document feature
This commit renames `jvmReachabilityMetadataRepository` to `metadataRepository` in the DSL. It also adds minimal documentation for this feature.
1 parent d7a8b27 commit d17200a

File tree

7 files changed

+173
-4
lines changed

7 files changed

+173
-4
lines changed

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

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,85 @@ include::../snippets/gradle/groovy/build.gradle[tags=add-agent-options-individua
335335
include::../snippets/gradle/kotlin/build.gradle.kts[tags=add-agent-options-individual]
336336
----
337337

338+
[[metadata-support]]
339+
== JVM Reachability Metadata support
340+
341+
Since release 0.9.11, the plugin adds experimental support for the https://github.com/graalvm/jvm-reachability-metadata/[JVM reachability metadata repository].
342+
This repository provides GraalVM configuration for libraries which do not officially support GraalVM native.
343+
344+
=== Enabling the metadata repository
345+
346+
Support needs to be enabled explicitly:
347+
348+
.Enabling the metadata repository
349+
[source, groovy, role="multi-language-sample"]
350+
----
351+
include::../snippets/gradle/groovy/build.gradle[tags=enable-metadata-repository]
352+
----
353+
354+
[source, kotlin, role="multi-language-sample"]
355+
----
356+
include::../snippets/gradle/kotlin/build.gradle.kts[tags=enable-metadata-repository]
357+
----
358+
359+
A metadata repository consists of configuration files for GraalVM.
360+
The plugin will automatically download the configuration metadata from the official repository if you supply the version of the repository you want to use:
361+
362+
.Enabling the metadata repository
363+
[source, groovy, role="multi-language-sample"]
364+
----
365+
include::../snippets/gradle/groovy/build.gradle[tags=specify-metadata-repository-version]
366+
----
367+
368+
[source, kotlin, role="multi-language-sample"]
369+
----
370+
include::../snippets/gradle/kotlin/build.gradle.kts[tags=specify-metadata-repository-version]
371+
----
372+
373+
Alternatively, it is possible to use a _local repository_, in which case you can specify the path to the repository:
374+
375+
.Using a local repository
376+
[source, groovy, role="multi-language-sample"]
377+
----
378+
include::../snippets/gradle/groovy/build.gradle[tags=specify-metadata-repository-file]
379+
----
380+
381+
[source, kotlin, role="multi-language-sample"]
382+
----
383+
include::../snippets/gradle/kotlin/build.gradle.kts[tags=specify-metadata-repository-file]
384+
----
385+
386+
=== Configuring the metadata repository
387+
388+
Once activated, for each library included in the native image, the plugin will automatically search for GraalVM JVM reachability metadata in the repository.
389+
In some cases, you may need to exclude a particular module from the search.
390+
This can be done by adding it to the exclude list:
391+
392+
.Excluding a module from search
393+
[source, groovy, role="multi-language-sample"]
394+
----
395+
include::../snippets/gradle/groovy/build.gradle[tags=exclude-module-from-metadata-repo]
396+
----
397+
398+
[source, kotlin, role="multi-language-sample"]
399+
----
400+
include::../snippets/gradle/kotlin/build.gradle.kts[tags=exclude-module-from-metadata-repo]
401+
----
402+
403+
Last, it is possible for you to override the _metadata version_ of a particular module.
404+
This may be interesting if there's no specific metadata available for the particular version of the library that you use, but that you know that a version works:
405+
406+
.Specifying the metadata version to use for a particular library
407+
[source, groovy, role="multi-language-sample"]
408+
----
409+
include::../snippets/gradle/groovy/build.gradle[tags=specify-metadata-version-for-library]
410+
----
411+
412+
[source, kotlin, role="multi-language-sample"]
413+
----
414+
include::../snippets/gradle/kotlin/build.gradle.kts[tags=specify-metadata-version-for-library]
415+
----
416+
338417
[[plugin-configurations]]
339418
== Configurations defined by the plugin
340419

docs/src/docs/asciidoc/index.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ If you are interested in contributing, please refer to our https://github.com/gr
2020

2121
* Fix long classpath issue under Windows when running native tests
2222
* Inherit environment variables and system properties from the surefire plugin configuration when executing tests
23+
* Fix invocation of `native-image` when classpath contains spaces
2324

2425
==== Gradle plugin
2526

2627
* Add support for environment variables in native test execution
28+
* Fix invocation of `native-image` when classpath contains spaces
29+
* Add experimental support for the JVM reachability metadata repository
2730

2831
=== Release 0.9.10
2932

docs/src/docs/snippets/gradle/groovy/build.gradle

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,46 @@ graalvmNative {
149149
}
150150
}
151151
// end::add-agent-options-individual[]
152+
153+
// tag::enable-metadata-repository[]
154+
graalvmNative {
155+
metadataRepository {
156+
enabled = true
157+
}
158+
}
159+
// end::enable-metadata-repository[]
160+
161+
// tag::specify-metadata-repository-version[]
162+
graalvmNative {
163+
metadataRepository {
164+
version = "1.0.0"
165+
}
166+
}
167+
// end::specify-metadata-repository-version[]
168+
169+
// tag::specify-metadata-repository-file[]
170+
graalvmNative {
171+
metadataRepository {
172+
uri(file("metadata-repository"))
173+
}
174+
}
175+
// end::specify-metadata-repository-file[]
176+
177+
// tag::exclude-module-from-metadata-repo[]
178+
graalvmNative {
179+
metadataRepository {
180+
// Exclude this library from automatic metadata
181+
// repository search
182+
excludes.add("com.company:some-library")
183+
}
184+
}
185+
// end::exclude-module-from-metadata-repo[]
186+
187+
// tag::specify-metadata-version-for-library[]
188+
graalvmNative {
189+
metadataRepository {
190+
// Force the version of the metadata for a particular library
191+
moduleToConfigVersion.put("com.company:some-library", "3")
192+
}
193+
}
194+
// end::specify-metadata-version-for-library[]

docs/src/docs/snippets/gradle/kotlin/build.gradle.kts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,47 @@ graalvmNative {
162162
}
163163
}
164164
// end::add-agent-options-individual[]
165+
166+
// tag::enable-metadata-repository[]
167+
graalvmNative {
168+
metadataRepository {
169+
enabled.set(true)
170+
}
171+
}
172+
// end::enable-metadata-repository[]
173+
174+
// tag::specify-metadata-repository-version[]
175+
graalvmNative {
176+
metadataRepository {
177+
version.set("1.0.0")
178+
}
179+
}
180+
// end::specify-metadata-repository-version[]
181+
182+
183+
// tag::specify-metadata-repository-file[]
184+
graalvmNative {
185+
metadataRepository {
186+
uri(file("metadata-repository"))
187+
}
188+
}
189+
// end::specify-metadata-repository-file[]
190+
191+
// tag::exclude-module-from-metadata-repo[]
192+
graalvmNative {
193+
metadataRepository {
194+
// Exclude this library from automatic metadata
195+
// repository search
196+
excludes.add("com.company:some-library")
197+
}
198+
}
199+
// end::exclude-module-from-metadata-repo[]
200+
201+
// tag::specify-metadata-version-for-library[]
202+
graalvmNative {
203+
metadataRepository {
204+
// Force the version of the metadata for a particular library
205+
moduleToConfigVersion.put("com.company:some-library", "3")
206+
}
207+
}
208+
// end::specify-metadata-version-for-library[]

native-gradle-plugin/src/functionalTest/groovy/org/graalvm/buildtools/gradle/NativeConfigRepoFunctionalTest.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class NativeConfigRepoFunctionalTest extends AbstractFunctionalTest {
9494

9595
buildFile << """
9696
graalvmNative {
97-
jvmReachabilityMetadataRepository {
97+
metadataRepository {
9898
excludedModules.add("org.graalvm.internal:library-with-reflection")
9999
}
100100
}
@@ -121,7 +121,7 @@ graalvmNative {
121121

122122
buildFile << """
123123
graalvmNative {
124-
jvmReachabilityMetadataRepository {
124+
metadataRepository {
125125
moduleToConfigVersion.put("org.graalvm.internal:library-with-reflection", "2")
126126
}
127127
}

native-gradle-plugin/src/main/java/org/graalvm/buildtools/gradle/NativeImagePlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ private GraalVMExtension registerGraalVMExtension(Project project) {
406406
}
407407

408408
private void configureNativeConfigurationRepo(ExtensionAware graalvmNative) {
409-
JvmReachabilityMetadataRepositoryExtension configurationRepository = graalvmNative.getExtensions().create("jvmReachabilityMetadataRepository", JvmReachabilityMetadataRepositoryExtension.class);
409+
JvmReachabilityMetadataRepositoryExtension configurationRepository = graalvmNative.getExtensions().create("metadataRepository", JvmReachabilityMetadataRepositoryExtension.class);
410410
configurationRepository.getEnabled().convention(false);
411411
configurationRepository.getUri().convention(configurationRepository.getVersion().map(v -> {
412412
try {

samples/native-config-integration/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ tasks.withType(Test).configureEach {
6868
}
6969

7070
graalvmNative {
71-
jvmReachabilityMetadataRepository {
71+
metadataRepository {
7272
enabled = true
7373
def extension = System.getProperty("extension", '')
7474
def repo = file("config-directory${extension ? '.' + extension : ''}")

0 commit comments

Comments
 (0)