use of org.gradle.api.publish.maven.tasks.PublishToMavenRepository 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);
}
Aggregations