Search in sources :

Example 1 with MavenArtifactRepository

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

the class PublishToMavenRepository method publish.

@TaskAction
public void publish() {
    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");
    }
    doPublish(publicationInternal, repository);
}
Also used : InvalidUserDataException(org.gradle.api.InvalidUserDataException) MavenArtifactRepository(org.gradle.api.artifacts.repositories.MavenArtifactRepository) MavenPublicationInternal(org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal) TaskAction(org.gradle.api.tasks.TaskAction)

Example 2 with MavenArtifactRepository

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

the class PublishLocalPlugin method apply.

@Override
public void apply(Project project) {
    project.getPlugins().withType(MavenPublishPlugin.class).all(new Action<MavenPublishPlugin>() {

        @Override
        public void execute(MavenPublishPlugin mavenPublish) {
            PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
            publishing.getRepositories().maven(new Action<MavenArtifactRepository>() {

                @Override
                public void execute(MavenArtifactRepository maven) {
                    maven.setName("local");
                    maven.setUrl(new File(project.getRootProject().getBuildDir(), "publications/repos"));
                }
            });
        }
    });
}
Also used : Action(org.gradle.api.Action) MavenPublishPlugin(org.gradle.api.publish.maven.plugins.MavenPublishPlugin) MavenArtifactRepository(org.gradle.api.artifacts.repositories.MavenArtifactRepository) File(java.io.File) PublishingExtension(org.gradle.api.publish.PublishingExtension)

Example 3 with MavenArtifactRepository

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

the class PublishToMavenRepositoryHook method publish.

@TaskAction
public void publish() {
    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");
    }
    doPublish(publicationInternal, repository);
}
Also used : InvalidUserDataException(org.gradle.api.InvalidUserDataException) MavenArtifactRepository(org.gradle.api.artifacts.repositories.MavenArtifactRepository) MavenPublicationInternal(org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal) TaskAction(org.gradle.api.tasks.TaskAction)

Example 4 with MavenArtifactRepository

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

the class DefaultBaseRepositoryFactory method createJCenterRepository.

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

Example 5 with MavenArtifactRepository

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

the class PluginResolutionServiceResolver method resolvePluginDependencies.

private ClassPath resolvePluginDependencies(final PluginUseMetaData metadata) {
    DependencyResolutionServices resolution = dependencyResolutionServicesFactory.create();
    RepositoryHandler repositories = resolution.getResolveRepositoryHandler();
    final String repoUrl = metadata.implementation.get("repo");
    repositories.maven(new Action<MavenArtifactRepository>() {

        public void execute(MavenArtifactRepository mavenArtifactRepository) {
            mavenArtifactRepository.setUrl(repoUrl);
        }
    });
    Dependency dependency = resolution.getDependencyHandler().create(metadata.implementation.get("gav"));
    ConfigurationContainerInternal configurations = (ConfigurationContainerInternal) resolution.getConfigurationContainer();
    ConfigurationInternal configuration = configurations.detachedConfiguration(dependency);
    try {
        Set<File> files = configuration.getResolvedConfiguration().getFiles(Specs.satisfyAll());
        return new DefaultClassPath(files);
    } catch (ResolveException e) {
        throw new DependencyResolutionException("Failed to resolve all plugin dependencies from " + repoUrl, e.getCause());
    }
}
Also used : ConfigurationContainerInternal(org.gradle.api.internal.artifacts.configurations.ConfigurationContainerInternal) Dependency(org.gradle.api.artifacts.Dependency) ConfigurationInternal(org.gradle.api.internal.artifacts.configurations.ConfigurationInternal) ResolveException(org.gradle.api.artifacts.ResolveException) DependencyResolutionServices(org.gradle.api.internal.artifacts.DependencyResolutionServices) MavenArtifactRepository(org.gradle.api.artifacts.repositories.MavenArtifactRepository) RepositoryHandler(org.gradle.api.artifacts.dsl.RepositoryHandler) File(java.io.File) DefaultClassPath(org.gradle.internal.classpath.DefaultClassPath)

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