Java 类org.gradle.api.artifacts.repositories.ArtifactRepository 实例源码

项目:Reer    文件:ProjectDependencyArtifactIdExtractorHack.java   
public String extract() {
    Collection<Upload> tasks = project.getTasks().withType(Upload.class);
    Collection<ArtifactRepository> repositories = getRepositories(tasks);
    if (!onlyContainsMavenResolvers(repositories)) {
        return project.getName();
    }

    Collection<MavenDeployer> deployers = getMavenDeployers(repositories);
    Set<String> artifactIds = getArtifactIds(deployers);
    if (artifactIds.size() == 1) {
        String artifactId = artifactIds.iterator().next();
        if (artifactId != null && !artifactId.equals(MavenProject.EMPTY_PROJECT_ARTIFACT_ID)) {
            return artifactId;
        }
    }
    String baseName = getArchivesBaseName();
    return baseName != null ? baseName : project.getName();
}
项目:Reer    文件:DefaultMavenPluginRepository.java   
@Override
protected ArtifactRepository internalCreateArtifactRepository(RepositoryHandler repositoryHandler) {
    return repositoryHandler.maven(new Action<MavenArtifactRepository>() {
        @Override
        public void execute(MavenArtifactRepository mavenArtifactRepository) {
            mavenArtifactRepository.setName(getArtifactRepositoryName());
            mavenArtifactRepository.setUrl(getUrl());
            Credentials credentials = authenticationSupport().getConfiguredCredentials();
            if (credentials != null) {
                ((AuthenticationSupportedInternal)mavenArtifactRepository).setConfiguredCredentials(credentials);
                mavenArtifactRepository.authentication(new Action<AuthenticationContainer>() {
                    @Override
                    public void execute(AuthenticationContainer authenticationContainer) {
                        authenticationContainer.addAll(authenticationSupport().getConfiguredAuthentication());
                    }
                });
            }
        }
    });
}
项目:Reer    文件:DefaultIvyPluginRepository.java   
@Override
protected ArtifactRepository internalCreateArtifactRepository(RepositoryHandler repositoryHandler) {
    return repositoryHandler.ivy(new Action<IvyArtifactRepository>() {
        @Override
        public void execute(IvyArtifactRepository ivyArtifactRepository) {
            ivyArtifactRepository.setName(getArtifactRepositoryName());
            ivyArtifactRepository.setUrl(getUrl());
            Credentials credentials = authenticationSupport().getConfiguredCredentials();
            if (credentials != null) {
                ((AuthenticationSupportedInternal)ivyArtifactRepository).setConfiguredCredentials(credentials);
                ivyArtifactRepository.authentication(new Action<AuthenticationContainer>() {
                    @Override
                    public void execute(AuthenticationContainer authenticationContainer) {
                        authenticationContainer.addAll(authenticationSupport().getConfiguredAuthentication());
                    }
                });
            }
        }
    });
}
项目:Pushjet-Android    文件:ProjectDependencyArtifactIdExtractorHack.java   
public String extract() {
    Collection<Upload> tasks = project.getTasks().withType(Upload.class);
    Collection<ArtifactRepository> repositories = getRepositories(tasks);
    if (!onlyContainsMavenResolvers(repositories)) { return project.getName(); }

    Collection<MavenDeployer> deployers = getMavenDeployers(repositories);
    Set<String> artifactIds = getArtifactIds(deployers);
    if (artifactIds.size() == 1) {
        String artifactId = artifactIds.iterator().next();
        if (artifactId != null && !artifactId.equals(MavenProject.EMPTY_PROJECT_ARTIFACT_ID)) {
            return artifactId;
        }
    }
    String baseName = getArchivesBaseName();
    return baseName != null ? baseName : project.getName();
}
项目:Pushjet-Android    文件:ProjectDependencyArtifactIdExtractorHack.java   
public String extract() {
    Collection<Upload> tasks = project.getTasks().withType(Upload.class);
    Collection<ArtifactRepository> repositories = getRepositories(tasks);
    if (!onlyContainsMavenResolvers(repositories)) { return project.getName(); }

    Collection<MavenDeployer> deployers = getMavenDeployers(repositories);
    Set<String> artifactIds = getArtifactIds(deployers);
    if (artifactIds.size() == 1) {
        String artifactId = artifactIds.iterator().next();
        if (artifactId != null && !artifactId.equals(MavenProject.EMPTY_PROJECT_ARTIFACT_ID)) {
            return artifactId;
        }
    }
    String baseName = getArchivesBaseName();
    return baseName != null ? baseName : project.getName();
}
项目:Pushjet-Android    文件:DefaultArtifactRepositoryContainer.java   
public DependencyResolver addAfter(Object userDescription, final String beforeResolverName, Closure configureClosure) {
    if (!GUtil.isTrue(beforeResolverName)) {
        throw new InvalidUserDataException("You must specify beforeResolverName");
    }
    DeprecationLogger.nagUserOfDiscontinuedMethod("ArtifactRepositoryContainer.addAfter()");
    final ArtifactRepository before = getByName(beforeResolverName);

    return addCustomDependencyResolver(userDescription, configureClosure, new Action<ArtifactRepository>() {
        public void execute(ArtifactRepository repository) {
            int insertPos = indexOf(before) + 1;
            if (insertPos == size()) {
                DefaultArtifactRepositoryContainer.super.add(repository);
            } else {
                DefaultArtifactRepositoryContainer.this.add(insertPos, repository);
            }
        }
    });
}
项目:Reer    文件:ProjectDependencyArtifactIdExtractorHack.java   
private Collection<ArtifactRepository> getRepositories(Collection<Upload> tasks) {
    Collection<ArtifactRepository> result = Lists.newArrayList();
    for (Upload task : tasks) {
        result.addAll(task.getRepositories());
    }
    return result;
}
项目:Reer    文件:ProjectDependencyArtifactIdExtractorHack.java   
private boolean onlyContainsMavenResolvers(Collection<ArtifactRepository> repositories) {
    for (ArtifactRepository repository : repositories) {
        if (!(repository instanceof MavenResolver)) {
            return false;
        }
    }
    return true;
}
项目:Reer    文件:ProjectDependencyArtifactIdExtractorHack.java   
private Collection<MavenDeployer> getMavenDeployers(Collection<ArtifactRepository> repositories) {
    Collection<MavenDeployer> result = Lists.newArrayList();
    for (ArtifactRepository repository : repositories) {
        if (repository instanceof MavenDeployer) {
            result.add((MavenDeployer) repository);
        }
    }
    return result;
}
项目:Reer    文件:DefaultGradlePluginPortal.java   
@Override
public ArtifactRepository createArtifactRepository(RepositoryHandler repositoryHandler) {
    return repositoryHandler.maven(new Action<MavenArtifactRepository>() {
        @Override
        public void execute(MavenArtifactRepository mavenArtifactRepository) {
            mavenArtifactRepository.setUrl("https://plugins.gradle.org/m2");
        }
    });
}
项目:Reer    文件:NativeComponentModelPlugin.java   
private DefaultRepositories(final Instantiator instantiator, final SourceDirectorySetFactory sourceDirectorySetFactory, final Action<PrebuiltLibrary> binaryFactory) {
    super(ArtifactRepository.class, instantiator, new ArtifactRepositoryNamer());
    registerFactory(PrebuiltLibraries.class, new NamedDomainObjectFactory<PrebuiltLibraries>() {
        public PrebuiltLibraries create(String name) {
            return instantiator.newInstance(DefaultPrebuiltLibraries.class, name, instantiator, sourceDirectorySetFactory, binaryFactory);
        }
    });
}
项目:Reer    文件:DefaultArtifactRepositoryContainer.java   
public DefaultArtifactRepositoryContainer(Instantiator instantiator) {
    super(ArtifactRepository.class, instantiator, new RepositoryNamer());
    whenObjectAdded(new Action<ArtifactRepository>() {
        public void execute(ArtifactRepository artifactRepository) {
            if (artifactRepository instanceof ArtifactRepositoryInternal) {
                ArtifactRepositoryInternal repository = (ArtifactRepositoryInternal) artifactRepository;
                repository.onAddToContainer(DefaultArtifactRepositoryContainer.this);
            }
        }
    });
}
项目:Reer    文件:DefaultArtifactRepositoryContainer.java   
private <T extends ArtifactRepository> T addWithUniqueName(T repository, String defaultName, Action<? super T> insertion) {
    String repositoryName = repository.getName();
    if (!GUtil.isTrue(repositoryName)) {
        repository.setName(uniquifyName(defaultName));
    } else {
        repository.setName(uniquifyName(repositoryName));
    }

    assertCanAdd(repository.getName());
    insertion.execute(repository);
    return repository;
}
项目:gradle-mobile-plugin    文件:XdepsUtil.java   
public static List<DefaultMavenArtifactRepository> getMavenRepositories(Project project) {
    List<DefaultMavenArtifactRepository> repos = new ArrayList<>();
    PublishingExtension publishingExtension = getPublishingExtension(project);
    if (publishingExtension != null) {
        RepositoryHandler repositoryHandler = publishingExtension.getRepositories();
        for (ArtifactRepository repo : repositoryHandler) {
            repos.add((DefaultMavenArtifactRepository)repo);
        }
    }
    return repos;
}
项目:Pushjet-Android    文件:ProjectDependencyArtifactIdExtractorHack.java   
private Collection<ArtifactRepository> getRepositories(Collection<Upload> tasks) {
    Collection<ArtifactRepository> result = Lists.newArrayList();
    for (Upload task : tasks) {
        result.addAll(task.getRepositories());
    }
    return result;
}
项目:Pushjet-Android    文件:ProjectDependencyArtifactIdExtractorHack.java   
private boolean onlyContainsMavenResolvers(Collection<ArtifactRepository> repositories) {
    for (ArtifactRepository repository : repositories) {
        if (!(repository instanceof MavenResolver)) {
            return false;
        }
    }
    return true;
}
项目:Pushjet-Android    文件:ProjectDependencyArtifactIdExtractorHack.java   
private Collection<MavenDeployer> getMavenDeployers(Collection<ArtifactRepository> repositories) {
    Collection<MavenDeployer> result = Lists.newArrayList();
    for (ArtifactRepository repository : repositories) {
        if (repository instanceof MavenDeployer) {
            result.add((MavenDeployer) repository);
        }
    }
    return result;
}
项目:Pushjet-Android    文件:NativeComponentModelPlugin.java   
private DefaultRepositories(final Instantiator instantiator, final FileResolver fileResolver, final Action<PrebuiltLibrary> binaryFactory) {
    super(ArtifactRepository.class, instantiator, new ArtifactRepositoryNamer());
    registerFactory(PrebuiltLibraries.class, new NamedDomainObjectFactory<PrebuiltLibraries>() {
        public PrebuiltLibraries create(String name) {
            return instantiator.newInstance(DefaultPrebuiltLibraries.class, name, instantiator, fileResolver, binaryFactory);
        }
    });
}
项目:Pushjet-Android    文件:DefaultArtifactRepositoryContainer.java   
public DefaultArtifactRepositoryContainer(Instantiator instantiator) {
    super(ArtifactRepository.class, instantiator, new RepositoryNamer());
    whenObjectAdded(new Action<ArtifactRepository>() {
        public void execute(ArtifactRepository artifactRepository) {
            if (artifactRepository instanceof ArtifactRepositoryInternal) {
                ArtifactRepositoryInternal repository = (ArtifactRepositoryInternal) artifactRepository;
                repository.onAddToContainer(DefaultArtifactRepositoryContainer.this);
            }
        }
    });
}
项目:Pushjet-Android    文件:DefaultArtifactRepositoryContainer.java   
private <T extends ArtifactRepository> T addWithUniqueName(T repository, String defaultName, Action<? super T> insertion) {
    String repositoryName = repository.getName();
    if (!GUtil.isTrue(repositoryName)) {
        repository.setName(uniquifyName(defaultName));
    } else {
        repository.setName(uniquifyName(repositoryName));
    }

    assertCanAdd(repository.getName());
    insertion.execute(repository);
    return repository;
}
项目:Pushjet-Android    文件:ProjectDependencyArtifactIdExtractorHack.java   
private Collection<ArtifactRepository> getRepositories(Collection<Upload> tasks) {
    Collection<ArtifactRepository> result = Lists.newArrayList();
    for (Upload task : tasks) {
        result.addAll(task.getRepositories());
    }
    return result;
}
项目:Pushjet-Android    文件:ProjectDependencyArtifactIdExtractorHack.java   
private boolean onlyContainsMavenResolvers(Collection<ArtifactRepository> repositories) {
    for (ArtifactRepository repository : repositories) {
        if (!(repository instanceof MavenResolver)) {
            return false;
        }
    }
    return true;
}
项目:Pushjet-Android    文件:ProjectDependencyArtifactIdExtractorHack.java   
private Collection<MavenDeployer> getMavenDeployers(Collection<ArtifactRepository> repositories) {
    Collection<MavenDeployer> result = Lists.newArrayList();
    for (ArtifactRepository repository : repositories) {
        if (repository instanceof MavenDeployer) {
            result.add((MavenDeployer) repository);
        }
    }
    return result;
}
项目:Pushjet-Android    文件:RepositoriesFactory.java   
private DefaultRepositories(final Instantiator instantiator, final FileResolver fileResolver, final Action<PrebuiltLibrary> binaryFactory) {
    super(ArtifactRepository.class, instantiator, new ArtifactRepositoryNamer());
    registerFactory(PrebuiltLibraries.class, new NamedDomainObjectFactory<PrebuiltLibraries>() {
        public PrebuiltLibraries create(String name) {
            return instantiator.newInstance(DefaultPrebuiltLibraries.class, name, instantiator, fileResolver, binaryFactory);
        }
    });
}
项目:Pushjet-Android    文件:DefaultArtifactRepositoryContainer.java   
public DependencyResolver addBefore(Object userDescription, final String afterResolverName, Closure configureClosure) {
    if (!GUtil.isTrue(afterResolverName)) {
        throw new InvalidUserDataException("You must specify afterResolverName");
    }
    DeprecationLogger.nagUserOfDiscontinuedMethod("ArtifactRepositoryContainer.addBefore()");
    final ArtifactRepository after = getByName(afterResolverName);
    return addCustomDependencyResolver(userDescription, configureClosure, new Action<ArtifactRepository>() {
        public void execute(ArtifactRepository repository) {
            DefaultArtifactRepositoryContainer.super.add(indexOf(after), repository);
        }
    });
}
项目:Pushjet-Android    文件:DefaultArtifactRepositoryContainer.java   
private DependencyResolver addCustomDependencyResolver(Object userDescription, Closure configureClosure, Action<ArtifactRepository> orderAction) {
    ArtifactRepository repository = baseRepositoryFactory.createRepository(userDescription);
    DependencyResolver resolver = baseRepositoryFactory.toResolver(repository);
    ConfigureUtil.configure(configureClosure, resolver);
    ArtifactRepository resolverRepository = baseRepositoryFactory.createResolverBackedRepository(resolver);
    addWithUniqueName(resolverRepository, "repository", orderAction);
    return resolver;
}
项目:Pushjet-Android    文件:DefaultArtifactRepositoryContainer.java   
public List<DependencyResolver> getResolvers() {
    DeprecationLogger.nagUserOfDiscontinuedMethod("ArtifactRepositoryContainer.getResolvers()");
    List<DependencyResolver> returnedResolvers = new ArrayList<DependencyResolver>();
    for (ArtifactRepository repository : this) {
        returnedResolvers.add(baseRepositoryFactory.toResolver(repository));
    }
    return returnedResolvers;
}
项目:Pushjet-Android    文件:DefaultArtifactRepositoryContainer.java   
private <T extends ArtifactRepository> T addWithUniqueName(T repository, String defaultName, Action<? super T> insertion) {
    String repositoryName = repository.getName();
    if (!GUtil.isTrue(repositoryName)) {
        repository.setName(uniquifyName(defaultName));
    } else {
        repository.setName(uniquifyName(repositoryName));
    }

    assertCanAdd(repository.getName());
    insertion.execute(repository);
    cast(ArtifactRepositoryInternal.class, repository).onAddToContainer(this);
    return repository;
}
项目:aether-gradle-plugin    文件:VersionResolverDependencyResolveDetails.java   
@Override
public void execute(DependencyResolveDetails dependencyResolveDetails) {
    String group = dependencyResolveDetails.getTarget().getGroup();
    String name = dependencyResolveDetails.getTarget().getName();
    if (aetherPlugin.getVersionMap().containsKey(group) && aetherPlugin.getVersionMap().get(group).containsKey(name)) {
        if (dependencyResolveDetails.getRequested().getVersion().equals(dependencyResolveDetails.getTarget().getVersion())) {
            dependencyResolveDetails.useVersion(aetherPlugin.getVersionMap().get(group).get(name));
        }
    } else {
        RepositorySystem system = setupRepositorySystem();
        RepositorySystemSession session = setupSession(project, system);
        List<RemoteRepository> remoteRepositories = new ArrayList<>();
        for (ArtifactRepository artifactRepository : project.getRepositories()) {
            if (artifactRepository instanceof MavenArtifactRepository) {
                MavenArtifactRepository mavenArtifactRepository = (MavenArtifactRepository) artifactRepository;
                remoteRepositories.add(new RemoteRepository.Builder(mavenArtifactRepository.getName(), "default", mavenArtifactRepository.getUrl().toString()).build());
            }
        }
        Artifact artifact = new DefaultArtifact(dependencyResolveDetails.getTarget().getGroup()
                + ":" + dependencyResolveDetails.getTarget().getName()
                + ":" + dependencyResolveDetails.getTarget().getVersion());

        CollectRequest collectRequest = new CollectRequest();
        String scope;
        if (configuration.getName().contains("test")) {
            scope = JavaScopes.TEST;
        } else if (configuration.getName().contains("runtime")) {
            scope = JavaScopes.RUNTIME;
        } else if (configuration.getName().equals("providedCompile")
                || configuration.getName().equals("compileOnly")) {
            scope = JavaScopes.PROVIDED;
        } else
            scope = JavaScopes.COMPILE;
        collectRequest.setRoot(new Dependency(artifact, scope));
        collectRequest.setRepositories(remoteRepositories);

        try {
            CollectResult collectResult = system.collectDependencies(session, collectRequest);
            processDependencyNode(collectResult.getRoot());
        } catch (DependencyCollectionException e) {
            e.printStackTrace();
        }
    }
}
项目:Reer    文件:JavaScriptRepositoriesExtension.java   
public ArtifactRepository gradle() {
    return gradle(Actions.doNothing());
}
项目:Reer    文件:AbstractPluginRepository.java   
@Override
public ArtifactRepository createArtifactRepository(RepositoryHandler repositoryHandler) {
    ArtifactRepository repo = internalCreateArtifactRepository(repositoryHandler);
    hasYieldedArtifactRepository.set(true);
    return repo;
}
项目:Reer    文件:AbstractArtifactRepository.java   
public void onAddToContainer(NamedDomainObjectCollection<ArtifactRepository> container) {
    isPartOfContainer = true;
}
项目:Reer    文件:NativeComponentModelPlugin.java   
@Override
public String determineName(ArtifactRepository object) {
    return object.getName();
}
项目:Reer    文件:DefaultArtifactRepositoryContainer.java   
public void execute(ArtifactRepository repository) {
    DefaultArtifactRepositoryContainer.super.add(repository);
}
项目:Reer    文件:DefaultArtifactRepositoryContainer.java   
public String determineName(ArtifactRepository r) {
    return r.getName();
}
项目:Reer    文件:DefaultArtifactRepositoryContainer.java   
public void addFirst(ArtifactRepository repository) {
    add(0, repository);
}
项目:Reer    文件:DefaultArtifactRepositoryContainer.java   
public void addLast(ArtifactRepository repository) {
    add(repository);
}
项目:Reer    文件:DefaultArtifactRepositoryContainer.java   
public <T extends ArtifactRepository> T addRepository(T repository, String defaultName) {
    return addRepository(repository, defaultName, Actions.doNothing());
}
项目:Reer    文件:DefaultArtifactRepositoryContainer.java   
public <T extends ArtifactRepository> T addRepository(T repository, String defaultName, Action<? super T> configureAction) {
    configureAction.execute(repository);
    return addWithUniqueName(repository, defaultName, addLastAction);
}
项目:srcdeps-gradle-plugin    文件:Wiring.java   
/**
 * Performs the wiring for the given Gradle {@link Project}.
 *
 * @param project
 */
