Search in sources :

Example 1 with MutableVersionConstraint

use of org.gradle.api.artifacts.MutableVersionConstraint 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 2 with MutableVersionConstraint

use of org.gradle.api.artifacts.MutableVersionConstraint in project gradle by gradle.

the class DependenciesAwareVersionCatalogBuilder method copyDependencyVersion.

private static void copyDependencyVersion(Dependency dependency, String group, String name, MutableVersionConstraint v) {
    if (dependency instanceof ExternalModuleDependency) {
        VersionConstraint vc = ((ExternalModuleDependency) dependency).getVersionConstraint();
        copyConstraint(vc, v);
    } else {
        String version = dependency.getVersion();
        if (version == null || version.isEmpty()) {
            throw new InvalidUserDataException("Version for dependency " + group + ":" + name + " must not be empty");
        }
        v.require(version);
    }
}
Also used : ImmutableVersionConstraint(org.gradle.api.internal.artifacts.ImmutableVersionConstraint) MutableVersionConstraint(org.gradle.api.artifacts.MutableVersionConstraint) VersionConstraint(org.gradle.api.artifacts.VersionConstraint) InvalidUserDataException(org.gradle.api.InvalidUserDataException) ExternalModuleDependency(org.gradle.api.artifacts.ExternalModuleDependency)

Aggregations

MutableVersionConstraint (org.gradle.api.artifacts.MutableVersionConstraint)2 ImmutableVersionConstraint (org.gradle.api.internal.artifacts.ImmutableVersionConstraint)2 InvalidUserDataException (org.gradle.api.InvalidUserDataException)1 ExternalModuleDependency (org.gradle.api.artifacts.ExternalModuleDependency)1 VersionConstraint (org.gradle.api.artifacts.VersionConstraint)1 DefaultImmutableVersionConstraint (org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint)1 DefaultMutableVersionConstraint (org.gradle.api.internal.artifacts.dependencies.DefaultMutableVersionConstraint)1