Java Code Examples for org.gradle.api.artifacts.dsl.RepositoryHandler

The following examples show how to use org.gradle.api.artifacts.dsl.RepositoryHandler. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
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());
    }
}
 
Example 2
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());
    }
}
 
Example 3
public AbstractScriptHandler(RepositoryHandler repositoryHandler,
                             DependencyHandler dependencyHandler, ScriptSource scriptSource,
                             ConfigurationContainer configContainer) {
    this.repositoryHandler = repositoryHandler;
    this.dependencyHandler = dependencyHandler;
    this.scriptSource = scriptSource;
    this.configContainer = configContainer;
    classpathConfiguration = configContainer.create(CLASSPATH_CONFIGURATION);
}
 
Example 4
public void createTasks(TaskContainer tasks, PublishingExtension publishingExtension) {
    PublicationContainer publications = publishingExtension.getPublications();
    RepositoryHandler repositories = publishingExtension.getRepositories();

    for (final IvyPublicationInternal publication : publications.withType(IvyPublicationInternal.class)) {

        final String publicationName = publication.getName();
        final String descriptorTaskName = String.format("generateDescriptorFileFor%sPublication", capitalize(publicationName));

        GenerateIvyDescriptor descriptorTask = tasks.create(descriptorTaskName, GenerateIvyDescriptor.class);
        descriptorTask.setDescription(String.format("Generates the Ivy Module Descriptor XML file for publication '%s'.", publication.getName()));
        descriptorTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
        descriptorTask.setDescriptor(publication.getDescriptor());

        ConventionMapping descriptorTaskConventionMapping = new DslObject(descriptorTask).getConventionMapping();
        descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
            public Object call() throws Exception {
                return new File(project.getBuildDir(), "publications/" + publication.getName() + "/ivy.xml");
            }
        });

        publication.setDescriptorFile(descriptorTask.getOutputs().getFiles());

        for (IvyArtifactRepository repository : repositories.withType(IvyArtifactRepository.class)) {
            final String repositoryName = repository.getName();
            final String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName));

            PublishToIvyRepository publishTask = tasks.create(publishTaskName, PublishToIvyRepository.class);
            publishTask.setPublication(publication);
            publishTask.setRepository(repository);
            publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
            publishTask.setDescription(String.format("Publishes Ivy publication '%s' to Ivy repository '%s'.", publicationName, repositoryName));

            tasks.getByName(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME).dependsOn(publishTask);
        }
    }
}
 
Example 5
public DefaultScriptHandler(
        ScriptSource scriptSource, RepositoryHandler repositoryHandler,
        DependencyHandler dependencyHandler, ConfigurationContainer configContainer,
        Factory<ClassLoader> classLoaderFactory
) {
    this.repositoryHandler = repositoryHandler;
    this.dependencyHandler = dependencyHandler;
    this.scriptSource = scriptSource;
    this.configContainer = configContainer;
    this.classLoaderFactory = classLoaderFactory;
    classpathConfiguration = configContainer.create(CLASSPATH_CONFIGURATION);
}
 
Example 6
public DefaultArtifactResolutionQuery(ConfigurationContainerInternal configurationContainer, RepositoryHandler repositoryHandler,
                                      ResolveIvyFactory ivyFactory, ModuleMetadataProcessor metadataProcessor, CacheLockingManager lockingManager) {
    this.configurationContainer = configurationContainer;
    this.repositoryHandler = repositoryHandler;
    this.ivyFactory = ivyFactory;
    this.metadataProcessor = metadataProcessor;
    this.lockingManager = lockingManager;
}
 
Example 7
public DefaultArtifactResolutionQuery(ConfigurationContainerInternal configurationContainer, RepositoryHandler repositoryHandler,
                                      ResolveIvyFactory ivyFactory, GlobalDependencyResolutionRules metadataHandler, CacheLockingManager lockingManager,
                                      ComponentTypeRegistry componentTypeRegistry) {
    this.configurationContainer = configurationContainer;
    this.repositoryHandler = repositoryHandler;
    this.ivyFactory = ivyFactory;
    this.metadataHandler = metadataHandler;
    this.lockingManager = lockingManager;
    this.componentTypeRegistry = componentTypeRegistry;
}
 
Example 8
public DefaultArtifactResolutionQueryFactory(ConfigurationContainerInternal configurationContainer, RepositoryHandler repositoryHandler,
                                             ResolveIvyFactory ivyFactory, GlobalDependencyResolutionRules metadataHandler,
                                             CacheLockingManager cacheLockingManager, ComponentTypeRegistry componentTypeRegistry) {
    this.configurationContainer = configurationContainer;
    this.repositoryHandler = repositoryHandler;
    this.ivyFactory = ivyFactory;
    this.metadataHandler = metadataHandler;
    this.cacheLockingManager = cacheLockingManager;
    this.componentTypeRegistry = componentTypeRegistry;
}
 
