use of org.gradle.api.artifacts.Configuration in project gradle by gradle.
the class DefaultConfiguration method createCopy.
private DefaultConfiguration createCopy(Set<Dependency> dependencies, boolean recursive) {
DetachedConfigurationsProvider configurationsProvider = new DetachedConfigurationsProvider();
String newName = name + "Copy";
Path newIdentityPath = identityPath.getParent().child(newName);
Path newPath = path.getParent().child(newName);
Factory<ResolutionStrategyInternal> childResolutionStrategy = resolutionStrategy != null ? Factories.constant(resolutionStrategy.copy()) : resolutionStrategyFactory;
DefaultConfiguration copiedConfiguration = instantiator.newInstance(DefaultConfiguration.class, newIdentityPath, newPath, newName, configurationsProvider, resolver, listenerManager, metaDataProvider, childResolutionStrategy, projectAccessListener, projectFinder, configurationComponentMetaDataBuilder, fileCollectionFactory, componentIdentifierFactory, buildOperationExecutor, instantiator, artifactNotationParser, attributesFactory, moduleIdentifierFactory);
configurationsProvider.setTheOnlyConfiguration(copiedConfiguration);
// state, cachedResolvedConfiguration, and extendsFrom intentionally not copied - must re-resolve copy
// copying extendsFrom could mess up dependencies when copy was re-resolved
copiedConfiguration.visible = visible;
copiedConfiguration.transitive = transitive;
copiedConfiguration.description = description;
copiedConfiguration.defaultDependencyActions = defaultDependencyActions;
copiedConfiguration.canBeConsumed = canBeConsumed;
copiedConfiguration.canBeResolved = canBeResolved;
copiedConfiguration.getArtifacts().addAll(getAllArtifacts());
if (!configurationAttributes.isEmpty()) {
for (Attribute<?> attribute : configurationAttributes.keySet()) {
Object value = configurationAttributes.getAttribute(attribute);
copiedConfiguration.getAttributes().attribute(Cast.<Attribute<Object>>uncheckedCast(attribute), value);
}
}
// todo An ExcludeRule is a value object but we don't enforce immutability for DefaultExcludeRule as strong as we
// should (we expose the Map). We should provide a better API for ExcludeRule (I don't want to use unmodifiable Map).
// As soon as DefaultExcludeRule is truly immutable, we don't need to create a new instance of DefaultExcludeRule.
Set<Configuration> excludeRuleSources = new LinkedHashSet<Configuration>();
excludeRuleSources.add(this);
if (recursive) {
excludeRuleSources.addAll(getHierarchy());
}
for (Configuration excludeRuleSource : excludeRuleSources) {
for (ExcludeRule excludeRule : excludeRuleSource.getExcludeRules()) {
copiedConfiguration.excludeRules.add(new DefaultExcludeRule(excludeRule.getGroup(), excludeRule.getModule()));
}
}
DomainObjectSet<Dependency> copiedDependencies = copiedConfiguration.getDependencies();
for (Dependency dependency : dependencies) {
copiedDependencies.add(dependency.copy());
}
return copiedConfiguration;
}
use of org.gradle.api.artifacts.Configuration in project gradle by gradle.
the class IdeaDependenciesProvider method getProjectDependencies.
private Set<Dependency> getProjectDependencies(IdeaModule ideaModule, GeneratedIdeaScope scope) {
Collection<Configuration> plusConfigurations = getPlusConfigurations(ideaModule, scope);
Collection<Configuration> minusConfigurations = getMinusConfigurations(ideaModule, scope);
Collection<IdeProjectDependency> extractedDependencies = dependenciesExtractor.extractProjectDependencies(ideaModule.getProject(), plusConfigurations, minusConfigurations);
Set<Dependency> dependencies = Sets.newLinkedHashSet();
for (IdeProjectDependency ideProjectDependency : extractedDependencies) {
dependencies.add(moduleDependencyBuilder.create(ideProjectDependency, scope.name()));
}
return dependencies;
}
use of org.gradle.api.artifacts.Configuration in project gradle by gradle.
the class IdeaDependenciesProvider method getExternalDependencies.
private Set<Dependency> getExternalDependencies(IdeaModule ideaModule, GeneratedIdeaScope scope) {
if (ideaModule.isOffline()) {
return Collections.emptySet();
}
Collection<Configuration> plusConfigurations = getPlusConfigurations(ideaModule, scope);
Collection<Configuration> minusConfigurations = getMinusConfigurations(ideaModule, scope);
Set<Dependency> dependencies = Sets.newLinkedHashSet();
Collection<IdeExtendedRepoFileDependency> ideRepoFileDependencies = dependenciesExtractor.extractRepoFileDependencies(ideaModule.getProject().getDependencies(), plusConfigurations, minusConfigurations, ideaModule.isDownloadSources(), ideaModule.isDownloadJavadoc());
for (IdeExtendedRepoFileDependency dependency : ideRepoFileDependencies) {
dependencies.add(toLibraryDependency(dependency, ideaModule, scope));
}
return dependencies;
}
use of org.gradle.api.artifacts.Configuration in project gradle by gradle.
the class MavenPlugin method configureInstall.
private void configureInstall(Project project) {
Upload installUpload = project.getTasks().create(INSTALL_TASK_NAME, Upload.class);
Configuration configuration = project.getConfigurations().getByName(Dependency.ARCHIVES_CONFIGURATION);
installUpload.setConfiguration(configuration);
MavenRepositoryHandlerConvention repositories = new DslObject(installUpload.getRepositories()).getConvention().getPlugin(MavenRepositoryHandlerConvention.class);
repositories.mavenInstaller();
installUpload.setDescription("Installs the 'archives' artifacts into the local Maven repository.");
}
use of org.gradle.api.artifacts.Configuration in project gradle by gradle.
the class DefaultConf2ScopeMappingContainerTest method createTestMappings.
private Map<Configuration, Conf2ScopeMapping> createTestMappings() {
Map<Configuration, Conf2ScopeMapping> testMappings = new HashMap<Configuration, Conf2ScopeMapping>() {
{
Configuration configuration = context.mock(Configuration.class);
put(configuration, new Conf2ScopeMapping(10, configuration, "scope"));
}
};
return testMappings;
}
Aggregations