Java Code Examples for org.gradle.api.publish.PublishingExtension#getPublications()

The following examples show how to use org.gradle.api.publish.PublishingExtension#getPublications() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MavenPublishPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Mutate
@SuppressWarnings("UnusedDeclaration")
public void realizePublishingTasks(CollectionBuilder<Task> tasks, @Path("tasks.publish") Task publishLifecycleTask, @Path("tasks.publishToMavenLocal") Task publishLocalLifecycleTask,
                                   PublishingExtension extension) {
    // Create generatePom tasks for any Maven publication
    PublicationContainer publications = extension.getPublications();

    for (final MavenPublicationInternal publication : publications.withType(MavenPublicationInternal.class)) {
        String publicationName = publication.getName();

        createGeneratePomTask(tasks, publication, publicationName);
        createLocalInstallTask(tasks, publishLocalLifecycleTask, publication, publicationName);
        createPublishTasksForEachMavenRepo(tasks, extension, publishLifecycleTask, publication, publicationName);
    }
}
 
Example 2
Source File: PublishingPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Mutate
void addConfiguredPublicationsToProjectPublicationRegistry(ProjectPublicationRegistry projectPublicationRegistry, PublishingExtension extension, ProjectIdentifier projectIdentifier) {
    for (Publication publication : extension.getPublications()) {
        PublicationInternal internalPublication = (PublicationInternal) publication;
        projectPublicationRegistry.registerPublication(projectIdentifier.getPath(), new DefaultProjectPublication(internalPublication.getCoordinates()));
    }
}
 
Example 3
Source File: MavenPublishTaskModelRule.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@SuppressWarnings("UnusedDeclaration")
public void realizePublishingTasks(TaskContainer tasks, PublishingExtension extension) {
    // Create generatePom tasks for any Maven publication
    PublicationContainer publications = extension.getPublications();

    for (final MavenPublicationInternal publication : publications.withType(MavenPublicationInternal.class)) {
        String publicationName = publication.getName();

        createGeneratePomTask(publication, publicationName);
        createLocalInstallTask(tasks, publication, publicationName);
        createPublishTasksForEachMavenRepo(tasks, extension, publication, publicationName);
    }
}
 
Example 4
Source File: IvyPublicationTasksModelRule.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void createTasks(TaskContainer tasks, PublishingExtension publishingExtension) {
    PublicationContainer publications = publishingExtension.getPublications();
    RepositoryHandler repositories = publishingExtension.getRepositories();

    for (final IvyPublicationInternal publication : publications.withType(IvyPublicationInternal.class)) {

        final String publicationName = publication.getName();
        final String descriptorTaskName = String.format("generateDescriptorFileFor%sPublication", capitalize(publicationName));

        GenerateIvyDescriptor descriptorTask = tasks.create(descriptorTaskName, GenerateIvyDescriptor.class);
        descriptorTask.setDescription(String.format("Generates the Ivy Module Descriptor XML file for publication '%s'.", publication.getName()));
        descriptorTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
        descriptorTask.setDescriptor(publication.getDescriptor());

        ConventionMapping descriptorTaskConventionMapping = new DslObject(descriptorTask).getConventionMapping();
        descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
            public Object call() throws Exception {
                return new File(project.getBuildDir(), "publications/" + publication.getName() + "/ivy.xml");
            }
        });

        publication.setDescriptorFile(descriptorTask.getOutputs().getFiles());

        for (IvyArtifactRepository repository : repositories.withType(IvyArtifactRepository.class)) {
            final String repositoryName = repository.getName();
            final String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName));

            PublishToIvyRepository publishTask = tasks.create(publishTaskName, PublishToIvyRepository.class);
            publishTask.setPublication(publication);
            publishTask.setRepository(repository);
            publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
            publishTask.setDescription(String.format("Publishes Ivy publication '%s' to Ivy repository '%s'.", publicationName, repositoryName));

            tasks.getByName(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME).dependsOn(publishTask);
        }
    }
}
 