Example 9
public ScriptHandler create(ScriptSource scriptSource, ClassLoaderScope classLoaderScope, DomainObjectContext context) {
    DependencyResolutionServices services = dependencyManagementServices.create(fileResolver, dependencyMetaDataProvider, projectFinder, context);
    RepositoryHandler repositoryHandler = services.getResolveRepositoryHandler();
    ConfigurationContainer configurationContainer = services.getConfigurationContainer();
    DependencyHandler dependencyHandler = services.getDependencyHandler();
    return new DefaultScriptHandler(scriptSource, repositoryHandler, dependencyHandler, configurationContainer, new ScriptHandlerClassLoaderFactory(scriptSource, classLoaderScope));
}
 
Example 10
Source Project: pushfish-android   Source File: Upload.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Returns the repositories to upload to.
 */
public RepositoryHandler getRepositories() {
    if (repositories == null) {
        repositories = getPublicationServices().createRepositoryHandler();
    }
    return repositories;
}
 
Example 11
private void configureUploadTasks(final DefaultDeployerFactory deployerFactory) {
    project.getTasks().withType(Upload.class, new Action<Upload>() {
        public void execute(Upload upload) {
            RepositoryHandler repositories = upload.getRepositories();
            DefaultRepositoryHandler handler = (DefaultRepositoryHandler) repositories;
            DefaultMavenRepositoryHandlerConvention repositoryConvention = new DefaultMavenRepositoryHandlerConvention(handler, deployerFactory);
            new DslObject(repositories).getConvention().getPlugins().put("maven", repositoryConvention);
        }
    });
}
 
Example 12
private void configureUploadTasks(final DefaultDeployerFactory deployerFactory) {
    project.getTasks().withType(Upload.class, new Action<Upload>() {
        public void execute(Upload upload) {
            RepositoryHandler repositories = upload.getRepositories();
            DefaultRepositoryHandler handler = (DefaultRepositoryHandler) repositories;
            DefaultMavenRepositoryHandlerConvention repositoryConvention = new DefaultMavenRepositoryHandlerConvention(handler, deployerFactory);
            new DslObject(repositories).getConvention().getPlugins().put("maven", repositoryConvention);
        }
    });
}
 
Example 13
public DefaultScriptHandler(
        ScriptSource scriptSource, RepositoryHandler repositoryHandler,
        DependencyHandler dependencyHandler, ConfigurationContainer configContainer,
        Factory<ClassLoader> classLoaderFactory
) {
    this.repositoryHandler = repositoryHandler;
    this.dependencyHandler = dependencyHandler;
    this.scriptSource = scriptSource;
    this.configContainer = configContainer;
    this.classLoaderFactory = classLoaderFactory;
    classpathConfiguration = configContainer.create(CLASSPATH_CONFIGURATION);
}
 
Example 14
public DefaultArtifactResolutionQuery(ConfigurationContainerInternal configurationContainer, RepositoryHandler repositoryHandler,
                                      ResolveIvyFactory ivyFactory, ModuleMetadataProcessor metadataProcessor, CacheLockingManager lockingManager) {
    this.configurationContainer = configurationContainer;
    this.repositoryHandler = repositoryHandler;
    this.ivyFactory = ivyFactory;
    this.metadataProcessor = metadataProcessor;
    this.lockingManager = lockingManager;
}
 
Example 15
public DefaultArtifactResolutionQueryFactory(ConfigurationContainerInternal configurationContainer, RepositoryHandler repositoryHandler,
                                             ResolveIvyFactory ivyFactory, ModuleMetadataProcessor metadataProcessor,
                                             CacheLockingManager cacheLockingManager) {
    this.configurationContainer = configurationContainer;
    this.repositoryHandler = repositoryHandler;
    this.ivyFactory = ivyFactory;
    this.metadataProcessor = metadataProcessor;
    this.cacheLockingManager = cacheLockingManager;
}
 
