use of org.gradle.api.plugins.internal.DefaultWarPluginConvention in project gradle by gradle.
the class WarPlugin method apply.
@Override
public void apply(final Project project) {
project.getPluginManager().apply(JavaPlugin.class);
final WarPluginConvention pluginConvention = new DefaultWarPluginConvention(project);
project.getConvention().getPlugins().put("war", pluginConvention);
project.getTasks().withType(War.class).configureEach(task -> {
task.getWebAppDirectory().convention(project.getLayout().dir(project.provider(() -> pluginConvention.getWebAppDir())));
task.from(task.getWebAppDirectory());
task.dependsOn((Callable) () -> project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath());
task.classpath((Callable) () -> {
FileCollection runtimeClasspath = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath();
Configuration providedRuntime = project.getConfigurations().getByName(PROVIDED_RUNTIME_CONFIGURATION_NAME);
return runtimeClasspath.minus(providedRuntime);
});
});
TaskProvider<War> war = project.getTasks().register(WAR_TASK_NAME, War.class, warTask -> {
warTask.setDescription("Generates a war archive with all the compiled classes, the web-app content and the libraries.");
warTask.setGroup(BasePlugin.BUILD_GROUP);
});
PublishArtifact warArtifact = new LazyPublishArtifact(war, ((ProjectInternal) project).getFileResolver());
project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(warArtifact);
configureConfigurations(project.getConfigurations());
configureComponent(project, warArtifact);
}
Aggregations