Example 5
Source File: MavenPublishPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Mutate
@SuppressWarnings("UnusedDeclaration")
public void realizePublishingTasks(CollectionBuilder<Task> tasks, @Path("tasks.publish") Task publishLifecycleTask, @Path("tasks.publishToMavenLocal") Task publishLocalLifecycleTask,
                                   PublishingExtension extension) {
    // Create generatePom tasks for any Maven publication
    PublicationContainer publications = extension.getPublications();

    for (final MavenPublicationInternal publication : publications.withType(MavenPublicationInternal.class)) {
        String publicationName = publication.getName();

        createGeneratePomTask(tasks, publication, publicationName);
        createLocalInstallTask(tasks, publishLocalLifecycleTask, publication, publicationName);
        createPublishTasksForEachMavenRepo(tasks, extension, publishLifecycleTask, publication, publicationName);
    }
}
 
Example 6
Source File: PublishingPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Mutate
void addConfiguredPublicationsToProjectPublicationRegistry(ProjectPublicationRegistry projectPublicationRegistry, PublishingExtension extension, ProjectIdentifier projectIdentifier) {
    for (Publication publication : extension.getPublications()) {
        PublicationInternal internalPublication = (PublicationInternal) publication;
        projectPublicationRegistry.registerPublication(projectIdentifier.getPath(), new DefaultProjectPublication(internalPublication.getCoordinates()));
    }
}
 
Example 7
Source File: MavenPublishTaskModelRule.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@SuppressWarnings("UnusedDeclaration")
public void realizePublishingTasks(TaskContainer tasks, PublishingExtension extension) {
    // Create generatePom tasks for any Maven publication
    PublicationContainer publications = extension.getPublications();

    for (final MavenPublicationInternal publication : publications.withType(MavenPublicationInternal.class)) {
        String publicationName = publication.getName();

        createGeneratePomTask(publication, publicationName);
        createLocalInstallTask(tasks, publication, publicationName);
        createPublishTasksForEachMavenRepo(tasks, extension, publication, publicationName);
    }
}
 
Example 8
Source File: IvyPublicationTasksModelRule.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void createTasks(TaskContainer tasks, PublishingExtension publishingExtension) {
    PublicationContainer publications = publishingExtension.getPublications();
    RepositoryHandler repositories = publishingExtension.getRepositories();

    for (final IvyPublicationInternal publication : publications.withType(IvyPublicationInternal.class)) {

        final String publicationName = publication.getName();
        final String descriptorTaskName = String.format("generateDescriptorFileFor%sPublication", capitalize(publicationName));

        GenerateIvyDescriptor descriptorTask = tasks.create(descriptorTaskName, GenerateIvyDescriptor.class);
        descriptorTask.setDescription(String.format("Generates the Ivy Module Descriptor XML file for publication '%s'.", publication.getName()));
        descriptorTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
        descriptorTask.setDescriptor(publication.getDescriptor());

        ConventionMapping descriptorTaskConventionMapping = new DslObject(descriptorTask).getConventionMapping();
        descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
            public Object call() throws Exception {
                return new File(project.getBuildDir(), "publications/" + publication.getName() + "/ivy.xml");
            }
        });

        publication.setDescriptorFile(descriptorTask.getOutputs().getFiles());

        for (IvyArtifactRepository repository : repositories.withType(IvyArtifactRepository.class)) {
            final String repositoryName = repository.getName();
            final String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName));

            PublishToIvyRepository publishTask = tasks.create(publishTaskName, PublishToIvyRepository.class);
            publishTask.setPublication(publication);
            publishTask.setRepository(repository);
            publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
            publishTask.setDescription(String.format("Publishes Ivy publication '%s' to Ivy repository '%s'.", publicationName, repositoryName));

            tasks.getByName(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME).dependsOn(publishTask);
        }
    }
}
 
