Java 类org.gradle.api.publish.PublicationContainer 实例源码

项目:Reer    文件:MavenPublishPlugin.java   
@Mutate
@SuppressWarnings("UnusedDeclaration")
public void realizePublishingTasks(ModelMap<Task> tasks, PublishingExtension extension, @Path("buildDir") File buildDir) {
    // Create generatePom tasks for any Maven publication
    PublicationContainer publications = extension.getPublications();
    Task publishLifecycleTask = tasks.get(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME);
    Task publishLocalLifecycleTask = tasks.get(PUBLISH_LOCAL_LIFECYCLE_TASK_NAME);

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

        createGeneratePomTask(tasks, publication, publicationName, buildDir);
        createLocalInstallTask(tasks, publishLocalLifecycleTask, publication, publicationName);
        createPublishTasksForEachMavenRepo(tasks, extension, publishLifecycleTask, publication, publicationName);
    }
}
项目:Reer    文件:MavenPluginPublishingRules.java   
private void createMavenMarkerPublication(PluginDeclaration declaration, final MavenPublication coordinates, PublicationContainer publications) {
    String pluginId = declaration.getId();
    MavenPublication publication = publications.create(declaration.getName() + "PluginMarkerMaven", MavenPublication.class);
    publication.setArtifactId(pluginId + PLUGIN_MARKER_SUFFIX);
    publication.setGroupId(pluginId);
    publication.getPom().withXml(new Action<XmlProvider>() {
        @Override
        public void execute(XmlProvider xmlProvider) {
            Element root = xmlProvider.asElement();
            Document document = root.getOwnerDocument();
            Node dependencies = root.appendChild(document.createElement("dependencies"));
            Node dependency = dependencies.appendChild(document.createElement("dependency"));
            Node groupId = dependency.appendChild(document.createElement("groupId"));
            groupId.setTextContent(coordinates.getGroupId());
            Node artifactId = dependency.appendChild(document.createElement("artifactId"));
            artifactId.setTextContent(coordinates.getArtifactId());
            Node version = dependency.appendChild(document.createElement("version"));
            version.setTextContent(coordinates.getVersion());
        }
    });
}
项目:Reer    文件:PublishingPlugin.java   
public void apply(final Project project) {
    RepositoryHandler repositories = publicationServices.createRepositoryHandler();
    PublicationContainer publications = instantiator.newInstance(DefaultPublicationContainer.class, instantiator);

    // TODO Registering an extension should register it with the model registry as well
    project.getExtensions().create(PublishingExtension.NAME, DefaultPublishingExtension.class, repositories, publications);

    Task publishLifecycleTask = project.getTasks().create(PUBLISH_LIFECYCLE_TASK_NAME);
    publishLifecycleTask.setDescription("Publishes all publications produced by this project.");
    publishLifecycleTask.setGroup(PUBLISH_TASK_GROUP);
}
项目:Reer    文件:MavenPluginPublishingRules.java   
@Mutate
public void addMainPublication(PublishingExtension publishing, GradlePluginDevelopmentExtension pluginDevelopment, ServiceRegistry services) {
    if (!pluginDevelopment.isAutomatedPublishing()) {
        return;
    }
    SoftwareComponentContainer componentContainer = services.get(SoftwareComponentContainer.class);
    SoftwareComponent component = componentContainer.getByName("java");

    PublicationContainer publications = publishing.getPublications();
    createMavenPluginPublication(component, publications);
}
项目:Reer    文件:MavenPluginPublishingRules.java   
@Finalize
public void addMarkerPublications(PublishingExtension publishing, GradlePluginDevelopmentExtension pluginDevelopment) {
    if (!pluginDevelopment.isAutomatedPublishing()) {
        return;
    }

    PublicationContainer publications = publishing.getPublications();
    NamedDomainObjectContainer<PluginDeclaration> declaredPlugins = pluginDevelopment.getPlugins();

    for (PluginDeclaration declaration : declaredPlugins) {
        createMavenMarkerPublication(declaration, (MavenPublication) publications.getByName("pluginMaven"), publications);
    }
}
项目:Reer    文件:IvyPluginPublishingRules.java   
@Mutate
public void addMainPublication(PublishingExtension publishing, GradlePluginDevelopmentExtension pluginDevelopment, ServiceRegistry services) {
    if (!pluginDevelopment.isAutomatedPublishing()) {
        return;
    }
    SoftwareComponentContainer componentContainer = services.get(SoftwareComponentContainer.class);
    SoftwareComponent component = componentContainer.getByName("java");

    PublicationContainer publications = publishing.getPublications();
    createIvyPluginPublication(component, publications);
}
项目:Reer    文件:IvyPluginPublishingRules.java   
@Finalize
public void addMarkerPublications(PublishingExtension publishing, GradlePluginDevelopmentExtension pluginDevelopment) {
    if (!pluginDevelopment.isAutomatedPublishing()) {
        return;
    }
    PublicationContainer publications = publishing.getPublications();
    NamedDomainObjectContainer<PluginDeclaration> declaredPlugins = pluginDevelopment.getPlugins();
    for (PluginDeclaration declaration : declaredPlugins) {
        createIvyMarkerPublication(declaration, (IvyPublication) publications.getByName("pluginIvy"), publications);
    }
}
项目:Reer    文件:IvyPublishPlugin.java   
@Mutate
@SuppressWarnings("UnusedDeclaration")
public void createTasks(ModelMap<Task> tasks, PublishingExtension publishingExtension, @Path("buildDir") final File buildDir) {
    PublicationContainer publications = publishingExtension.getPublications();
    RepositoryHandler repositories = publishingExtension.getRepositories();

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

        final String publicationName = publication.getName();
        final String descriptorTaskName = "generateDescriptorFileFor" + capitalize(publicationName) + "Publication";

        tasks.create(descriptorTaskName, GenerateIvyDescriptor.class, new Action<GenerateIvyDescriptor>() {
            public void execute(final GenerateIvyDescriptor descriptorTask) {
                descriptorTask.setDescription("Generates the Ivy Module Descriptor XML file for publication '" + publicationName + "'.");
                descriptorTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
                descriptorTask.setDescriptor(publication.getDescriptor());
                descriptorTask.setDestination(new File(buildDir, "publications/" + publicationName + "/ivy.xml"));
            }
        });
        publication.setDescriptorFile(tasks.get(descriptorTaskName).getOutputs().getFiles());

        for (final IvyArtifactRepository repository : repositories.withType(IvyArtifactRepository.class)) {
            final String repositoryName = repository.getName();
            final String publishTaskName = "publish" + capitalize(publicationName) + "PublicationTo" + capitalize(repositoryName) + "Repository";

            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("Publishes Ivy publication '" + publicationName + "' to Ivy repository '" + repositoryName + "'.");
                }
            });
            tasks.get(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME).dependsOn(publishTaskName);
        }
    }
}
项目:gradle-mobile-plugin    文件:XdepsUtil.java   
public static List<DefaultMavenPublication> getMavenPublications(Project project) {
    List<DefaultMavenPublication> xdeps = new ArrayList<>();
    PublishingExtension publishingExtension = getPublishingExtension(project);
    if (publishingExtension != null) {
        PublicationContainer publicationContainer = publishingExtension.getPublications();
        for (Publication publication : publicationContainer) {
            xdeps.add((DefaultMavenPublication)publication);
        }
    }
    return xdeps;
}
项目:Pushjet-Android    文件:MavenPublishPlugin.java   
@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);
    }
}
项目:Pushjet-Android    文件:PublishingPlugin.java   
public void apply(final Project project) {
    RepositoryHandler repositories = publicationServices.createRepositoryHandler();
    PublicationContainer publications = instantiator.newInstance(DefaultPublicationContainer.class, instantiator);

    // TODO Registering an extension should register it with the model registry as well
    project.getExtensions().create(PublishingExtension.NAME, DefaultPublishingExtension.class, repositories, publications);

    Task publishLifecycleTask = project.getTasks().create(PUBLISH_LIFECYCLE_TASK_NAME);
    publishLifecycleTask.setDescription("Publishes all publications produced by this project.");
    publishLifecycleTask.setGroup(PUBLISH_TASK_GROUP);
}
项目:Pushjet-Android    文件:MavenPublishTaskModelRule.java   
@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);
    }
}
项目:Pushjet-Android    文件:IvyPublicationTasksModelRule.java   
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);
        }
    }
}
项目:Reer    文件:DefaultPublishingExtension.java   
public DefaultPublishingExtension(RepositoryHandler repositories, PublicationContainer publications) {
    this.repositories = repositories;
    this.publications = publications;
}
项目:Reer    文件:DefaultPublishingExtension.java   
public PublicationContainer getPublications() {
    return publications;
}
项目:Reer    文件:DefaultPublishingExtension.java   
public void publications(Action<? super PublicationContainer> configure) {
    configure.execute(publications);
}
项目:Reer    文件:MavenPluginPublishingRules.java   
private void createMavenPluginPublication(SoftwareComponent component, PublicationContainer publications) {
    MavenPublication publication = publications.create("pluginMaven", MavenPublication.class);
    publication.from(component);
}
项目:Reer    文件:IvyPluginPublishingRules.java   
private void createIvyPluginPublication(SoftwareComponent component, PublicationContainer publications) {
    IvyPublication publication = publications.create("pluginIvy", IvyPublication.class);
    publication.from(component);
}
项目:Pushjet-Android    文件:DefaultPublishingExtension.java   
public DefaultPublishingExtension(RepositoryHandler repositories, PublicationContainer publications) {
    this.repositories = repositories;
    this.publications = publications;
}
项目:Pushjet-Android    文件:DefaultPublishingExtension.java   
public PublicationContainer getPublications() {
    return publications;
}
项目:Pushjet-Android    文件:DefaultPublishingExtension.java   
public void publications(Action<? super PublicationContainer> configure) {
    configure.execute(publications);
}
项目:Pushjet-Android    文件:IvyPublishPlugin.java   
@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);
                }
            });
        }
    }
}
项目:Pushjet-Android    文件:DefaultPublishingExtension.java   
public DefaultPublishingExtension(RepositoryHandler repositories, PublicationContainer publications) {
    this.repositories = repositories;
    this.publications = publications;
}
项目:Pushjet-Android    文件:DefaultPublishingExtension.java   
public PublicationContainer getPublications() {
    return publications;
}
项目:Pushjet-Android    文件:DefaultPublishingExtension.java   
public void publications(Action<? super PublicationContainer> configure) {
    configure.execute(publications);
}