use of org.gradle.api.artifacts.Dependency in project gradle by gradle.
the class CoffeeScriptBasePlugin method addJsConfiguration.
private Configuration addJsConfiguration(ConfigurationContainer configurations, final DependencyHandler dependencies, final CoffeeScriptExtension extension) {
Configuration configuration = configurations.create(CoffeeScriptExtension.JS_CONFIGURATION_NAME);
configuration.defaultDependencies(new Action<DependencySet>() {
@Override
public void execute(DependencySet configDependencies) {
String notation = CoffeeScriptExtension.DEFAULT_JS_DEPENDENCY_GROUP + ":" + CoffeeScriptExtension.DEFAULT_JS_DEPENDENCY_MODULE + ":" + extension.getVersion() + "@js";
Dependency dependency = dependencies.create(notation);
configDependencies.add(dependency);
}
});
return configuration;
}
use of org.gradle.api.artifacts.Dependency 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.Dependency in project gradle by gradle.
the class DefaultConfiguration method registerWatchPoints.
@Override
public void registerWatchPoints(FileSystemSubset.Builder builder) {
for (Dependency dependency : allDependencies) {
if (dependency instanceof FileCollectionDependency) {
FileCollection files = ((FileCollectionDependency) dependency).getFiles();
((FileCollectionInternal) files).registerWatchPoints(builder);
}
}
super.registerWatchPoints(builder);
}
use of org.gradle.api.artifacts.Dependency in project gradle by gradle.
the class DefaultConfiguration method dump.
/**
* Print a formatted representation of a Configuration
*/
public String dump() {
StringBuilder reply = new StringBuilder();
reply.append("\nConfiguration:");
reply.append(" class='" + this.getClass() + "'");
reply.append(" name='" + this.getName() + "'");
reply.append(" hashcode='" + this.hashCode() + "'");
reply.append("\nLocal Dependencies:");
if (getDependencies().size() > 0) {
for (Dependency d : getDependencies()) {
reply.append("\n " + d);
}
} else {
reply.append("\n none");
}
reply.append("\nLocal Artifacts:");
if (getArtifacts().size() > 0) {
for (PublishArtifact a : getArtifacts()) {
reply.append("\n " + a);
}
} else {
reply.append("\n none");
}
reply.append("\nAll Dependencies:");
if (getAllDependencies().size() > 0) {
for (Dependency d : getAllDependencies()) {
reply.append("\n " + d);
}
} else {
reply.append("\n none");
}
reply.append("\nAll Artifacts:");
if (getAllArtifacts().size() > 0) {
for (PublishArtifact a : getAllArtifacts()) {
reply.append("\n " + a);
}
} else {
reply.append("\n none");
}
return reply.toString();
}
use of org.gradle.api.artifacts.Dependency in project gradle by gradle.
the class UnresolvableConfigurationResult method getChildren.
@Override
public Set<? extends RenderableDependency> getChildren() {
final DependencySet dependencies = configuration.getDependencies();
if (dependencies.isEmpty()) {
return Collections.emptySet();
}
Set<RenderableDependency> children = Sets.newLinkedHashSet();
for (final Dependency dependency : dependencies) {
children.add(new RenderableDependency() {
@Override
public Object getId() {
return dependency;
}
@Override
public String getName() {
String label;
if (dependency instanceof ProjectDependency) {
label = "project " + dependency.getName();
} else {
label = Joiner.on(":").join(Iterables.filter(Arrays.asList(dependency.getGroup(), dependency.getName(), dependency.getVersion()), Predicates.<String>notNull()));
}
return label;
}
@Override
public String getDescription() {
return null;
}
@Override
public ResolutionState getResolutionState() {
return ResolutionState.UNRESOLVED;
}
@Override
public Set<? extends RenderableDependency> getChildren() {
return Collections.emptySet();
}
});
}
return children;
}
Aggregations