public static void init(final Project project) {

    final Path srcdepsYamlPath = project.getRootDir().toPath().resolve("srcdeps.yaml");

    Gradle gradle = project.getGradle();
    if (!(gradle instanceof GradleInternal)) {
        throw new RuntimeException(String.format("Expected %s, but found %s", GradleInternal.class.getName(),
                gradle.getClass().getName()));
    }

    ServiceRegistry services = ((GradleInternal) gradle).getServices();
    if (!(services instanceof DefaultServiceRegistry)) {
        throw new RuntimeException(String.format("Expected %s, but found %s",
                DefaultServiceRegistry.class.getName(), services.getClass().getName()));
    }

    ArtifactRepository repo = project.getRepositories()
            .findByName(org.gradle.api.artifacts.ArtifactRepositoryContainer.DEFAULT_MAVEN_LOCAL_REPO_NAME);
    if (!(repo instanceof MavenArtifactRepository)) {
        throw new RuntimeException(
                String.format("Expected %s, but found %s", MavenArtifactRepository.class.getName(), repo));
    }
    final MavenLocalRepository localRepository = new MavenLocalRepository(Paths.get(((MavenArtifactRepository) repo).getUrl()));

    final Path scrdepsDir = localRepository.getRootDirectory().getParent().resolve("srcdeps");
    final PathLocker<SrcVersion> pathLocker = new PathLocker<>();
    final BuildDirectoriesManager buildDirectoriesManager = new BuildDirectoriesManager(scrdepsDir, pathLocker);

    ClassLoader classloader = Wiring.class.getClassLoader();
    final Module spaceModule = new SpaceModule(new URLClassSpace(classloader));
    Module wrappedWiremodule = new Module() {
        @Override
        public void configure(Binder binder) {

            spaceModule.configure(binder);

            binder.bind(Path.class).annotatedWith(Names.named(ConfigurationService.SRCDEPS_YAML_PATH))
                    .toInstance(srcdepsYamlPath);
            binder.bind(MavenLocalRepository.class).toInstance(localRepository);
            binder.bind(new TypeLiteral<PathLocker<SrcVersion>>() {
            }).toInstance(pathLocker);
            binder.bind(BuildDirectoriesManager.class).toInstance(buildDirectoriesManager);
        }
    };
    final Module wireModule = new WireModule(wrappedWiremodule);
    injector = Guice.createInjector(wireModule);
}