Example 9
Source File: IvyPublishPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Mutate
@SuppressWarnings("UnusedDeclaration")
public void createTasks(CollectionBuilder<Task> tasks, final @Path("tasks.publish") Task publishLifecycleTask, PublishingExtension publishingExtension) {
    PublicationContainer publications = publishingExtension.getPublications();
    RepositoryHandler repositories = publishingExtension.getRepositories();

    for (final IvyPublicationInternal publication : publications.withType(IvyPublicationInternal.class)) {

        final String publicationName = publication.getName();
        final String descriptorTaskName = String.format("generateDescriptorFileFor%sPublication", capitalize(publicationName));

        tasks.create(descriptorTaskName, GenerateIvyDescriptor.class, new Action<GenerateIvyDescriptor>() {
            public void execute(final GenerateIvyDescriptor descriptorTask) {
                descriptorTask.setDescription(String.format("Generates the Ivy Module Descriptor XML file for publication '%s'.", publication.getName()));
                descriptorTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
                descriptorTask.setDescriptor(publication.getDescriptor());

                ConventionMapping descriptorTaskConventionMapping = new DslObject(descriptorTask).getConventionMapping();
                descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
                    public Object call() throws Exception {
                        return new File(descriptorTask.getProject().getBuildDir(), "publications/" + publication.getName() + "/ivy.xml");
                    }
                });

                publication.setDescriptorFile(descriptorTask.getOutputs().getFiles());
            }
        });

        for (final IvyArtifactRepository repository : repositories.withType(IvyArtifactRepository.class)) {
            final String repositoryName = repository.getName();
            final String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName));

            tasks.create(publishTaskName, PublishToIvyRepository.class, new Action<PublishToIvyRepository>() {
                public void execute(PublishToIvyRepository publishTask) {
                    publishTask.setPublication(publication);
                    publishTask.setRepository(repository);
                    publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
                    publishTask.setDescription(String.format("Publishes Ivy publication '%s' to Ivy 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);
                }
            });
        }
    }
}
 
Example 10
Source File: IvyPublishPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Mutate
@SuppressWarnings("UnusedDeclaration")
public void createTasks(CollectionBuilder<Task> tasks, final @Path("tasks.publish") Task publishLifecycleTask, PublishingExtension publishingExtension) {
    PublicationContainer publications = publishingExtension.getPublications();
    RepositoryHandler repositories = publishingExtension.getRepositories();

    for (final IvyPublicationInternal publication : publications.withType(IvyPublicationInternal.class)) {

        final String publicationName = publication.getName();
        final String descriptorTaskName = String.format("generateDescriptorFileFor%sPublication", capitalize(publicationName));

        tasks.create(descriptorTaskName, GenerateIvyDescriptor.class, new Action<GenerateIvyDescriptor>() {
            public void execute(final GenerateIvyDescriptor descriptorTask) {
                descriptorTask.setDescription(String.format("Generates the Ivy Module Descriptor XML file for publication '%s'.", publication.getName()));
                descriptorTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
                descriptorTask.setDescriptor(publication.getDescriptor());

                ConventionMapping descriptorTaskConventionMapping = new DslObject(descriptorTask).getConventionMapping();
                descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
                    public Object call() throws Exception {
                        return new File(descriptorTask.getProject().getBuildDir(), "publications/" + publication.getName() + "/ivy.xml");
                    }
                });

                publication.setDescriptorFile(descriptorTask.getOutputs().getFiles());
            }
        });

        for (final IvyArtifactRepository repository : repositories.withType(IvyArtifactRepository.class)) {
            final String repositoryName = repository.getName();
            final String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName));

            tasks.create(publishTaskName, PublishToIvyRepository.class, new Action<PublishToIvyRepository>() {
                public void execute(PublishToIvyRepository publishTask) {
                    publishTask.setPublication(publication);
                    publishTask.setRepository(repository);
                    publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
                    publishTask.setDescription(String.format("Publishes Ivy publication '%s' to Ivy 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);
                }
            });
        }
    }
}