Rename 'generateAotSources' task to processAot'
See gh-31918
This commit is contained in:
parent
2f6354f633
commit
c0b3d36205
|
|
@ -70,8 +70,8 @@ When Gradle's {application-plugin}[`application` plugin] is applied to a project
|
|||
When the {nbt-gradle-plugin}[GraalVM Native Image plugin] is applied to a project, the Spring Boot plugin:
|
||||
|
||||
. Applies the `org.springframework.boot.aot` plugin that:
|
||||
.. Registers a `GenerateAotSources` task named `generateAotSources` that will generate AOT-optimized source code for the application.
|
||||
.. Configures the Java compilation and process resources tasks for the `aot` source set to depend upon `generateAotSources`.
|
||||
.. Registers a `ProcessAot` task named `processAot` that will generate AOT-optimized source code for the application.
|
||||
.. Configures the Java compilation and process resources tasks for the `aot` source set to depend upon `processAot`.
|
||||
. Adds the output of the `aot` source set to the classpath of the `nativeCompile` task.
|
||||
. Configures the GraalVM extension to disable Toolchain detection.
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import org.gradle.api.tasks.SourceSet;
|
|||
import org.gradle.api.tasks.SourceSetContainer;
|
||||
import org.gradle.api.tasks.TaskProvider;
|
||||
|
||||
import org.springframework.boot.gradle.tasks.aot.GenerateAotSources;
|
||||
import org.springframework.boot.gradle.tasks.aot.ProcessAot;
|
||||
|
||||
/**
|
||||
* Gradle plugin for Spring Boot AOT.
|
||||
|
|
@ -50,9 +50,9 @@ public class SpringBootAotPlugin implements Plugin<Project> {
|
|||
public static final String AOT_SOURCE_SET_NAME = "aot";
|
||||
|
||||
/**
|
||||
* Name of the default {@link GenerateAotSources} task.
|
||||
* Name of the default {@link ProcessAot} task.
|
||||
*/
|
||||
public static final String GENERATE_AOT_SOURCES_TASK_NAME = "generateAotSources";
|
||||
public static final String PROCESS_AOT_TASK_NAME = "processAot";
|
||||
|
||||
@Override
|
||||
public void apply(Project project) {
|
||||
|
|
@ -60,7 +60,7 @@ public class SpringBootAotPlugin implements Plugin<Project> {
|
|||
plugins.withType(JavaPlugin.class).all((javaPlugin) -> {
|
||||
plugins.withType(SpringBootPlugin.class).all((bootPlugin) -> {
|
||||
SourceSet aotSourceSet = configureAotSourceSet(project);
|
||||
registerGenerateAotSourcesTask(project, aotSourceSet);
|
||||
registerProcessAotTask(project, aotSourceSet);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -97,11 +97,11 @@ public class SpringBootAotPlugin implements Plugin<Project> {
|
|||
attributes.attribute(Usage.USAGE_ATTRIBUTE, javaRuntime);
|
||||
}
|
||||
|
||||
private void registerGenerateAotSourcesTask(Project project, SourceSet aotSourceSet) {
|
||||
private void registerProcessAotTask(Project project, SourceSet aotSourceSet) {
|
||||
TaskProvider<ResolveMainClassName> resolveMainClassName = project.getTasks()
|
||||
.named(SpringBootPlugin.RESOLVE_MAIN_CLASS_NAME_TASK_NAME, ResolveMainClassName.class);
|
||||
TaskProvider<GenerateAotSources> generateAotSources = project.getTasks()
|
||||
.register(GENERATE_AOT_SOURCES_TASK_NAME, GenerateAotSources.class, (task) -> {
|
||||
TaskProvider<ProcessAot> processAot = project.getTasks().register(PROCESS_AOT_TASK_NAME, ProcessAot.class,
|
||||
(task) -> {
|
||||
Provider<Directory> generatedClasses = project.getLayout().getBuildDirectory()
|
||||
.dir("generated/aotClasses");
|
||||
aotSourceSet.getOutput().dir(generatedClasses);
|
||||
|
|
@ -114,9 +114,9 @@ public class SpringBootAotPlugin implements Plugin<Project> {
|
|||
task.getArtifactId().set(project.provider(() -> project.getName()));
|
||||
});
|
||||
project.getTasks().named(aotSourceSet.getCompileJavaTaskName())
|
||||
.configure((compileJava) -> compileJava.dependsOn(generateAotSources));
|
||||
.configure((compileJava) -> compileJava.dependsOn(processAot));
|
||||
project.getTasks().named(aotSourceSet.getProcessResourcesTaskName())
|
||||
.configure((processResources) -> processResources.dependsOn(generateAotSources));
|
||||
.configure((processResources) -> processResources.dependsOn(processAot));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@ import org.gradle.api.tasks.OutputDirectory;
|
|||
import org.gradle.api.tasks.TaskAction;
|
||||
|
||||
/**
|
||||
* Custom {@link JavaExec} task for generating sources ahead of time.
|
||||
* Custom {@link JavaExec} task for processing code ahead-of-time.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @since 3.0.0
|
||||
*/
|
||||
@CacheableTask
|
||||
public class GenerateAotSources extends JavaExec {
|
||||
public class ProcessAot extends JavaExec {
|
||||
|
||||
private final Property<String> applicationClass;
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ public class GenerateAotSources extends JavaExec {
|
|||
|
||||
private final Property<String> artifactId;
|
||||
|
||||
public GenerateAotSources() {
|
||||
public ProcessAot() {
|
||||
this.applicationClass = getProject().getObjects().property(String.class);
|
||||
this.sourcesDir = getProject().getObjects().directoryProperty();
|
||||
this.resourcesDir = getProject().getObjects().directoryProperty();
|
||||
|
|
@ -39,30 +39,30 @@ class SpringBootAotPluginIntegrationTests {
|
|||
GradleBuild gradleBuild;
|
||||
|
||||
@TestTemplate
|
||||
void noGenerateAotSourcesTaskWithoutAotPluginApplied() {
|
||||
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=generateAotSources").getOutput())
|
||||
.contains("generateAotSources exists = false");
|
||||
void noProcessAotTaskWithoutAotPluginApplied() {
|
||||
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=processAot").getOutput())
|
||||
.contains("processAot exists = false");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void applyingAotPluginCreatesGenerateAotSourcesTask() {
|
||||
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=generateAotSources").getOutput())
|
||||
.contains("generateAotSources exists = true");
|
||||
void applyingAotPluginCreatesProcessAotTask() {
|
||||
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=processAot").getOutput())
|
||||
.contains("processAot exists = true");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void generateAotSourcesHasLibraryResourcesOnItsClasspath() throws IOException {
|
||||
void processAotHasLibraryResourcesOnItsClasspath() throws IOException {
|
||||
File settings = new File(this.gradleBuild.getProjectDir(), "settings.gradle");
|
||||
Files.write(settings.toPath(), List.of("include 'library'"));
|
||||
File library = new File(this.gradleBuild.getProjectDir(), "library");
|
||||
library.mkdirs();
|
||||
Files.write(library.toPath().resolve("build.gradle"), List.of("plugins {", " id 'java-library'", "}"));
|
||||
assertThat(this.gradleBuild.build("generateAotSourcesClasspath").getOutput()).contains("library.jar");
|
||||
assertThat(this.gradleBuild.build("processAotClasspath").getOutput()).contains("library.jar");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void generateAotSourcesHasTransitiveRuntimeDependenciesOnItsClasspath() {
|
||||
String output = this.gradleBuild.build("generateAotSourcesClasspath").getOutput();
|
||||
void processAotHasTransitiveRuntimeDependenciesOnItsClasspath() {
|
||||
String output = this.gradleBuild.build("processAotClasspath").getOutput();
|
||||
assertThat(output).contains("org.jboss.logging" + File.separatorChar + "jboss-logging");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ dependencies {
|
|||
implementation project(":library")
|
||||
}
|
||||
|
||||
task('generateAotSourcesClasspath') {
|
||||
task('processAotClasspath') {
|
||||
doFirst {
|
||||
tasks.findByName('generateAotSources').classpath.files.each { println it }
|
||||
tasks.findByName('processAot').classpath.files.each { println it }
|
||||
}
|
||||
}
|
||||
|
|
@ -12,8 +12,8 @@ dependencies {
|
|||
implementation "org.hibernate.orm:hibernate-core:6.1.1.Final"
|
||||
}
|
||||
|
||||
task('generateAotSourcesClasspath') {
|
||||
task('processAotClasspath') {
|
||||
doFirst {
|
||||
tasks.findByName('generateAotSources').classpath.files.each { println it }
|
||||
tasks.findByName('processAot').classpath.files.each { println it }
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue