Search in sources :

Example 6 with PublishingExtension

use of org.gradle.api.publish.PublishingExtension in project coffeenet-starter by coffeenet.

the class DeployedPlugin method apply.

@Override
public void apply(Project project) {
    project.getPlugins().apply(MavenPublishPlugin.class);
    // Create a new Maven publication
    PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
    MavenPublication mavenPublication = publishing.getPublications().create("maven", MavenPublication.class);
    mavenPublication.suppressAllPomMetadataWarnings();
    // Publish all Java artifacts and the platform BOMs
    // J-
    // @formatter:off
    project.getPlugins().withType(JavaPlugin.class).all((plugin) -> project.getComponents().matching((component) -> component.getName().equals("java")).all(mavenPublication::from));
    project.getPlugins().withType(JavaPlatformPlugin.class).all((plugin) -> project.getComponents().matching((component) -> component.getName().equals("javaPlatform")).all(mavenPublication::from));
    if (project.hasProperty(SIGN_GPG_PROPERTY_NAME)) {
        applyGpgSigning(project, mavenPublication);
    }
// @formatter:on
// J+
}
Also used : MavenPublication(org.gradle.api.publish.maven.MavenPublication) JavaPlugin(org.gradle.api.plugins.JavaPlugin) PublishingExtension(org.gradle.api.publish.PublishingExtension) JavaPlatformPlugin(org.gradle.api.plugins.JavaPlatformPlugin)

Example 7 with PublishingExtension

use of org.gradle.api.publish.PublishingExtension in project spring-boot by spring-projects.

the class MavenRepositoryPlugin method apply.

@Override
public void apply(Project project) {
    project.getPlugins().apply(MavenPublishPlugin.class);
    PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
    File repositoryLocation = new File(project.getBuildDir(), "maven-repository");
    publishing.getRepositories().maven((mavenRepository) -> {
        mavenRepository.setName("project");
        mavenRepository.setUrl(repositoryLocation.toURI());
    });
    project.getTasks().matching((task) -> task.getName().equals(PUBLISH_TO_PROJECT_REPOSITORY_TASK_NAME)).all((task) -> setUpProjectRepository(project, task, repositoryLocation));
    project.getTasks().matching((task) -> task.getName().equals("publishPluginMavenPublicationToProjectRepository")).all((task) -> setUpProjectRepository(project, task, repositoryLocation));
}
Also used : Action(org.gradle.api.Action) JavaPlatformPlugin(org.gradle.api.plugins.JavaPlatformPlugin) Project(org.gradle.api.Project) MavenPublishPlugin(org.gradle.api.publish.maven.plugins.MavenPublishPlugin) ProjectDependency(org.gradle.api.artifacts.ProjectDependency) HashMap(java.util.HashMap) JavaPlugin(org.gradle.api.plugins.JavaPlugin) DependencySet(org.gradle.api.artifacts.DependencySet) File(java.io.File) Configuration(org.gradle.api.artifacts.Configuration) JavaLibraryPlugin(org.gradle.api.plugins.JavaLibraryPlugin) Task(org.gradle.api.Task) PublishingExtension(org.gradle.api.publish.PublishingExtension) Map(java.util.Map) Plugin(org.gradle.api.Plugin) File(java.io.File) PublishingExtension(org.gradle.api.publish.PublishingExtension)

Example 8 with PublishingExtension

use of org.gradle.api.publish.PublishingExtension in project spring-boot by spring-projects.

the class MavenPublishingConventions method apply.

void apply(Project project) {
    project.getPlugins().withType(MavenPublishPlugin.class).all((mavenPublish) -> {
        PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
        if (project.hasProperty("deploymentRepository")) {
            publishing.getRepositories().maven((mavenRepository) -> {
                mavenRepository.setUrl(project.property("deploymentRepository"));
                mavenRepository.setName("deployment");
            });
        }
        publishing.getPublications().withType(MavenPublication.class).all((mavenPublication) -> customizeMavenPublication(mavenPublication, project));
        project.getPlugins().withType(JavaPlugin.class).all((javaPlugin) -> {
            JavaPluginExtension extension = project.getExtensions().getByType(JavaPluginExtension.class);
            extension.withJavadocJar();
            extension.withSourcesJar();
        });
    });
}
Also used : MavenPublishPlugin(org.gradle.api.publish.maven.plugins.MavenPublishPlugin) MavenPublication(org.gradle.api.publish.maven.MavenPublication) JavaPlugin(org.gradle.api.plugins.JavaPlugin) JavaPluginExtension(org.gradle.api.plugins.JavaPluginExtension) PublishingExtension(org.gradle.api.publish.PublishingExtension)

Example 9 with PublishingExtension

use of org.gradle.api.publish.PublishingExtension in project spring-boot by spring-projects.

the class DeployedPlugin method apply.

