Search in sources :

Example 1 with DefaultMutableVersionConstraint

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));
}
Also used : ImmutableVersionConstraint(org.gradle.api.internal.artifacts.ImmutableVersionConstraint) DefaultMutableVersionConstraint(org.gradle.api.internal.artifacts.dependencies.DefaultMutableVersionConstraint) DefaultMinimalDependency(org.gradle.api.internal.artifacts.dependencies.DefaultMinimalDependency)

Example 2 with DefaultMutableVersionConstraint

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));
}
Also used : ImmutableVersionConstraint(org.gradle.api.internal.artifacts.ImmutableVersionConstraint) DefaultMutableVersionConstraint(org.gradle.api.internal.artifacts.dependencies.DefaultMutableVersionConstraint) DefaultPluginDependency(org.gradle.api.internal.artifacts.dependencies.DefaultPluginDependency)

Example 3 with DefaultMutableVersionConstraint

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;
}
Also used : DefaultMutableVersionConstraint(org.gradle.api.internal.artifacts.dependencies.DefaultMutableVersionConstraint) MutableVersionConstraint(org.gradle.api.artifacts.MutableVersionConstraint) DefaultMutableVersionConstraint(org.gradle.api.internal.artifacts.dependencies.DefaultMutableVersionConstraint) ImmutableVersionConstraint(org.gradle.api.internal.artifacts.ImmutableVersionConstraint) DefaultImmutableVersionConstraint(org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint)

Example 4 with DefaultMutableVersionConstraint

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;
}
Also used : DefaultMutableVersionConstraint(org.gradle.api.internal.artifacts.dependencies.DefaultMutableVersionConstraint)

Example 5 with DefaultMutableVersionConstraint

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);
    }
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) DefaultImmutableVersionConstraint(org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DefaultModuleComponentSelector(org.gradle.internal.component.external.model.DefaultModuleComponentSelector) DefaultMutableVersionConstraint(org.gradle.api.internal.artifacts.dependencies.DefaultMutableVersionConstraint)

Aggregations

DefaultMutableVersionConstraint (org.gradle.api.internal.artifacts.dependencies.DefaultMutableVersionConstraint)6 ImmutableVersionConstraint (org.gradle.api.internal.artifacts.ImmutableVersionConstraint)3 DefaultImmutableVersionConstraint (org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint)2 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)1 MutableVersionConstraint (org.gradle.api.artifacts.MutableVersionConstraint)1 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)1 DefaultMinimalDependency (org.gradle.api.internal.artifacts.dependencies.DefaultMinimalDependency)1 DefaultPluginDependency (org.gradle.api.internal.artifacts.dependencies.DefaultPluginDependency)1 DefaultModuleComponentSelector (org.gradle.internal.component.external.model.DefaultModuleComponentSelector)1 ModuleDependencyMetadata (org.gradle.internal.component.external.model.ModuleDependencyMetadata)1