Search in sources :

Example 6 with PublicationContainer

use of org.gradle.api.publish.PublicationContainer in project shipkit by mockito.

the class JavaPublishPlugin method apply.

public void apply(final Project project) {
    final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration();
    project.getPlugins().apply(JavaLibraryPlugin.class);
    project.getPlugins().apply("maven-publish");
    final Jar sourcesJar = (Jar) project.getTasks().getByName(JavaLibraryPlugin.SOURCES_JAR_TASK);
    final Jar javadocJar = (Jar) project.getTasks().getByName(JavaLibraryPlugin.JAVADOC_JAR_TASK);
    GradleDSLHelper.publications(project, new Action<PublicationContainer>() {

        public void execute(PublicationContainer publications) {
            MavenPublication p = publications.create(PUBLICATION_NAME, MavenPublication.class, new Action<MavenPublication>() {

                public void execute(MavenPublication publication) {
                    publication.from(project.getComponents().getByName("java"));
                    publication.artifact(sourcesJar);
                    publication.artifact(javadocJar);
                    publication.setArtifactId(((Jar) project.getTasks().getByName("jar")).getBaseName());
                    PomCustomizer.customizePom(project, conf, publication);
                }
            });
            LOG.info("{} - configured '{}' publication", project.getPath(), p.getArtifactId());
        }
    });
    // so that we flesh out problems with maven publication during the build process
    project.getTasks().getByName("build").dependsOn("publishToMavenLocal");
}
Also used : Action(org.gradle.api.Action) ShipkitConfiguration(org.shipkit.gradle.configuration.ShipkitConfiguration) ShipkitConfigurationPlugin(org.shipkit.internal.gradle.configuration.ShipkitConfigurationPlugin) PublicationContainer(org.gradle.api.publish.PublicationContainer) MavenPublication(org.gradle.api.publish.maven.MavenPublication) Jar(org.gradle.api.tasks.bundling.Jar)

Aggregations

PublicationContainer (org.gradle.api.publish.PublicationContainer)6 SoftwareComponent (org.gradle.api.component.SoftwareComponent)2 SoftwareComponentContainer (org.gradle.api.component.SoftwareComponentContainer)2 Finalize (org.gradle.model.Finalize)2 Mutate (org.gradle.model.Mutate)2 PluginDeclaration (org.gradle.plugin.devel.PluginDeclaration)2 Action (org.gradle.api.Action)1 RepositoryHandler (org.gradle.api.artifacts.dsl.RepositoryHandler)1 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)1 PublishingExtension (org.gradle.api.publish.PublishingExtension)1 DefaultPublicationContainer (org.gradle.api.publish.internal.DefaultPublicationContainer)1 DefaultPublishingExtension (org.gradle.api.publish.internal.DefaultPublishingExtension)1 MavenPublication (org.gradle.api.publish.maven.MavenPublication)1 Jar (org.gradle.api.tasks.bundling.Jar)1 ShipkitConfiguration (org.shipkit.gradle.configuration.ShipkitConfiguration)1 ShipkitConfigurationPlugin (org.shipkit.internal.gradle.configuration.ShipkitConfigurationPlugin)1