private void createPublishTasksForEachMavenRepo(ModelMap<Task> tasks, PublishingExtension extension, final Task publishLifecycleTask, final MavenPublicationInternal publication, final String publicationName) { for (final MavenArtifactRepository repository : extension.getRepositories().withType(MavenArtifactRepository.class)) { final String repositoryName = repository.getName(); String publishTaskName = "publish" + capitalize(publicationName) + "PublicationTo" + capitalize(repositoryName) + "Repository"; tasks.create(publishTaskName, PublishToMavenRepository.class, new Action<PublishToMavenRepository>() { public void execute(PublishToMavenRepository publishTask) { publishTask.setPublication(publication); publishTask.setRepository(repository); publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP); publishTask.setDescription("Publishes Maven publication '" + publicationName + "' to Maven repository '" + repositoryName + "'."); } }); publishLifecycleTask.dependsOn(publishTaskName); } }
private void createPublishTasksForEachMavenRepo(CollectionBuilder<Task> tasks, PublishingExtension extension, final Task publishLifecycleTask, final MavenPublicationInternal publication, final String publicationName) { for (final MavenArtifactRepository repository : extension.getRepositories().withType(MavenArtifactRepository.class)) { final String repositoryName = repository.getName(); String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName)); tasks.create(publishTaskName, PublishToMavenRepository.class, new Action<PublishToMavenRepository>() { public void execute(PublishToMavenRepository publishTask) { publishTask.setPublication(publication); publishTask.setRepository(repository); publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP); publishTask.setDescription(String.format("Publishes Maven publication '%s' to Maven repository '%s'.", publicationName, repositoryName)); //Because dynamic rules are not yet implemented we have to violate input immutability here as an interim step publishLifecycleTask.dependsOn(publishTask); } }); } }
@Mutate public static void linkPublishingTasks(ModelMap<Task> tasks) { Task defaultPublishTask = tasks.get("publish"); for (XdepsPublishTask xdepsPublishTask : tasks.withType(XdepsPublishTask.class)) { for (Task publishTask : tasks.withType(PublishToMavenRepository.class)) { if (publishTask.getName().endsWith("PublicationTo" + xdepsPublishTask.getRepoName() + "Repository")) { defaultPublishTask.getDependsOn().remove(publishTask.getName()); xdepsPublishTask.dependsOn(publishTask); publishTask.setGroup(null); } } } }
private void createPublishTasksForEachMavenRepo(TaskContainer tasks, PublishingExtension extension, MavenPublicationInternal publication, String publicationName) { for (MavenArtifactRepository repository : extension.getRepositories().withType(MavenArtifactRepository.class)) { String repositoryName = repository.getName(); String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName)); PublishToMavenRepository publishTask = tasks.create(publishTaskName, PublishToMavenRepository.class); publishTask.setPublication(publication); publishTask.setRepository(repository); publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP); publishTask.setDescription(String.format("Publishes Maven publication '%s' to Maven repository '%s'.", publicationName, repositoryName)); publishLifecycleTask.dependsOn(publishTask); } }