Search in sources :

Example 11 with PublishingExtension

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

the class IvyPublishPlugin method createTasksLater.

private void createTasksLater(final Project project, final PublishingExtension publishingExtension, final DirectoryProperty buildDir) {
    final TaskContainer tasks = project.getTasks();
    final NamedDomainObjectSet<IvyPublicationInternal> publications = publishingExtension.getPublications().withType(IvyPublicationInternal.class);
    final NamedDomainObjectList<IvyArtifactRepository> repositories = publishingExtension.getRepositories().withType(IvyArtifactRepository.class);
    repositories.all(repository -> tasks.register(publishAllToSingleRepoTaskName(repository), publish -> {
        publish.setDescription("Publishes all Ivy publications produced by this project to the " + repository.getName() + " repository.");
        publish.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
    }));
    publications.all(publication -> {
        final String publicationName = publication.getName();
        createGenerateIvyDescriptorTask(tasks, publicationName, publication, buildDir);
        createGenerateMetadataTask(tasks, publication, publications, buildDir, repositories);
        createPublishTaskForEachRepository(tasks, publication, publicationName, repositories);
    });
}
Also used : NamedDomainObjectFactory(org.gradle.api.NamedDomainObjectFactory) VersionMappingStrategyInternal(org.gradle.api.publish.internal.versionmapping.VersionMappingStrategyInternal) Path(org.gradle.model.Path) PluginManager(org.gradle.api.plugins.PluginManager) IvyArtifactNotationParserFactory(org.gradle.api.publish.ivy.internal.artifact.IvyArtifactNotationParserFactory) GenerateModuleMetadata(org.gradle.api.publish.tasks.GenerateModuleMetadata) NamedDomainObjectList(org.gradle.api.NamedDomainObjectList) Task(org.gradle.api.Task) PublishingExtension(org.gradle.api.publish.PublishingExtension) PublishingPlugin(org.gradle.api.publish.plugins.PublishingPlugin) IvyPublicationIdentity(org.gradle.api.publish.ivy.internal.publisher.IvyPublicationIdentity) TaskProvider(org.gradle.api.tasks.TaskProvider) ExtensionContainer(org.gradle.api.plugins.ExtensionContainer) IvyArtifact(org.gradle.api.publish.ivy.IvyArtifact) Project(org.gradle.api.Project) Set(java.util.Set) NamedDomainObjectSet(org.gradle.api.NamedDomainObjectSet) GenerateIvyDescriptor(org.gradle.api.publish.ivy.tasks.GenerateIvyDescriptor) IvyPublication(org.gradle.api.publish.ivy.IvyPublication) List(java.util.List) Spec(org.gradle.api.specs.Spec) TaskContainer(org.gradle.api.tasks.TaskContainer) AndSpec(org.gradle.api.specs.AndSpec) IvyRepositoryDescriptor(org.gradle.api.internal.artifacts.repositories.descriptor.IvyRepositoryDescriptor) NotationParser(org.gradle.internal.typeconversion.NotationParser) PublishToIvyRepository(org.gradle.api.publish.ivy.tasks.PublishToIvyRepository) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DefaultIvyPublicationIdentity(org.gradle.api.publish.ivy.internal.publication.DefaultIvyPublicationIdentity) Logger(org.gradle.api.logging.Logger) Module(org.gradle.api.internal.artifacts.Module) SourceSet(org.gradle.api.tasks.SourceSet) Inject(javax.inject.Inject) DefaultVersionMappingStrategy(org.gradle.api.publish.ivy.internal.versionmapping.DefaultVersionMappingStrategy) DirectoryProperty(org.gradle.api.file.DirectoryProperty) SourceSetContainer(org.gradle.api.tasks.SourceSetContainer) DefaultIvyPublication(org.gradle.api.publish.ivy.internal.publication.DefaultIvyPublication) StringUtils.capitalize(org.apache.commons.lang.StringUtils.capitalize) Usage(org.gradle.api.attributes.Usage) TaskInternal(org.gradle.api.internal.TaskInternal) JavaPlatformPlugin(org.gradle.api.plugins.JavaPlatformPlugin) Cast(org.gradle.internal.Cast) RepositoryDescriptor(org.gradle.api.internal.artifacts.repositories.descriptor.RepositoryDescriptor) Instantiator(org.gradle.internal.reflect.Instantiator) IvyPublicationInternal(org.gradle.api.publish.ivy.internal.publication.IvyPublicationInternal) FileResolver(org.gradle.api.internal.file.FileResolver) ObjectFactory(org.gradle.api.model.ObjectFactory) Logging(org.gradle.api.logging.Logging) DefaultIvyArtifactRepository(org.gradle.api.internal.artifacts.repositories.DefaultIvyArtifactRepository) DependencyMetaDataProvider(org.gradle.api.internal.artifacts.configurations.DependencyMetaDataProvider) Plugin(org.gradle.api.Plugin) IvyArtifactRepository(org.gradle.api.artifacts.repositories.IvyArtifactRepository) IvyPublicationInternal(org.gradle.api.publish.ivy.internal.publication.IvyPublicationInternal) TaskContainer(org.gradle.api.tasks.TaskContainer) DefaultIvyArtifactRepository(org.gradle.api.internal.artifacts.repositories.DefaultIvyArtifactRepository) IvyArtifactRepository(org.gradle.api.artifacts.repositories.IvyArtifactRepository)

