Search in sources :

Example 1 with BootWar

use of org.springframework.boot.gradle.tasks.bundling.BootWar in project spring-boot by spring-projects.

the class WarPluginAction method configureBootWarTask.

private TaskProvider<BootWar> configureBootWarTask(Project project) {
    Configuration developmentOnly = project.getConfigurations().getByName(SpringBootPlugin.DEVELOPMENT_ONLY_CONFIGURATION_NAME);
    Configuration productionRuntimeClasspath = project.getConfigurations().getByName(SpringBootPlugin.PRODUCTION_RUNTIME_CLASSPATH_CONFIGURATION_NAME);
    Callable<FileCollection> classpath = () -> project.getExtensions().getByType(SourceSetContainer.class).getByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath().minus(providedRuntimeConfiguration(project)).minus((developmentOnly.minus(productionRuntimeClasspath))).filter(new JarTypeFileSpec());
    TaskProvider<ResolveMainClassName> resolveMainClassName = ResolveMainClassName.registerForTask(SpringBootPlugin.BOOT_WAR_TASK_NAME, project, classpath);
    TaskProvider<BootWar> bootWarProvider = project.getTasks().register(SpringBootPlugin.BOOT_WAR_TASK_NAME, BootWar.class, (bootWar) -> {
        bootWar.setGroup(BasePlugin.BUILD_GROUP);
        bootWar.setDescription("Assembles an executable war archive containing webapp" + " content, and the main classes and their dependencies.");
        bootWar.providedClasspath(providedRuntimeConfiguration(project));
        bootWar.setClasspath(classpath);
        Provider<String> manifestStartClass = project.provider(() -> (String) bootWar.getManifest().getAttributes().get("Start-Class"));
        bootWar.getMainClass().convention(resolveMainClassName.flatMap((resolver) -> manifestStartClass.isPresent() ? manifestStartClass : resolveMainClassName.get().readMainClassName()));
    });
    bootWarProvider.map((bootWar) -> bootWar.getClasspath());
    return bootWarProvider;
}
Also used : LazyPublishArtifact(org.gradle.api.internal.artifacts.dsl.LazyPublishArtifact) Action(org.gradle.api.Action) Project(org.gradle.api.Project) Callable(java.util.concurrent.Callable) WarPlugin(org.gradle.api.plugins.WarPlugin) BootWar(org.springframework.boot.gradle.tasks.bundling.BootWar) BasePlugin(org.gradle.api.plugins.BasePlugin) FileCollection(org.gradle.api.file.FileCollection) SourceSet(org.gradle.api.tasks.SourceSet) BootBuildImage(org.springframework.boot.gradle.tasks.bundling.BootBuildImage) Configuration(org.gradle.api.artifacts.Configuration) Provider(org.gradle.api.provider.Provider) War(org.gradle.api.tasks.bundling.War) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) TaskProvider(org.gradle.api.tasks.TaskProvider) SourceSetContainer(org.gradle.api.tasks.SourceSetContainer) Plugin(org.gradle.api.Plugin) BootWar(org.springframework.boot.gradle.tasks.bundling.BootWar) Configuration(org.gradle.api.artifacts.Configuration) FileCollection(org.gradle.api.file.FileCollection) SourceSetContainer(org.gradle.api.tasks.SourceSetContainer)

Aggregations

Callable (java.util.concurrent.Callable)1 Action (org.gradle.api.Action)1 Plugin (org.gradle.api.Plugin)1 Project (org.gradle.api.Project)1 Configuration (org.gradle.api.artifacts.Configuration)1 ConfigurationContainer (org.gradle.api.artifacts.ConfigurationContainer)1 FileCollection (org.gradle.api.file.FileCollection)1 LazyPublishArtifact (org.gradle.api.internal.artifacts.dsl.LazyPublishArtifact)1 BasePlugin (org.gradle.api.plugins.BasePlugin)1 WarPlugin (org.gradle.api.plugins.WarPlugin)1 Provider (org.gradle.api.provider.Provider)1 SourceSet (org.gradle.api.tasks.SourceSet)1 SourceSetContainer (org.gradle.api.tasks.SourceSetContainer)1 TaskProvider (org.gradle.api.tasks.TaskProvider)1 War (org.gradle.api.tasks.bundling.War)1 BootBuildImage (org.springframework.boot.gradle.tasks.bundling.BootBuildImage)1 BootWar (org.springframework.boot.gradle.tasks.bundling.BootWar)1