@Override
@SuppressWarnings("deprecation")
public void apply(Project project) {
    project.getPlugins().apply(MavenPublishPlugin.class);
    project.getPlugins().apply(MavenRepositoryPlugin.class);
    PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
    MavenPublication mavenPublication = publishing.getPublications().create("maven", MavenPublication.class);
    project.afterEvaluate((evaluated) -> {
        project.getPlugins().withType(JavaPlugin.class).all((javaPlugin) -> {
            if (((Jar) project.getTasks().getByName(JavaPlugin.JAR_TASK_NAME)).isEnabled()) {
                project.getComponents().matching((component) -> component.getName().equals("java")).all((javaComponent) -> mavenPublication.from(javaComponent));
            }
        });
    });
    project.getPlugins().withType(JavaPlatformPlugin.class).all((javaPlugin) -> project.getComponents().matching((component) -> component.getName().equals("javaPlatform")).all((javaComponent) -> mavenPublication.from(javaComponent)));
}
Also used : PublishingExtension(org.gradle.api.publish.PublishingExtension) Jar(org.gradle.api.tasks.bundling.Jar) JavaPlatformPlugin(org.gradle.api.plugins.JavaPlatformPlugin) Project(org.gradle.api.Project) MavenPublishPlugin(org.gradle.api.publish.maven.plugins.MavenPublishPlugin) JavaPlugin(org.gradle.api.plugins.JavaPlugin) MavenPublication(org.gradle.api.publish.maven.MavenPublication) Plugin(org.gradle.api.Plugin) MavenPublication(org.gradle.api.publish.maven.MavenPublication) JavaPlugin(org.gradle.api.plugins.JavaPlugin) Jar(org.gradle.api.tasks.bundling.Jar) PublishingExtension(org.gradle.api.publish.PublishingExtension) JavaPlatformPlugin(org.gradle.api.plugins.JavaPlatformPlugin)

Example 10 with PublishingExtension

use of org.gradle.api.publish.PublishingExtension in project gradle by gradle.

the class PublishingPlugin method apply.

@Override
public void apply(final Project project) {
    RepositoryHandler repositories = publicationServices.createRepositoryHandler();
    PublicationContainer publications = instantiator.newInstance(DefaultPublicationContainer.class, instantiator, collectionCallbackActionDecorator);
    PublishingExtension extension = project.getExtensions().create(PublishingExtension.class, PublishingExtension.NAME, DefaultPublishingExtension.class, repositories, publications);
    project.getTasks().register(PUBLISH_LIFECYCLE_TASK_NAME, task -> {
        task.setDescription("Publishes all publications produced by this project.");
        task.setGroup(PUBLISH_TASK_GROUP);
    });
    extension.getPublications().all(publication -> {
        PublicationInternal<?> internalPublication = Cast.uncheckedNonnullCast(publication);
        ProjectInternal projectInternal = (ProjectInternal) project;
        projectPublicationRegistry.registerPublication(projectInternal, internalPublication);
    });
    bridgeToSoftwareModelIfNeeded((ProjectInternal) project);
    validatePublishingModelWhenComplete(project, extension);
}
Also used : PublicationContainer(org.gradle.api.publish.PublicationContainer) DefaultPublicationContainer(org.gradle.api.publish.internal.DefaultPublicationContainer) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) RepositoryHandler(org.gradle.api.artifacts.dsl.RepositoryHandler) PublishingExtension(org.gradle.api.publish.PublishingExtension) DefaultPublishingExtension(org.gradle.api.publish.internal.DefaultPublishingExtension)

Aggregations

PublishingExtension (org.gradle.api.publish.PublishingExtension)16 Project (org.gradle.api.Project)8 JavaPlugin (org.gradle.api.plugins.JavaPlugin)8 Plugin (org.gradle.api.Plugin)7 MavenPublication (org.gradle.api.publish.maven.MavenPublication)7 JavaPlatformPlugin (org.gradle.api.plugins.JavaPlatformPlugin)5 MavenPublishPlugin (org.gradle.api.publish.maven.plugins.MavenPublishPlugin)5 Task (org.gradle.api.Task)4 File (java.io.File)3 Set (java.util.Set)3 Action (org.gradle.api.Action)3 HashMap (java.util.HashMap)2 ConfigurationContainer (org.gradle.api.artifacts.ConfigurationContainer)2 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)2 ExtensionContainer (org.gradle.api.plugins.ExtensionContainer)2 JavaPluginExtension (org.gradle.api.plugins.JavaPluginExtension)2 SourceSet (org.gradle.api.tasks.SourceSet)2 SourceSetContainer (org.gradle.api.tasks.SourceSetContainer)2 TaskProvider (org.gradle.api.tasks.TaskProvider)2 IdlOptions (com.linkedin.pegasus.gradle.PegasusOptions.IdlOptions)1