use of org.gradle.api.tasks.TaskContainer in project atlas by alibaba.
the class PublishHooker method hookPublish.
public void hookPublish() {
project.getTasks().whenTaskAdded(new Action<Task>() {
@Override
public void execute(Task task) {
if ("publishMavenPublicationToMavenRepository".equals(task.getName())) {
publishTask = (PublishToMavenRepository) task;
task.setEnabled(false);
if (null != hookTask) {
hookTask.setRepository(publishTask.getRepository());
hookTask.setPublication(publishTask.getPublication());
}
}
}
});
final TaskContainer tasks = project.getTasks();
Task publishLifecycleTask = tasks.getByName(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME);
String taskName = "publishMavenPublicationToMavenRepositoryHook";
hookTask = tasks.create(taskName, PublishToMavenRepositoryHook.class, new Action<PublishToMavenRepositoryHook>() {
public void execute(PublishToMavenRepositoryHook publishTask) {
publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
}
});
publishLifecycleTask.dependsOn(taskName);
}
use of org.gradle.api.tasks.TaskContainer in project gradle by gradle.
the class MavenPublishPlugin method apply.
public void apply(final Project project) {
project.getPluginManager().apply(PublishingPlugin.class);
final TaskContainer tasks = project.getTasks();
final Task publishLocalLifecycleTask = tasks.create(PUBLISH_LOCAL_LIFECYCLE_TASK_NAME);
publishLocalLifecycleTask.setDescription("Publishes all Maven publications produced by this project to the local Maven cache.");
publishLocalLifecycleTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
// Can't move this to rules yet, because it has to happen before user deferred configurable actions
project.getExtensions().configure(PublishingExtension.class, new Action<PublishingExtension>() {
public void execute(PublishingExtension extension) {
// Register factory for MavenPublication
extension.getPublications().registerFactory(MavenPublication.class, new MavenPublicationFactory(dependencyMetaDataProvider, instantiator, fileResolver));
}
});
}
use of org.gradle.api.tasks.TaskContainer in project gradle by gradle.
the class EclipsePlugin method maybeAddTask.
private static <T extends Task> void maybeAddTask(Project project, IdePlugin plugin, String taskName, Class<T> taskType, Action<T> action) {
TaskContainer tasks = project.getTasks();
if (tasks.findByName(taskName) != null) {
return;
}
T task = tasks.create(taskName, taskType);
action.execute(task);
plugin.addWorker(task);
}
Aggregations