use of org.gradle.api.capabilities.Capability in project gradle by gradle.
the class NodeState method findCapability.
@Nullable
public Capability findCapability(String group, String name) {
Capability onComponent = component.findCapability(group, name);
if (onComponent != null) {
return onComponent;
}
List<? extends Capability> capabilities = metaData.getCapabilities().getCapabilities();
if (!capabilities.isEmpty()) {
// Not required, but Guava's performance bad for an empty immutable list
for (Capability capability : capabilities) {
if (capability.getGroup().equals(group) && capability.getName().equals(name)) {
return capability;
}
}
}
return null;
}
use of org.gradle.api.capabilities.Capability in project gradle by gradle.
the class UpgradeCapabilityResolver method resolve.
@Override
public void resolve(CapabilitiesConflictHandler.ResolutionDetails details) {
Collection<? extends Capability> capabilityVersions = details.getCapabilityVersions();
if (capabilityVersions.size() > 1) {
Set<Capability> sorted = Sets.newTreeSet((o1, o2) -> {
VersionNumber v1 = VersionNumber.parse(o1.getVersion());
VersionNumber v2 = VersionNumber.parse(o2.getVersion());
return v2.compareTo(v1);
});
sorted.addAll(capabilityVersions);
boolean first = true;
for (Capability capability : sorted) {
DisplayName reason = Describables.of("latest version of capability", ((CapabilityInternal) capability).getCapabilityId());
boolean isFirst = first;
details.getCandidates(capability).forEach(cand -> {
cand.byReason(reason);
if (!isFirst) {
cand.evict();
}
});
first = false;
}
}
}
use of org.gradle.api.capabilities.Capability in project gradle by gradle.
the class DependencyManagementBuildScopeServices method createDependencyFactory.
DependencyFactory createDependencyFactory(Instantiator instantiator, DefaultProjectDependencyFactory factory, ClassPathRegistry classPathRegistry, CurrentGradleInstallation currentGradleInstallation, FileCollectionFactory fileCollectionFactory, RuntimeShadedJarFactory runtimeShadedJarFactory, ImmutableAttributesFactory attributesFactory, SimpleMapInterner stringInterner) {
NotationParser<Object, Capability> capabilityNotationParser = new CapabilityNotationParserFactory(false).create();
ProjectDependencyFactory projectDependencyFactory = new ProjectDependencyFactory(factory);
return new DefaultDependencyFactory(DependencyNotationParser.parser(instantiator, factory, classPathRegistry, fileCollectionFactory, runtimeShadedJarFactory, currentGradleInstallation, stringInterner, attributesFactory, capabilityNotationParser), DependencyConstraintNotationParser.parser(instantiator, factory, stringInterner, attributesFactory), new ClientModuleNotationParserFactory(instantiator, stringInterner).create(), capabilityNotationParser, projectDependencyFactory, attributesFactory);
}
use of org.gradle.api.capabilities.Capability in project gradle by gradle.
the class DefaultConfigurationPublications method capability.
@Override
public void capability(Object notation) {
if (canCreate) {
Capability descriptor = capabilityNotationParser.parseNotation(notation);
if (capabilities == null) {
// it's rare that a component would declare more than 1 capability
capabilities = Lists.newArrayListWithExpectedSize(1);
}
capabilities.add(descriptor);
} else {
throw new InvalidUserCodeException("Cannot declare capability '" + notation + "' after dependency " + displayName + " has been resolved");
}
}
use of org.gradle.api.capabilities.Capability in project gradle by gradle.
the class ModuleComponentSelectorSerializer method writeCapabilities.
private void writeCapabilities(Encoder encoder, Collection<Capability> capabilities) throws IOException {
encoder.writeSmallInt(capabilities.size());
for (Capability capability : capabilities) {
encoder.writeString(capability.getGroup());
encoder.writeString(capability.getName());
encoder.writeNullableString(capability.getVersion());
}
}
Aggregations