use of com.thomasjensen.checkstyle.addons.build.tasks.JarJavadocConfigAction in project checkstyle-addons by checkstyle-addons.
the class TaskCreator method setupArtifactTasks.
public void setupArtifactTasks(@Nonnull final DependencyConfigs pDepConfigs) {
final TaskContainer tasks = project.getTasks();
for (final DependencyConfig depConfig : pDepConfigs.getAll().values()) {
final String pubSuffix = depConfig.getName();
// 'generatePomProperties' task
final String pomPropsTaskName = TaskNames.generatePomProperties.getName(depConfig);
final TaskProvider<GeneratePomPropsTask> pomPropsTaskTaskProvider = tasks.register(pomPropsTaskName, GeneratePomPropsTask.class);
pomPropsTaskTaskProvider.configure(pomPropsTask -> {
pomPropsTask.getAppendix().set(depConfig.isDefaultConfig() ? null : pubSuffix);
pomPropsTask.updateDescription();
});
// 'jar' task
final String jarTaskName = TaskNames.jar.getName(depConfig);
final TaskProvider<Jar> jarTaskProvider = tasks.register(jarTaskName, Jar.class);
jarTaskProvider.configure(new JarConfigAction(depConfig));
// 'fatjar' task
final String fatjarTaskName = TaskNames.fatJar.getName(depConfig);
final TaskProvider<ShadowJar> shadowJarTaskProvider = tasks.register(fatjarTaskName, ShadowJar.class);
shadowJarTaskProvider.configure(new FatJarConfigAction(depConfig));
// 'jarSources' task
final String jarSourcesTaskName = TaskNames.jarSources.getName(depConfig);
final TaskProvider<Jar> jarSourcesTaskProvider = tasks.register(jarSourcesTaskName, Jar.class);
jarSourcesTaskProvider.configure(new JarSourcesConfigAction(depConfig));
// 'jarJavadoc' task
final String jarJavadocTaskName = TaskNames.jarJavadoc.getName(depConfig);
final TaskProvider<Jar> jarJavadocTaskProvider = tasks.register(jarJavadocTaskName, Jar.class);
jarJavadocTaskProvider.configure(new JarJavadocConfigAction(depConfig));
// 'jarEclipse' task
final String eclipseTaskName = TaskNames.jarEclipse.getName(depConfig);
final TaskProvider<Jar> jarEclipseTaskProvider = tasks.register(eclipseTaskName, Jar.class);
jarEclipseTaskProvider.configure(new JarEclipseConfigAction(depConfig));
// 'jarSonarqube' task (with 'jarSonarqubeRelocate' task)
TaskProvider<ShadowJar> jarSqTaskProvider = null;
if (depConfig.isSonarQubeSupported()) {
final String sqTaskName = TaskNames.jarSonarqube.getName(depConfig);
final String relocateTaskName = TaskNames.jarSonarqubeRelocate.getName(depConfig);
final TaskProvider<ConfigureShadowRelocation> relocationTaskProvider = tasks.register(relocateTaskName, ConfigureShadowRelocation.class);
relocationTaskProvider.configure(relocTask -> {
relocTask.setTarget((ShadowJar) tasks.getByName(sqTaskName));
relocTask.setPrefix("com.thomasjensen.checkstyle.addons.shadow");
});
jarSqTaskProvider = tasks.register(sqTaskName, ShadowJar.class);
jarSqTaskProvider.configure(new JarSonarqubeConfigAction(depConfig));
jarSqTaskProvider.configure(t -> t.dependsOn(relocationTaskProvider));
}
final TaskProvider<ShadowJar> jarSqTaskProviderFinal = jarSqTaskProvider;
// 'assemble' task for the dependency configuration
TaskProvider<Task> assembleTaskProvider = null;
if (depConfig.isDefaultConfig()) {
assembleTaskProvider = tasks.named(BasePlugin.ASSEMBLE_TASK_NAME);
} else {
assembleTaskProvider = tasks.register(TaskNames.assemble.getName(depConfig));
assembleTaskProvider.configure(assembleTask -> assembleTask.setDescription("Assembles the artifacts belonging to dependency configuration '" + depConfig.getName() + "'"));
final TaskProvider<Task> assembleTaskProviderFinal = assembleTaskProvider;
final TaskProvider<Task> buildTaskProvider = tasks.named(JavaBasePlugin.BUILD_TASK_NAME);
buildTaskProvider.configure(buildTask -> buildTask.dependsOn(assembleTaskProviderFinal));
}
assembleTaskProvider.configure(assembleTask -> {
assembleTask.setGroup(ARTIFACTS_GROUP_NAME);
assembleTask.dependsOn(jarTaskProvider);
assembleTask.dependsOn(shadowJarTaskProvider);
assembleTask.dependsOn(jarSourcesTaskProvider);
assembleTask.dependsOn(jarJavadocTaskProvider);
assembleTask.dependsOn(jarEclipseTaskProvider);
if (jarSqTaskProviderFinal != null) {
assembleTask.dependsOn(jarSqTaskProviderFinal);
}
});
}
// disable standard 'jar' task
tasks.named(JavaPlugin.JAR_TASK_NAME).configure(t -> t.setEnabled(false));
}
Aggregations