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

The following examples show how to use org.gradle.api.artifacts.dsl.RepositoryHandler. 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
Source File: PluginResolutionServiceResolver.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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
Source File: PluginResolutionServiceResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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
Source File: ModuleMappingPluginResolver.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #4
Source File: DefaultArtifactResolutionQuery.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #5
Source File: DefaultArtifactResolutionQueryFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #6
Source File: DefaultArtifactResolutionQueryFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #7
Source File: DefaultArtifactResolutionQuery.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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
Source File: DefaultArtifactResolutionQuery.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #9
Source File: DefaultScriptHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #10
Source File: IvyPublicationTasksModelRule.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #11
Source File: DefaultScriptHandlerFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #12
Source File: DefaultScriptHandlerFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #13
Source File: PublishingPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #14
Source File: Upload.java    From pushfish-android with 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 #15
Source File: MavenPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #16
Source File: IvyPublicationTasksModelRule.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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
Source File: DefaultScriptHandlerFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #18
Source File: AbstractScriptHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #19
Source File: DefaultArtifactResolutionQueryFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #20
Source File: DefaultArtifactResolutionQuery.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #21
Source File: DefaultScriptHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #22
Source File: MavenPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #23
Source File: AbstractScriptHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #24
Source File: MavenPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #25
Source File: DefaultScriptHandlerFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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
Source File: AbstractProject.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public RepositoryHandler getRepositories() {
    return repositoryHandler;
}
 
Example #27
Source File: DefaultDependencyManagementServices.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public RepositoryHandler getResolveRepositoryHandler() {
    return services.get(RepositoryHandler.class);
}
 
Example #28
Source File: DefaultScriptHandler.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public RepositoryHandler getRepositories() {
    return repositoryHandler;
}
 
Example #29
Source File: DefaultPublishingExtension.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void repositories(Action<? super RepositoryHandler> configure) {
    configure.execute(repositories);
}
 
Example #30
Source File: AbstractScriptHandler.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public RepositoryHandler getRepositories() {
    return repositoryHandler;
}