Search in sources :

Example 1 with ExternalDependency

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

the class DependencyStringNotationConverter method createDependencyFromString.

private T createDependencyFromString(String notation) {
    ParsedModuleStringNotation parsedNotation = splitModuleFromExtension(notation);
    StrictVersionParser.RichVersion version = strictVersionParser.parse(parsedNotation.getVersion());
    T moduleDependency = instantiator.newInstance(wantedType, stringInterner.intern(parsedNotation.getGroup()), stringInterner.intern(parsedNotation.getName()), stringInterner.intern(version.require));
    maybeEnrichVersion(version, moduleDependency);
    if (moduleDependency instanceof ExternalDependency) {
        ModuleFactoryHelper.addExplicitArtifactsIfDefined((ExternalDependency) moduleDependency, parsedNotation.getArtifactType(), parsedNotation.getClassifier());
    }
    return moduleDependency;
}
Also used : ParsedModuleStringNotation(org.gradle.api.internal.artifacts.dsl.ParsedModuleStringNotation) ExternalDependency(org.gradle.api.artifacts.ExternalDependency) StrictVersionParser(org.gradle.api.internal.catalog.parser.StrictVersionParser)

Example 2 with ExternalDependency

use of org.gradle.api.artifacts.ExternalDependency 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()));
            }
        }
    }
}
Also used : ExternalDependency(org.gradle.api.artifacts.ExternalDependency) ModuleDependency(org.gradle.api.artifacts.ModuleDependency) Capability(org.gradle.api.capabilities.Capability) UsageContext(org.gradle.api.internal.component.UsageContext) DependencyConstraint(org.gradle.api.artifacts.DependencyConstraint) DefaultIvyProjectDependency(org.gradle.api.publish.ivy.internal.dependency.DefaultIvyProjectDependency) ProjectDependency(org.gradle.api.artifacts.ProjectDependency)

Aggregations

ExternalDependency (org.gradle.api.artifacts.ExternalDependency)2 DependencyConstraint (org.gradle.api.artifacts.DependencyConstraint)1 ModuleDependency (org.gradle.api.artifacts.ModuleDependency)1 ProjectDependency (org.gradle.api.artifacts.ProjectDependency)1 Capability (org.gradle.api.capabilities.Capability)1 ParsedModuleStringNotation (org.gradle.api.internal.artifacts.dsl.ParsedModuleStringNotation)1 StrictVersionParser (org.gradle.api.internal.catalog.parser.StrictVersionParser)1 UsageContext (org.gradle.api.internal.component.UsageContext)1 DefaultIvyProjectDependency (org.gradle.api.publish.ivy.internal.dependency.DefaultIvyProjectDependency)1