Search in sources :

Example 6 with MavenArtifactRepository

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

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

the class PublishToMavenRepository method computeSpec.

private PublishSpec computeSpec() {
    MavenPublicationInternal publicationInternal = getPublicationInternal();
    if (publicationInternal == null) {
        throw new InvalidUserDataException("The 'publication' property is required");
    }
    MavenArtifactRepository repository = getRepository();
    if (repository == null) {
        throw new InvalidUserDataException("The 'repository' property is required");
    }
    getDuplicatePublicationTracker().checkCanPublish(publicationInternal, repository.getUrl(), repository.getName());
    MavenNormalizedPublication normalizedPublication = publicationInternal.asNormalisedPublication();
    return new PublishSpec(RepositorySpec.of(repository), normalizedPublication);
}
Also used : InvalidUserDataException(org.gradle.api.InvalidUserDataException) MavenArtifactRepository(org.gradle.api.artifacts.repositories.MavenArtifactRepository) MavenPublicationInternal(org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal) MavenNormalizedPublication(org.gradle.api.publish.maven.internal.publisher.MavenNormalizedPublication)

Example 8 with MavenArtifactRepository

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

the class DefaultBaseRepositoryFactory method createMavenLocalRepository.

@Override
public MavenArtifactRepository createMavenLocalRepository() {
    MavenArtifactRepository mavenRepository = instantiator.newInstance(DefaultMavenLocalArtifactRepository.class, fileResolver, transportFactory, locallyAvailableResourceFinder, instantiatorFactory, artifactFileStore, pomParser, metadataParser, createAuthenticationContainer(), fileResourceRepository, mavenMetadataFactory, isolatableFactory, objectFactory, urlArtifactRepositoryFactory, checksumService);
    File localMavenRepository = localMavenRepositoryLocator.getLocalMavenRepository();
    mavenRepository.setUrl(localMavenRepository);
    return mavenRepository;
}
Also used : MavenArtifactRepository(org.gradle.api.artifacts.repositories.MavenArtifactRepository) File(java.io.File)

Example 9 with MavenArtifactRepository

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

the class DefaultBaseRepositoryFactory method createGradlePluginPortal.

@Override
public ArtifactRepository createGradlePluginPortal() {
    MavenArtifactRepository mavenRepository = createMavenRepository(new NamedMavenRepositoryDescriber(PLUGIN_PORTAL_DEFAULT_URL));
    mavenRepository.setUrl(System.getProperty(PLUGIN_PORTAL_OVERRIDE_URL_PROPERTY, PLUGIN_PORTAL_DEFAULT_URL));
    mavenRepository.metadataSources(MavenArtifactRepository.MetadataSources::mavenPom);
    return mavenRepository;
}
Also used : MavenArtifactRepository(org.gradle.api.artifacts.repositories.MavenArtifactRepository)

Example 10 with MavenArtifactRepository

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

the class DefaultBaseRepositoryFactory method createMavenCentralRepository.

@Override
public MavenArtifactRepository createMavenCentralRepository() {
    MavenArtifactRepository mavenRepository = createMavenRepository(new NamedMavenRepositoryDescriber(RepositoryHandler.MAVEN_CENTRAL_URL));
    mavenRepository.setUrl(RepositoryHandler.MAVEN_CENTRAL_URL);
    return mavenRepository;
}
Also used : MavenArtifactRepository(org.gradle.api.artifacts.repositories.MavenArtifactRepository)

Aggregations

MavenArtifactRepository (org.gradle.api.artifacts.repositories.MavenArtifactRepository)11 MavenPublicationInternal (org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal)4 File (java.io.File)3 InvalidUserDataException (org.gradle.api.InvalidUserDataException)3 PublishingExtension (org.gradle.api.publish.PublishingExtension)2 TaskAction (org.gradle.api.tasks.TaskAction)2 Set (java.util.Set)1 Inject (javax.inject.Inject)1 StringUtils.capitalize (org.apache.commons.lang.StringUtils.capitalize)1 Action (org.gradle.api.Action)1 NamedDomainObjectFactory (org.gradle.api.NamedDomainObjectFactory)1 NamedDomainObjectList (org.gradle.api.NamedDomainObjectList)1 NamedDomainObjectSet (org.gradle.api.NamedDomainObjectSet)1 Plugin (org.gradle.api.Plugin)1 Project (org.gradle.api.Project)1 Task (org.gradle.api.Task)1 Dependency (org.gradle.api.artifacts.Dependency)1 ResolveException (org.gradle.api.artifacts.ResolveException)1 RepositoryHandler (org.gradle.api.artifacts.dsl.RepositoryHandler)1 Usage (org.gradle.api.attributes.Usage)1