Example 12 with PublishingExtension

use of org.gradle.api.publish.PublishingExtension in project wildfly-gradle-tools by wildfly.

the class GradleArtifactFileResolver method extractPublishingExtension.

/**
 * @param project
 * @return the list of PublishingExtension(s), if some are defined: this will depend on the project (could be empty).
 */
private static PublishingExtension extractPublishingExtension(final Project project) {
    final ExtensionContainer extensions = project.getExtensions();
    final Object publishing = extensions.findByName("publishing");
    if (publishing == null) {
        return null;
    }
    if (!PublishingExtension.class.isAssignableFrom(publishing.getClass())) {
        throw new RuntimeException("The registered 'publishing' extension is not of the expected type PublishingExtension");
    }
    return (PublishingExtension) publishing;
}
Also used : ExtensionContainer(org.gradle.api.plugins.ExtensionContainer) PublishingExtension(org.gradle.api.publish.PublishingExtension)

Example 13 with PublishingExtension

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

the class MavenPluginPlugin method configurePomPackaging.

private void configurePomPackaging(Project project) {
    PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
    publishing.getPublications().withType(MavenPublication.class, this::setPackaging);
}
Also used : PublishingExtension(org.gradle.api.publish.PublishingExtension)

Example 14 with PublishingExtension

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

the class MavenPublishPlugin method realizePublishingTasksLater.

private void realizePublishingTasksLater(final Project project, final PublishingExtension extension) {
    final NamedDomainObjectSet<MavenPublicationInternal> mavenPublications = extension.getPublications().withType(MavenPublicationInternal.class);
    final TaskContainer tasks = project.getTasks();
    final DirectoryProperty buildDirectory = project.getLayout().getBuildDirectory();
    final TaskProvider<Task> publishLifecycleTask = tasks.named(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME);
    final TaskProvider<Task> publishLocalLifecycleTask = tasks.named(PUBLISH_LOCAL_LIFECYCLE_TASK_NAME);
    final NamedDomainObjectList<MavenArtifactRepository> repositories = extension.getRepositories().withType(MavenArtifactRepository.class);
    repositories.all(repository -> tasks.register(publishAllToSingleRepoTaskName(repository), publish -> {
        publish.setDescription("Publishes all Maven publications produced by this project to the " + repository.getName() + " repository.");
        publish.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
    }));
    mavenPublications.all(publication -> {
        createGenerateMetadataTask(tasks, publication, mavenPublications, buildDirectory);
        createGeneratePomTask(tasks, publication, buildDirectory, project);
        createLocalInstallTask(tasks, publishLocalLifecycleTask, publication);
        createPublishTasksForEachMavenRepo(tasks, publishLifecycleTask, publication, repositories);
    });
}
Also used : NamedDomainObjectFactory(org.gradle.api.NamedDomainObjectFactory) VersionMappingStrategyInternal(org.gradle.api.publish.internal.versionmapping.VersionMappingStrategyInternal) MavenArtifactNotationParserFactory(org.gradle.api.publish.maven.internal.artifact.MavenArtifactNotationParserFactory) PluginManager(org.gradle.api.plugins.PluginManager) GenerateModuleMetadata(org.gradle.api.publish.tasks.GenerateModuleMetadata) NamedDomainObjectList(org.gradle.api.NamedDomainObjectList) MavenPublication(org.gradle.api.publish.maven.MavenPublication) PublishToMavenLocal(org.gradle.api.publish.maven.tasks.PublishToMavenLocal) PublishToMavenRepository(org.gradle.api.publish.maven.tasks.PublishToMavenRepository) Module(org.gradle.api.internal.artifacts.Module) SourceSet(org.gradle.api.tasks.SourceSet) Inject(javax.inject.Inject) Task(org.gradle.api.Task) WritableMavenProjectIdentity(org.gradle.api.publish.maven.internal.publication.WritableMavenProjectIdentity) PublishingExtension(org.gradle.api.publish.PublishingExtension) PublishingPlugin(org.gradle.api.publish.plugins.PublishingPlugin) TaskProvider(org.gradle.api.tasks.TaskProvider) DirectoryProperty(org.gradle.api.file.DirectoryProperty) SourceSetContainer(org.gradle.api.tasks.SourceSetContainer) ExtensionContainer(org.gradle.api.plugins.ExtensionContainer) DefaultVersionMappingStrategy(org.gradle.api.publish.internal.versionmapping.DefaultVersionMappingStrategy) StringUtils.capitalize(org.apache.commons.lang.StringUtils.capitalize) Usage(org.gradle.api.attributes.Usage) ImmutableAttributesFactory(org.gradle.api.internal.attributes.ImmutableAttributesFactory) MavenArtifact(org.gradle.api.publish.maven.MavenArtifact) JavaPlatformPlugin(org.gradle.api.plugins.JavaPlatformPlugin) Project(org.gradle.api.Project) MavenArtifactRepository(org.gradle.api.artifacts.repositories.MavenArtifactRepository) InstantiatorFactory(org.gradle.internal.instantiation.InstantiatorFactory) Set(java.util.Set) NamedDomainObjectSet(org.gradle.api.NamedDomainObjectSet) DefaultMavenPublication(org.gradle.api.publish.maven.internal.publication.DefaultMavenPublication) MutableMavenProjectIdentity(org.gradle.api.publish.maven.internal.publisher.MutableMavenProjectIdentity) Instantiator(org.gradle.internal.reflect.Instantiator) ProviderFactory(org.gradle.api.provider.ProviderFactory) GenerateMavenPom(org.gradle.api.publish.maven.tasks.GenerateMavenPom) FileResolver(org.gradle.api.internal.file.FileResolver) ObjectFactory(org.gradle.api.model.ObjectFactory) TaskContainer(org.gradle.api.tasks.TaskContainer) DependencyMetaDataProvider(org.gradle.api.internal.artifacts.configurations.DependencyMetaDataProvider) Plugin(org.gradle.api.Plugin) MavenPublicationInternal(org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal) NotationParser(org.gradle.internal.typeconversion.NotationParser) Task(org.gradle.api.Task) TaskContainer(org.gradle.api.tasks.TaskContainer) DirectoryProperty(org.gradle.api.file.DirectoryProperty) MavenArtifactRepository(org.gradle.api.artifacts.repositories.MavenArtifactRepository) MavenPublicationInternal(org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal)

