From 65777a7c5eac6885954d6219daac0f4128854ab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Mon, 17 Oct 2022 21:52:15 +0200 Subject: [PATCH] Fix --exclude-config regression with Gradle Closes gh-340 --- .../graalvm/buildtools/gradle/NativeImagePlugin.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/native-gradle-plugin/src/main/java/org/graalvm/buildtools/gradle/NativeImagePlugin.java b/native-gradle-plugin/src/main/java/org/graalvm/buildtools/gradle/NativeImagePlugin.java index b845c9100..ce273edac 100644 --- a/native-gradle-plugin/src/main/java/org/graalvm/buildtools/gradle/NativeImagePlugin.java +++ b/native-gradle-plugin/src/main/java/org/graalvm/buildtools/gradle/NativeImagePlugin.java @@ -121,6 +121,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.nio.file.Path; +import java.util.AbstractMap; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -424,8 +425,11 @@ private static URI computeMetadataRepositoryUri(Project project, } private void configureJvmReachabilityExcludeConfigArgs(Project project, GraalVMExtension graalExtension, NativeImageOptions options, SourceSet sourceSet) { + options.getExcludeConfig().putAll(graalVMReachabilityQuery(project, graalExtension, sourceSet, + DirectoryConfiguration::isOverride, this::getExclusionConfig, + Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))); GraalVMReachabilityMetadataRepositoryExtension repositoryExtension = reachabilityExtensionOn(graalExtension); - Provider serviceProvider = project.getGradle() + project.getGradle() .getSharedServices() .registerIfAbsent("nativeConfigurationService", GraalVMReachabilityMetadataService.class, spec -> { LogLevel logLevel = determineLogLevel(); @@ -436,6 +440,12 @@ private void configureJvmReachabilityExcludeConfigArgs(Project project, GraalVME }); } + private Map.Entry> getExclusionConfig(ModuleVersionIdentifier moduleVersion, + DirectoryConfiguration configuration) { + String gav = moduleVersion.getGroup() + ":" + moduleVersion.getName() + ":" + moduleVersion.getVersion(); + return new AbstractMap.SimpleEntry<>(gav, Arrays.asList("^/META-INF/native-image/.*")); + } + private static LogLevel determineLogLevel() { LogLevel logLevel = LogLevel.DEBUG; String loggingProperty = System.getProperty(CONFIG_REPO_LOGLEVEL);