use of org.graalvm.buildtools.gradle.tasks.GenerateResourcesConfigFile in project native-build-tools by graalvm.
the class NativeImagePlugin method configureAutomaticTaskCreation.
private void configureAutomaticTaskCreation(Project project, GraalVMExtension graalExtension, Map<String, Provider<Boolean>> agents, TaskContainer tasks, SourceSetContainer sourceSets) {
graalExtension.getBinaries().configureEach(options -> {
String binaryName = options.getName();
String compileTaskName = deriveTaskName(binaryName, "native", "Compile");
if ("main".equals(binaryName)) {
compileTaskName = NATIVE_COMPILE_TASK_NAME;
}
Provider<Boolean> agent = agentPropertyOverride(project, options);
agents.put(binaryName, agent);
TaskProvider<BuildNativeImageTask> imageBuilder = tasks.register(compileTaskName, BuildNativeImageTask.class, builder -> {
builder.setDescription("Compiles a native image for the " + options.getName() + " binary");
builder.setGroup(LifecycleBasePlugin.BUILD_GROUP);
builder.getOptions().convention(options);
builder.getAgentEnabled().set(agent);
builder.getUseArgFile().convention(graalExtension.getUseArgFile());
});
String runTaskName = deriveTaskName(binaryName, "native", "Run");
if ("main".equals(binaryName)) {
runTaskName = NativeRunTask.TASK_NAME;
} else if (binaryName.toLowerCase(Locale.US).endsWith("test")) {
runTaskName = "native" + capitalize(binaryName);
}
tasks.register(runTaskName, NativeRunTask.class, task -> {
task.setGroup(LifecycleBasePlugin.BUILD_GROUP);
task.setDescription("Executes the " + options.getName() + " native binary");
task.getImage().convention(imageBuilder.map(t -> t.getOutputFile().get()));
task.getRuntimeArgs().convention(options.getRuntimeArgs());
});
configureClasspathJarFor(tasks, options, imageBuilder);
SourceSet sourceSet = "test".equals(binaryName) ? sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME) : sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
TaskProvider<GenerateResourcesConfigFile> generateResourcesConfig = registerResourcesConfigTask(graalExtension.getGeneratedResourcesDirectory(), options, tasks, transitiveProjectArtifacts(project, sourceSet.getRuntimeClasspathConfigurationName()), deriveTaskName(binaryName, "generate", "ResourcesConfigFile"));
options.getConfigurationFileDirectories().from(generateResourcesConfig.map(t -> t.getOutputFile().map(f -> f.getAsFile().getParentFile())));
configureJvmReachabilityConfigurationDirectories(project, graalExtension, options, sourceSet);
});
}
Aggregations