Example 15 with PublishingExtension

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

the class ManagementConfigurationPlugin method apply.

@Override
public void apply(Project project) {
    ConfigurationContainer configurations = project.getConfigurations();
    configurations.create(MANAGEMENT_CONFIGURATION_NAME, (management) -> {
        management.setVisible(false);
        management.setCanBeConsumed(false);
        management.setCanBeResolved(false);
        PluginContainer plugins = project.getPlugins();
        plugins.withType(JavaPlugin.class, (javaPlugin) -> {
            configurations.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management);
            configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management);
            configurations.getByName(JavaPlugin.TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management);
            configurations.getByName(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management);
        });
        plugins.withType(JavaTestFixturesPlugin.class, (javaTestFixturesPlugin) -> {
            configurations.getByName("testFixturesCompileClasspath").extendsFrom(management);
            configurations.getByName("testFixturesRuntimeClasspath").extendsFrom(management);
        });
        plugins.withType(MavenPublishPlugin.class, (mavenPublish) -> {
            PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
            publishing.getPublications().withType(MavenPublication.class, (mavenPublication -> {
                mavenPublication.versionMapping((versions) -> versions.allVariants(versionMapping -> versionMapping.fromResolutionResult()));
            }));
        });
        plugins.withType(PropDepsPlugin.class, (propDepsPlugin -> {
            configurations.getByName("optional").extendsFrom(management);
            configurations.getByName("provided").extendsFrom(management);
        }));
    });
}
Also used : PublishingExtension(org.gradle.api.publish.PublishingExtension) Project(org.gradle.api.Project) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) MavenPublishPlugin(org.gradle.api.publish.maven.plugins.MavenPublishPlugin) JavaTestFixturesPlugin(org.gradle.api.plugins.JavaTestFixturesPlugin) PropDepsPlugin(org.springframework.gradle.propdeps.PropDepsPlugin) PluginContainer(org.gradle.api.plugins.PluginContainer) JavaPlugin(org.gradle.api.plugins.JavaPlugin) MavenPublication(org.gradle.api.publish.maven.MavenPublication) Plugin(org.gradle.api.Plugin) PluginContainer(org.gradle.api.plugins.PluginContainer) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) PublishingExtension(org.gradle.api.publish.PublishingExtension)

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