Example 16
public void createTasks(TaskContainer tasks, PublishingExtension publishingExtension) {
    PublicationContainer publications = publishingExtension.getPublications();
    RepositoryHandler repositories = publishingExtension.getRepositories();

    for (final IvyPublicationInternal publication : publications.withType(IvyPublicationInternal.class)) {

        final String publicationName = publication.getName();
        final String descriptorTaskName = String.format("generateDescriptorFileFor%sPublication", capitalize(publicationName));

        GenerateIvyDescriptor descriptorTask = tasks.create(descriptorTaskName, GenerateIvyDescriptor.class);
        descriptorTask.setDescription(String.format("Generates the Ivy Module Descriptor XML file for publication '%s'.", publication.getName()));
        descriptorTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
        descriptorTask.setDescriptor(publication.getDescriptor());

        ConventionMapping descriptorTaskConventionMapping = new DslObject(descriptorTask).getConventionMapping();
        descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
            public Object call() throws Exception {
                return new File(project.getBuildDir(), "publications/" + publication.getName() + "/ivy.xml");
            }
        });

        publication.setDescriptorFile(descriptorTask.getOutputs().getFiles());

        for (IvyArtifactRepository repository : repositories.withType(IvyArtifactRepository.class)) {
            final String repositoryName = repository.getName();
            final String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName));

            PublishToIvyRepository publishTask = tasks.create(publishTaskName, PublishToIvyRepository.class);
            publishTask.setPublication(publication);
            publishTask.setRepository(repository);
            publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
            publishTask.setDescription(String.format("Publishes Ivy publication '%s' to Ivy repository '%s'.", publicationName, repositoryName));

            tasks.getByName(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME).dependsOn(publishTask);
        }
    }
}
 
Example 17
public ModuleMappingPluginResolver(String name, DependencyResolutionServices dependencyResolutionServices, Instantiator instantiator, Mapper mapper, Action<? super RepositoryHandler> repositoriesConfigurer) {
    this.name = name;
    this.dependencyResolutionServices = dependencyResolutionServices;
    this.instantiator = instantiator;
    this.mapper = mapper;
    this.repositoriesConfigurer = repositoriesConfigurer;
}
 
Example 18
public ScriptHandler create(ScriptSource scriptSource, ClassLoaderScope classLoaderScope, DomainObjectContext context) {
    DependencyResolutionServices services = dependencyManagementServices.create(fileResolver, dependencyMetaDataProvider, projectFinder, context);
    RepositoryHandler repositoryHandler = services.getResolveRepositoryHandler();
    ConfigurationContainer configurationContainer = services.getConfigurationContainer();
    DependencyHandler dependencyHandler = services.getDependencyHandler();
    return new DefaultScriptHandler(scriptSource, repositoryHandler, dependencyHandler, configurationContainer, new ScriptHandlerClassLoaderFactory(scriptSource, classLoaderScope));
}
 
Example 19
public AbstractScriptHandler(RepositoryHandler repositoryHandler,
                             DependencyHandler dependencyHandler, ScriptSource scriptSource,
                             ConfigurationContainer configContainer) {
    this.repositoryHandler = repositoryHandler;
    this.dependencyHandler = dependencyHandler;
    this.scriptSource = scriptSource;
    this.configContainer = configContainer;
    classpathConfiguration = configContainer.create(CLASSPATH_CONFIGURATION);
}
 
Example 20
private void configureUploadTasks(final DefaultDeployerFactory deployerFactory) {
    project.getTasks().withType(Upload.class, new Action<Upload>() {
        public void execute(Upload upload) {
            RepositoryHandler repositories = upload.getRepositories();
            DefaultRepositoryHandler handler = (DefaultRepositoryHandler) repositories;
            DefaultMavenRepositoryHandlerConvention repositoryConvention = new DefaultMavenRepositoryHandlerConvention(handler, deployerFactory);
            new DslObject(repositories).getConvention().getPlugins().put("maven", repositoryConvention);
        }
    });
}
 
Example 21
public void apply(final Project project) {
    RepositoryHandler repositories = publicationServices.createRepositoryHandler();
    PublicationContainer publications = instantiator.newInstance(DefaultPublicationContainer.class, instantiator);

    // TODO Registering an extension should register it with the model registry as well
    project.getExtensions().create(PublishingExtension.NAME, DefaultPublishingExtension.class, repositories, publications);

    Task publishLifecycleTask = project.getTasks().create(PUBLISH_LIFECYCLE_TASK_NAME);
    publishLifecycleTask.setDescription("Publishes all publications produced by this project.");
    publishLifecycleTask.setGroup(PUBLISH_TASK_GROUP);
}
 
Example 22
public ScriptHandler create(ScriptSource scriptSource, ClassLoaderScope classLoaderScope, DomainObjectContext context) {
    DependencyResolutionServices services = dependencyManagementServices.create(fileResolver, dependencyMetaDataProvider, projectFinder, context);
    RepositoryHandler repositoryHandler = services.getResolveRepositoryHandler();
    ConfigurationContainer configurationContainer = services.getConfigurationContainer();
    DependencyHandler dependencyHandler = services.getDependencyHandler();
    return new DefaultScriptHandler(scriptSource, repositoryHandler, dependencyHandler, configurationContainer, new ScriptHandlerClassLoaderFactory(scriptSource, classLoaderScope));
}
 
