This commit is contained in:
Phillip Webb
2022-07-29 12:07:36 +01:00
parent 41e8697445
commit e08c16dfd6
17 changed files with 134 additions and 111 deletions

View File

@@ -22,6 +22,7 @@ import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.ConfigurationContainer;
import org.gradle.api.attributes.AttributeContainer;
import org.gradle.api.attributes.LibraryElements;
import org.gradle.api.file.Directory;
import org.gradle.api.plugins.JavaPlugin;
@@ -77,12 +78,17 @@ public class SpringBootAotPlugin implements Plugin<Project> {
aotImplementation.extendsFrom(configurations.getByName(main.getImplementationConfigurationName()));
aotImplementation.extendsFrom(configurations.getByName(main.getRuntimeOnlyConfigurationName()));
configurations.getByName(aot.getCompileClasspathConfigurationName())
.attributes((attributes) -> attributes.attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE,
project.getObjects().named(LibraryElements.class, LibraryElements.CLASSES_AND_RESOURCES)));
.attributes((attributes) -> addLibraryElementsAttribute(project, attributes));
});
return aotSourceSet;
}
private AttributeContainer addLibraryElementsAttribute(Project project, AttributeContainer attributes) {
LibraryElements libraryElements = project.getObjects().named(LibraryElements.class,
LibraryElements.CLASSES_AND_RESOURCES);
return attributes.attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, libraryElements);
}
private void registerGenerateAotSourcesTask(Project project, SourceSet aotSourceSet) {
TaskProvider<ResolveMainClassName> resolveMainClassName = project.getTasks()
.named(SpringBootPlugin.RESOLVE_MAIN_CLASS_NAME_TASK_NAME, ResolveMainClassName.class);