mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Use constants in SpringBootAotPlugin
This commit is contained in:
parent
9e85e3e3af
commit
e4484c3db5
@ -78,9 +78,9 @@ public class SpringBootAotPlugin implements Plugin<Project> {
|
||||
JavaPluginExtension javaPluginExtension = project.getExtensions().getByType(JavaPluginExtension.class);
|
||||
SourceSetContainer sourceSets = javaPluginExtension.getSourceSets();
|
||||
SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
|
||||
SourceSet aotSourceSet = configureSourceSet(project, "aot", mainSourceSet);
|
||||
SourceSet aotSourceSet = configureSourceSet(project, AOT_SOURCE_SET_NAME, mainSourceSet);
|
||||
SourceSet testSourceSet = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME);
|
||||
SourceSet aotTestSourceSet = configureSourceSet(project, "aotTest", testSourceSet);
|
||||
SourceSet aotTestSourceSet = configureSourceSet(project, AOT_TEST_SOURCE_SET_NAME, testSourceSet);
|
||||
plugins.withType(SpringBootPlugin.class).all((bootPlugin) -> {
|
||||
registerProcessAotTask(project, aotSourceSet, mainSourceSet);
|
||||
registerProcessTestAotTask(project, mainSourceSet, aotTestSourceSet, testSourceSet);
|
||||
@ -126,7 +126,7 @@ public class SpringBootAotPlugin implements Plugin<Project> {
|
||||
.dir("generated/" + aotSourceSet.getName() + "Resources");
|
||||
TaskProvider<ProcessAot> processAot = project.getTasks()
|
||||
.register(PROCESS_AOT_TASK_NAME, ProcessAot.class, (task) -> {
|
||||
configureAotTask(project, aotSourceSet, task, mainSourceSet, resourcesOutput);
|
||||
configureAotTask(project, aotSourceSet, task, resourcesOutput);
|
||||
task.getApplicationMainClass()
|
||||
.set(resolveMainClassName.flatMap(ResolveMainClassName::readMainClassName));
|
||||
task.setClasspath(aotClasspath);
|
||||
@ -139,7 +139,7 @@ public class SpringBootAotPlugin implements Plugin<Project> {
|
||||
configureDependsOn(project, aotSourceSet, processAot);
|
||||
}
|
||||
|
||||
private void configureAotTask(Project project, SourceSet sourceSet, AbstractAot task, SourceSet inputSourceSet,
|
||||
private void configureAotTask(Project project, SourceSet sourceSet, AbstractAot task,
|
||||
Provider<Directory> resourcesOutput) {
|
||||
task.getSourcesOutput()
|
||||
.set(project.getLayout().getBuildDirectory().dir("generated/" + sourceSet.getName() + "Sources"));
|
||||
@ -154,7 +154,7 @@ public class SpringBootAotPlugin implements Plugin<Project> {
|
||||
private Configuration createAotProcessingClasspath(Project project, String taskName, SourceSet inputSourceSet) {
|
||||
Configuration base = project.getConfigurations()
|
||||
.getByName(inputSourceSet.getRuntimeClasspathConfigurationName());
|
||||
Configuration aotClasspath = project.getConfigurations().create(taskName + "Classpath", (classpath) -> {
|
||||
return project.getConfigurations().create(taskName + "Classpath", (classpath) -> {
|
||||
classpath.setCanBeConsumed(false);
|
||||
classpath.setCanBeResolved(true);
|
||||
classpath.setDescription("Classpath of the " + taskName + " task.");
|
||||
@ -166,7 +166,6 @@ public class SpringBootAotPlugin implements Plugin<Project> {
|
||||
}
|
||||
});
|
||||
});
|
||||
return aotClasspath;
|
||||
}
|
||||
|
||||
private Stream<Configuration> removeDevelopmentOnly(Set<Configuration> configurations) {
|
||||
@ -196,7 +195,7 @@ public class SpringBootAotPlugin implements Plugin<Project> {
|
||||
.dir("generated/" + aotTestSourceSet.getName() + "Resources");
|
||||
TaskProvider<ProcessTestAot> processTestAot = project.getTasks()
|
||||
.register(PROCESS_TEST_AOT_TASK_NAME, ProcessTestAot.class, (task) -> {
|
||||
configureAotTask(project, aotTestSourceSet, task, testSourceSet, resourcesOutput);
|
||||
configureAotTask(project, aotTestSourceSet, task, resourcesOutput);
|
||||
task.setClasspath(aotClasspath);
|
||||
task.setClasspathRoots(testSourceSet.getOutput());
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user