use of org.graalvm.buildtools.gradle.internal.JvmReachabilityMetadataService in project native-build-tools by graalvm.
the class NativeImagePlugin method configureJvmReachabilityConfigurationDirectories.
private void configureJvmReachabilityConfigurationDirectories(Project project, GraalVMExtension graalExtension, NativeImageOptions options, SourceSet sourceSet) {
JvmReachabilityMetadataRepositoryExtension repositoryExtension = reachabilityExtensionOn(graalExtension);
Provider<JvmReachabilityMetadataService> serviceProvider = project.getGradle().getSharedServices().registerIfAbsent("nativeConfigurationService", JvmReachabilityMetadataService.class, spec -> {
LogLevel logLevel = determineLogLevel();
spec.getParameters().getLogLevel().set(logLevel);
spec.getParameters().getUri().set(repositoryExtension.getUri());
spec.getParameters().getCacheDir().set(new File(project.getGradle().getGradleUserHomeDir(), "native-build-tools/repositories"));
});
options.getConfigurationFileDirectories().from(repositoryExtension.getEnabled().flatMap(enabled -> {
if (enabled) {
if (repositoryExtension.getUri().isPresent()) {
Configuration classpath = project.getConfigurations().getByName(sourceSet.getRuntimeClasspathConfigurationName());
Set<String> excludedModules = repositoryExtension.getExcludedModules().getOrElse(Collections.emptySet());
Map<String, String> forcedVersions = repositoryExtension.getModuleToConfigVersion().getOrElse(Collections.emptyMap());
return serviceProvider.map(repo -> repo.findConfigurationDirectoriesFor(query -> classpath.getIncoming().getResolutionResult().allComponents(component -> {
ModuleVersionIdentifier moduleVersion = component.getModuleVersion();
String module = moduleVersion.getGroup() + ":" + moduleVersion.getName();
if (!excludedModules.contains(module)) {
query.forArtifact(artifact -> {
artifact.gav(module + ":" + moduleVersion.getVersion());
if (forcedVersions.containsKey(module)) {
artifact.forceConfigVersion(forcedVersions.get(module));
}
});
}
query.useLatestConfigWhenVersionIsUntested();
})).stream().map(Path::toAbsolutePath).map(Path::toFile).collect(Collectors.toList()));
}
}
return project.getProviders().provider(Collections::emptySet);
}));
}
Aggregations