Example 23
public DefaultArtifactResolutionQuery(ConfigurationContainerInternal configurationContainer, RepositoryHandler repositoryHandler,
                                      ResolveIvyFactory ivyFactory, GlobalDependencyResolutionRules metadataHandler, CacheLockingManager lockingManager,
                                      ComponentTypeRegistry componentTypeRegistry) {
    this.configurationContainer = configurationContainer;
    this.repositoryHandler = repositoryHandler;
    this.ivyFactory = ivyFactory;
    this.metadataHandler = metadataHandler;
    this.lockingManager = lockingManager;
    this.componentTypeRegistry = componentTypeRegistry;
}
 
Example 24
public DefaultArtifactResolutionQueryFactory(ConfigurationContainerInternal configurationContainer, RepositoryHandler repositoryHandler,
                                             ResolveIvyFactory ivyFactory, GlobalDependencyResolutionRules metadataHandler,
                                             CacheLockingManager cacheLockingManager, ComponentTypeRegistry componentTypeRegistry) {
    this.configurationContainer = configurationContainer;
    this.repositoryHandler = repositoryHandler;
    this.ivyFactory = ivyFactory;
    this.metadataHandler = metadataHandler;
    this.cacheLockingManager = cacheLockingManager;
    this.componentTypeRegistry = componentTypeRegistry;
}
 
Example 25
public ScriptHandler create(ScriptSource scriptSource, ClassLoaderScope classLoaderScope, DomainObjectContext context) {
    DependencyResolutionServices services = dependencyManagementServices.create(fileResolver, dependencyMetaDataProvider, projectFinder, context);
    RepositoryHandler repositoryHandler = services.getResolveRepositoryHandler();
    ConfigurationContainer configurationContainer = services.getConfigurationContainer();
    DependencyHandler dependencyHandler = services.getDependencyHandler();
    return new DefaultScriptHandler(scriptSource, repositoryHandler, dependencyHandler, configurationContainer, new ScriptHandlerClassLoaderFactory(scriptSource, classLoaderScope));
}
 
Example 26
public DefaultPublishingExtension(RepositoryHandler repositories, PublicationContainer publications) {
    this.repositories = repositories;
    this.publications = publications;
}
 
Example 27
public RepositoryHandler getRepositories() {
    return repositories;
}
 
Example 28
public DefaultConfigurationResolver(ArtifactDependencyResolver resolver, RepositoryHandler repositories, GlobalDependencyResolutionRules metadataHandler) {
    this.resolver = resolver;
    this.repositories = repositories;
    this.metadataHandler = metadataHandler;
}
 
Example 29
public RepositoryHandler getRepositories() {
    return repositoryHandler;
}
 
Example 30
@Mutate
@SuppressWarnings("UnusedDeclaration")
public void createTasks(CollectionBuilder<Task> tasks, final @Path("tasks.publish") Task publishLifecycleTask, PublishingExtension publishingExtension) {
    PublicationContainer publications = publishingExtension.getPublications();
    RepositoryHandler repositories = publishingExtension.getRepositories();

    for (final IvyPublicationInternal publication : publications.withType(IvyPublicationInternal.class)) {

        final String publicationName = publication.getName();
        final String descriptorTaskName = String.format("generateDescriptorFileFor%sPublication", capitalize(publicationName));

        tasks.create(descriptorTaskName, GenerateIvyDescriptor.class, new Action<GenerateIvyDescriptor>() {
            public void execute(final GenerateIvyDescriptor descriptorTask) {
                descriptorTask.setDescription(String.format("Generates the Ivy Module Descriptor XML file for publication '%s'.", publication.getName()));
                descriptorTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
                descriptorTask.setDescriptor(publication.getDescriptor());

                ConventionMapping descriptorTaskConventionMapping = new DslObject(descriptorTask).getConventionMapping();
                descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
                    public Object call() throws Exception {
                        return new File(descriptorTask.getProject().getBuildDir(), "publications/" + publication.getName() + "/ivy.xml");
                    }
                });

                publication.setDescriptorFile(descriptorTask.getOutputs().getFiles());
            }
        });

        for (final IvyArtifactRepository repository : repositories.withType(IvyArtifactRepository.class)) {
            final String repositoryName = repository.getName();
            final String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName));

            tasks.create(publishTaskName, PublishToIvyRepository.class, new Action<PublishToIvyRepository>() {
                public void execute(PublishToIvyRepository publishTask) {
                    publishTask.setPublication(publication);
                    publishTask.setRepository(repository);
                    publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
                    publishTask.setDescription(String.format("Publishes Ivy publication '%s' to Ivy repository '%s'.", publicationName, repositoryName));

                    //Because dynamic rules are not yet implemented we have to violate input immutability here as an interim step
                    publishLifecycleTask.dependsOn(publishTask);
                }
            });
        }
    }
}