use of org.gradle.api.artifacts.ModuleDependency in project gradle by gradle.
the class DefaultIvyPublication method populateDependencies.
private void populateDependencies(Set<? extends UsageContext> usageContexts, PublicationWarningsCollector publicationWarningsCollector) {
for (UsageContext usageContext : usageContexts) {
publicationWarningsCollector.newContext(usageContext.getName());
for (ModuleDependency dependency : usageContext.getDependencies()) {
String confMapping = confMappingFor(usageContext, dependency);
if (!dependency.getAttributes().isEmpty()) {
publicationWarningsCollector.addUnsupported(String.format("%s:%s:%s declared with Gradle attributes", dependency.getGroup(), dependency.getName(), dependency.getVersion()));
}
if (dependency instanceof ProjectDependency) {
addProjectDependency((ProjectDependency) dependency, confMapping);
} else {
ExternalDependency externalDependency = (ExternalDependency) dependency;
if (platformSupport.isTargetingPlatform(dependency)) {
publicationWarningsCollector.addUnsupported(String.format("%s:%s:%s declared as platform", dependency.getGroup(), dependency.getName(), dependency.getVersion()));
}
if (!versionMappingInUse && externalDependency.getVersion() == null) {
publicationWarningsCollector.addUnsupported(String.format("%s:%s declared without version", externalDependency.getGroup(), externalDependency.getName()));
}
addExternalDependency(externalDependency, confMapping, ((AttributeContainerInternal) usageContext.getAttributes()).asImmutable());
}
}
if (!usageContext.getDependencyConstraints().isEmpty()) {
for (DependencyConstraint constraint : usageContext.getDependencyConstraints()) {
publicationWarningsCollector.addUnsupported(String.format("%s:%s:%s declared as a dependency constraint", constraint.getGroup(), constraint.getName(), constraint.getVersion()));
}
}
if (!usageContext.getCapabilities().isEmpty()) {
for (Capability capability : usageContext.getCapabilities()) {
publicationWarningsCollector.addVariantUnsupported(String.format("Declares capability %s:%s:%s which cannot be mapped to Ivy", capability.getGroup(), capability.getName(), capability.getVersion()));
}
}
}
}
use of org.gradle.api.artifacts.ModuleDependency in project gradle by gradle.
the class DefaultDependencyHandler method testFixtures.
@Override
public Dependency testFixtures(Object notation) {
Dependency testFixturesDependency = create(notation);
if (testFixturesDependency instanceof ProjectDependency) {
ProjectDependency projectDependency = (ProjectDependency) testFixturesDependency;
projectDependency.capabilities(new ProjectTestFixtures(projectDependency.getDependencyProject()));
} else if (testFixturesDependency instanceof ModuleDependency) {
ModuleDependency moduleDependency = (ModuleDependency) testFixturesDependency;
moduleDependency.capabilities(capabilities -> capabilities.requireCapability(new ImmutableCapability(moduleDependency.getGroup(), moduleDependency.getName() + TEST_FIXTURES_CAPABILITY_APPENDIX, null)));
}
return testFixturesDependency;
}
use of org.gradle.api.artifacts.ModuleDependency in project gradle by gradle.
the class DefaultDependencyHandler method platform.
@Override
public Dependency platform(Object notation) {
Dependency dependency = create(notation);
if (dependency instanceof ModuleDependency) {
ModuleDependency moduleDependency = (ModuleDependency) dependency;
moduleDependency.endorseStrictVersions();
platformSupport.addPlatformAttribute(moduleDependency, toCategory(Category.REGULAR_PLATFORM));
} else if (dependency instanceof HasConfigurableAttributes) {
platformSupport.addPlatformAttribute((HasConfigurableAttributes<?>) dependency, toCategory(Category.REGULAR_PLATFORM));
}
return dependency;
}
use of org.gradle.api.artifacts.ModuleDependency in project gradle by gradle.
the class ModuleFactoryDelegate method dependency.
@SuppressWarnings("rawtypes")
public void dependency(Object dependencyNotation, Closure configureClosure) {
Dependency dependency = dependencyFactory.createDependency(dependencyNotation);
clientModule.addDependency((ModuleDependency) dependency);
ConfigureUtil.configure(configureClosure, dependency);
}
use of org.gradle.api.artifacts.ModuleDependency in project gradle by gradle.
the class TransientConfigurationResultsBuilder method deserialize.
private TransientConfigurationResults deserialize(Decoder decoder, ResolvedGraphResults graphResults, SelectedArtifactResults artifactResults) {
Timer clock = Timers.startTimer();
Map<Long, DefaultResolvedDependency> allDependencies = new HashMap<Long, DefaultResolvedDependency>();
Map<ModuleDependency, DependencyGraphNodeResult> firstLevelDependencies = new LinkedHashMap<ModuleDependency, DependencyGraphNodeResult>();
DependencyGraphNodeResult root;
int valuesRead = 0;
byte type = -1;
try {
while (true) {
type = decoder.readByte();
long id;
valuesRead++;
switch(type) {
case NEW_DEP:
id = decoder.readSmallLong();
ResolvedConfigurationIdentifier details = resolvedConfigurationIdentifierSerializer.read(decoder);
allDependencies.put(id, new DefaultResolvedDependency(id, details));
break;
case ROOT:
id = decoder.readSmallLong();
root = allDependencies.get(id);
if (root == null) {
throw new IllegalStateException(String.format("Unexpected root id %s. Seen ids: %s", id, allDependencies.keySet()));
}
//root should be the last entry
LOG.debug("Loaded resolved configuration results ({}) from {}", clock.getElapsed(), binaryStore);
return new DefaultTransientConfigurationResults(root, firstLevelDependencies);
case FIRST_LVL:
id = decoder.readSmallLong();
DefaultResolvedDependency dependency = allDependencies.get(id);
if (dependency == null) {
throw new IllegalStateException(String.format("Unexpected first level id %s. Seen ids: %s", id, allDependencies.keySet()));
}
firstLevelDependencies.put(graphResults.getModuleDependency(id), dependency);
break;
case PARENT_CHILD:
long parentId = decoder.readSmallLong();
long childId = decoder.readSmallLong();
DefaultResolvedDependency parent = allDependencies.get(parentId);
DefaultResolvedDependency child = allDependencies.get(childId);
if (parent == null) {
throw new IllegalStateException(String.format("Unexpected parent dependency id %s. Seen ids: %s", parentId, allDependencies.keySet()));
}
if (child == null) {
throw new IllegalStateException(String.format("Unexpected child dependency id %s. Seen ids: %s", childId, allDependencies.keySet()));
}
parent.addChild(child);
child.addParentSpecificArtifacts(parent, artifactResults.getArtifacts(decoder.readSmallLong()));
break;
default:
throw new IOException("Unknown value type read from stream: " + type);
}
}
} catch (IOException e) {
throw new RuntimeException("Problems loading the resolved configuration. Read " + valuesRead + " values, last was: " + type, e);
}
}
Aggregations