use of org.graalvm.buildtools.gradle.dsl.JvmReachabilityMetadataRepositoryExtension 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);
}));
}
use of org.graalvm.buildtools.gradle.dsl.JvmReachabilityMetadataRepositoryExtension in project native-build-tools by graalvm.
the class NativeImagePlugin method configureNativeConfigurationRepo.
private void configureNativeConfigurationRepo(ExtensionAware graalvmNative) {
JvmReachabilityMetadataRepositoryExtension configurationRepository = graalvmNative.getExtensions().create("metadataRepository", JvmReachabilityMetadataRepositoryExtension.class);
configurationRepository.getEnabled().convention(false);
configurationRepository.getUri().convention(configurationRepository.getVersion().map(v -> {
try {
return new URI("https://github.com/graalvm/jvm-reachability-metadata/releases/download/" + v + "/jvm-reachability-metadata-" + v + ".zip");
} catch (URISyntaxException e) {
return null;
}
}));
configurationRepository.getExcludedModules().convention(Collections.emptySet());
configurationRepository.getModuleToConfigVersion().convention(Collections.emptyMap());
}
Aggregations