use of org.gradle.api.internal.artifacts.dependencies.DefaultMutableVersionConstraint in project gradle by gradle.
the class DependencyValueSource method obtain.
@Override
public MinimalExternalModuleDependency obtain() {
DependencyModel data = getParameters().getDependencyData().get();
ImmutableVersionConstraint version = data.getVersion();
return new DefaultMinimalDependency(DefaultModuleIdentifier.newId(data.getGroup(), data.getName()), new DefaultMutableVersionConstraint(version));
}
use of org.gradle.api.internal.artifacts.dependencies.DefaultMutableVersionConstraint in project gradle by gradle.
the class PluginDependencyValueSource method obtain.
@Override
public PluginDependency obtain() {
String pluginName = getParameters().getPluginName().get();
PluginModel data = getParameters().getConfig().get().getPlugin(pluginName);
ImmutableVersionConstraint version = data.getVersion();
return new DefaultPluginDependency(data.getId(), new DefaultMutableVersionConstraint(version));
}
use of org.gradle.api.internal.artifacts.dependencies.DefaultMutableVersionConstraint in project gradle by gradle.
the class DefaultVersionCatalogBuilder method version.
@Override
public String version(String alias, Action<? super MutableVersionConstraint> versionSpec) {
validateAlias(AliasType.VERSION, alias);
alias = intern(normalize(alias));
if (versionConstraints.containsKey(alias)) {
// a platform, we want to silence overrides
return alias;
}
MutableVersionConstraint versionBuilder = new DefaultMutableVersionConstraint("");
versionSpec.execute(versionBuilder);
ImmutableVersionConstraint version = versionConstraintInterner.intern(DefaultImmutableVersionConstraint.of(versionBuilder));
versionConstraints.put(alias, new VersionModel(version, currentContext));
return alias;
}
use of org.gradle.api.internal.artifacts.dependencies.DefaultMutableVersionConstraint in project gradle by gradle.
the class DefaultDependencyResolveDetails method useVersion.
@Override
public void useVersion(String version) {
if (version == null) {
throw new IllegalArgumentException("Configuring the dependency resolve details with 'null' version is not allowed.");
}
useSelector = null;
useVersion = new DefaultMutableVersionConstraint(version);
dirty = true;
}
use of org.gradle.api.internal.artifacts.dependencies.DefaultMutableVersionConstraint in project gradle by gradle.
the class GradlePomModuleDescriptorParser method doParsePom.
private void doParsePom(DescriptorParseContext parserSettings, GradlePomModuleDescriptorBuilder mdBuilder, PomReader pomReader) throws IOException, SAXException {
pomReader.resolveGAV();
String groupId = pomReader.getGroupId();
String artifactId = pomReader.getArtifactId();
String version = pomReader.getVersion();
if (pomReader.hasParent()) {
// Is there any other parent properties?
String parentGroupId = pomReader.getParentGroupId();
String parentArtifactId = pomReader.getParentArtifactId();
String parentVersion = pomReader.getParentVersion();
if (!(Objects.equals(parentGroupId, groupId) && Objects.equals(parentArtifactId, artifactId) && Objects.equals(parentVersion, version))) {
// Only attempt loading the parent if it has different coordinates
ModuleComponentSelector parentId = DefaultModuleComponentSelector.newSelector(DefaultModuleIdentifier.newId(parentGroupId, parentArtifactId), new DefaultImmutableVersionConstraint(parentVersion));
PomReader parentPomReader = parsePomForSelector(parserSettings, parentId, pomReader.getAllPomProperties());
pomReader.setPomParent(parentPomReader);
// Current POM can derive version/artifactId from parent. Resolve GAV and substitute values
pomReader.resolveGAV();
groupId = pomReader.getGroupId();
artifactId = pomReader.getArtifactId();
version = pomReader.getVersion();
}
}
mdBuilder.setModuleRevId(groupId, artifactId, version);
ModuleVersionIdentifier relocation = pomReader.getRelocation();
if (relocation != null) {
if (groupId != null && artifactId != null && artifactId.equals(relocation.getName()) && groupId.equals(relocation.getGroup())) {
LOGGER.error("POM relocation to an other version number is not fully supported in Gradle : {} relocated to {}.", mdBuilder.getComponentIdentifier(), relocation);
LOGGER.warn("Please update your dependency to directly use the correct version '{}'.", relocation);
LOGGER.warn("Resolution will only pick dependencies of the relocated element. Artifacts and other metadata will be ignored.");
PomReader relocatedModule = parsePomForId(parserSettings, DefaultModuleComponentIdentifier.newId(relocation), Maps.newHashMap());
addDependencies(mdBuilder, relocatedModule);
} else {
LOGGER.info(mdBuilder.getComponentIdentifier() + " is relocated to " + relocation + ". Please update your dependencies.");
LOGGER.debug("Relocated module will be considered as a dependency");
ModuleComponentSelector selector = DefaultModuleComponentSelector.newSelector(DefaultModuleIdentifier.newId(relocation.getGroup(), relocation.getName()), new DefaultMutableVersionConstraint(relocation.getVersion()));
mdBuilder.addDependencyForRelocation(selector);
}
} else {
overrideDependencyMgtsWithImported(parserSettings, pomReader);
addDependencies(mdBuilder, pomReader);
}
}
Aggregations