Search in sources :

Example 1 with IvyArtifactRepository

use of org.gradle.api.artifacts.repositories.IvyArtifactRepository 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 2 with IvyArtifactRepository

use of org.gradle.api.artifacts.repositories.IvyArtifactRepository in project gradle by gradle.

the class IvyPublishPlugin method disableGradleMetadataGenerationIfCustomLayout.

private void disableGradleMetadataGenerationIfCustomLayout(NamedDomainObjectList<IvyArtifactRepository> repositories, GenerateModuleMetadata generateTask) {
    AtomicBoolean didWarn = new AtomicBoolean();
    Spec<? super Task> checkStandardLayout = task -> {
        boolean standard = repositories.stream().allMatch(this::hasStandardPattern);
        if (!standard && !didWarn.getAndSet(true)) {
            LOGGER.warn("Publication of Gradle Module Metadata is disabled because you have configured an Ivy repository with a non-standard layout");
        }
        return standard;
    };
    Spec<TaskInternal> spec = new AndSpec<TaskInternal>(generateTask.getOnlyIf(), checkStandardLayout);
    generateTask.setOnlyIf(Cast.<Spec<? super Task>>uncheckedCast(spec));
}
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) AndSpec(org.gradle.api.specs.AndSpec) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TaskInternal(org.gradle.api.internal.TaskInternal)

Example 3 with IvyArtifactRepository

use of org.gradle.api.artifacts.repositories.IvyArtifactRepository in project gradle by gradle.

the class PublishToIvyRepository method publish.

@TaskAction
public void publish() {
    IvyPublicationInternal publicationInternal = getPublicationInternal();
    if (publicationInternal == null) {
        throw new InvalidUserDataException("The 'publication' property is required");
    }
    IvyArtifactRepository repository = getRepository();
    if (repository == null) {
        throw new InvalidUserDataException("The 'repository' property is required");
    }
    getDuplicatePublicationTracker().checkCanPublish(publicationInternal, repository.getUrl(), repository.getName());
    doPublish(publicationInternal, repository);
}
Also used : IvyPublicationInternal(org.gradle.api.publish.ivy.internal.publication.IvyPublicationInternal) InvalidUserDataException(org.gradle.api.InvalidUserDataException) IvyArtifactRepository(org.gradle.api.artifacts.repositories.IvyArtifactRepository) TaskAction(org.gradle.api.tasks.TaskAction)

Example 4 with IvyArtifactRepository

use of org.gradle.api.artifacts.repositories.IvyArtifactRepository in project spring-security by spring-projects.

the class GitHubChangelogPlugin method createRepository.

private void createRepository(Project project) {
    IvyArtifactRepository repository = project.getRepositories().ivy(new Action<IvyArtifactRepository>() {

        @Override
        public void execute(IvyArtifactRepository repository) {
            repository.setUrl("https://github.com/");
            repository.patternLayout(new Action<IvyPatternRepositoryLayout>() {

                @Override
                public void execute(IvyPatternRepositoryLayout layout) {
                    layout.artifact("[organization]/[artifact]/releases/download/v[revision]/[artifact].[ext]");
                }
            });
            repository.getMetadataSources().artifact();
        }
    });
    project.getRepositories().exclusiveContent(new Action<ExclusiveContentRepository>() {

        @Override
        public void execute(ExclusiveContentRepository exclusiveContentRepository) {
            exclusiveContentRepository.forRepositories(repository);
            exclusiveContentRepository.filter(new Action<InclusiveRepositoryContentDescriptor>() {

                @Override
                public void execute(InclusiveRepositoryContentDescriptor descriptor) {
                    descriptor.includeGroup("spring-io");
                }
            });
        }
    });
}
Also used : Action(org.gradle.api.Action) ExclusiveContentRepository(org.gradle.api.artifacts.repositories.ExclusiveContentRepository) IvyPatternRepositoryLayout(org.gradle.api.artifacts.repositories.IvyPatternRepositoryLayout) IvyArtifactRepository(org.gradle.api.artifacts.repositories.IvyArtifactRepository) InclusiveRepositoryContentDescriptor(org.gradle.api.artifacts.repositories.InclusiveRepositoryContentDescriptor)

Aggregations

IvyArtifactRepository (org.gradle.api.artifacts.repositories.IvyArtifactRepository)4 IvyPublicationInternal (org.gradle.api.publish.ivy.internal.publication.IvyPublicationInternal)3 List (java.util.List)2 Set (java.util.Set)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 Inject (javax.inject.Inject)2 StringUtils.capitalize (org.apache.commons.lang.StringUtils.capitalize)2 NamedDomainObjectFactory (org.gradle.api.NamedDomainObjectFactory)2 NamedDomainObjectList (org.gradle.api.NamedDomainObjectList)2 NamedDomainObjectSet (org.gradle.api.NamedDomainObjectSet)2 Plugin (org.gradle.api.Plugin)2 Project (org.gradle.api.Project)2 Task (org.gradle.api.Task)2 Usage (org.gradle.api.attributes.Usage)2 DirectoryProperty (org.gradle.api.file.DirectoryProperty)2 TaskInternal (org.gradle.api.internal.TaskInternal)2 Module (org.gradle.api.internal.artifacts.Module)2 DependencyMetaDataProvider (org.gradle.api.internal.artifacts.configurations.DependencyMetaDataProvider)2 DefaultIvyArtifactRepository (org.gradle.api.internal.artifacts.repositories.DefaultIvyArtifactRepository)2 IvyRepositoryDescriptor (org.gradle.api.internal.artifacts.repositories.descriptor.IvyRepositoryDescriptor)2