Java Code Examples for org.gradle.api.artifacts.repositories.ArtifactRepository

The following examples show how to use org.gradle.api.artifacts.repositories.ArtifactRepository. 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
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();
}
 
Example 2
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);
            }
        }
    });
}
 
Example 3
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);
            }
        }
    });
}
 
Example 4
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();
}
 
Example 5
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();
}
 
Example 6
private boolean onlyContainsMavenResolvers(Collection<ArtifactRepository> repositories) {
    for (ArtifactRepository repository : repositories) {
        if (!(repository instanceof MavenResolver)) {
            return false;
        }
    }
    return true;
}
 
Example 7
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);
        }
    });
}
 
Example 8
private boolean onlyContainsMavenResolvers(Collection<ArtifactRepository> repositories) {
    for (ArtifactRepository repository : repositories) {
        if (!(repository instanceof MavenResolver)) {
            return false;
        }
    }
    return true;
}
 
Example 9
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);
        }
    });
}
 
Example 10
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;
}
 
Example 11
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;
}
 
Example 12
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;
}
 
Example 13
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;
}
 
Example 14
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);
        }
    });
}
 
Example 15
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);
        }
    });
}
 
Example 16
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);
        }
    });
}
 
Example 17
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;
}
 
Example 18
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;
}
 
Example 19
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;
}
 
Example 20
private Collection<ArtifactRepository> getRepositories(Collection<Upload> tasks) {
    Collection<ArtifactRepository> result = Lists.newArrayList();
    for (Upload task : tasks) {
        result.addAll(task.getRepositories());
    }
    return result;
}
 
Example 21
private boolean onlyContainsMavenResolvers(Collection<ArtifactRepository> repositories) {
    for (ArtifactRepository repository : repositories) {
        if (!(repository instanceof MavenResolver)) {
            return false;
        }
    }
    return true;
}
 
Example 22
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);
            }
        }
    });
}
 
Example 23
protected PublishOperation(Publication publication, ArtifactRepository repository) {
    this.publication = publication;
    this.repository = repository;
}
 
Example 24
public DefaultArtifactRepositoryContainer(BaseRepositoryFactory baseRepositoryFactory, Instantiator instantiator) {
    super(ArtifactRepository.class, instantiator, new RepositoryNamer());
    this.baseRepositoryFactory = baseRepositoryFactory;
}
 
Example 25
public String determineName(ArtifactRepository object) {
    return object.getName();
}
 
Example 26
public void execute(ArtifactRepository repository) {
    DefaultArtifactRepositoryContainer.super.add(repository);
}
 
Example 27
public void addFirst(ArtifactRepository repository) {
    add(0, repository);
}
 
Example 28
public void addLast(ArtifactRepository repository) {
    add(repository);
}
 
Example 29
public <T extends ArtifactRepository> T addRepository(T repository, String defaultName, Action<? super T> configureAction) {
    configureAction.execute(repository);
    return addWithUniqueName(repository, defaultName, addLastAction);
}
 
Example 30
protected PublishOperation(Publication publication, ArtifactRepository repository) {
    this.publication = publication;
    this.repository = repository;
}