Search in sources :

Example 1 with PublishToMavenRepository

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);
}
Also used : Task(org.gradle.api.Task) Action(org.gradle.api.Action) TaskContainer(org.gradle.api.tasks.TaskContainer) PublishToMavenRepository(org.gradle.api.publish.maven.tasks.PublishToMavenRepository) PublishToMavenRepositoryHook(com.taobao.android.builder.tasks.maven.PublishToMavenRepositoryHook)

Aggregations

PublishToMavenRepositoryHook (com.taobao.android.builder.tasks.maven.PublishToMavenRepositoryHook)1 Action (org.gradle.api.Action)1 Task (org.gradle.api.Task)1 PublishToMavenRepository (org.gradle.api.publish.maven.tasks.PublishToMavenRepository)1 TaskContainer (org.gradle.api.tasks.TaskContainer)1