Search in sources :

Example 1 with MavenDependencyDescriptor

use of org.gradle.internal.component.external.model.maven.MavenDependencyDescriptor in project gradle by gradle.

the class ModuleComponentResolveMetadataSerializer method read.

@Override
public ModuleComponentResolveMetadata read(Decoder decoder) throws EOFException, Exception {
    Map<Integer, MavenDependencyDescriptor> deduplicationDependencyCache = Maps.newHashMap();
    MutableModuleComponentResolveMetadata mutable = delegate.read(decoder, moduleIdentifierFactory, deduplicationDependencyCache);
    readPlatformOwners(decoder, mutable);
    AbstractLazyModuleComponentResolveMetadata resolveMetadata = (AbstractLazyModuleComponentResolveMetadata) mutable.asImmutable();
    if (resolveMetadata instanceof DefaultIvyModuleResolveMetadata) {
        return ivySerializationHelper.readMetadata(decoder, (DefaultIvyModuleResolveMetadata) resolveMetadata);
    } else if (resolveMetadata instanceof DefaultMavenModuleResolveMetadata) {
        return mavenSerializationHelper.readMetadata(decoder, (DefaultMavenModuleResolveMetadata) resolveMetadata, deduplicationDependencyCache);
    } else {
        throw new IllegalStateException("Unknown resolved metadata type: " + resolveMetadata.getClass());
    }
}
Also used : MutableModuleComponentResolveMetadata(org.gradle.internal.component.external.model.MutableModuleComponentResolveMetadata) DefaultIvyModuleResolveMetadata(org.gradle.internal.component.external.model.ivy.DefaultIvyModuleResolveMetadata) MavenDependencyDescriptor(org.gradle.internal.component.external.model.maven.MavenDependencyDescriptor) DefaultMavenModuleResolveMetadata(org.gradle.internal.component.external.model.maven.DefaultMavenModuleResolveMetadata) AbstractLazyModuleComponentResolveMetadata(org.gradle.internal.component.external.model.AbstractLazyModuleComponentResolveMetadata)

Example 2 with MavenDependencyDescriptor

use of org.gradle.internal.component.external.model.maven.MavenDependencyDescriptor in project gradle by gradle.

the class GradlePomModuleDescriptorBuilder method doAddDependency.

private void doAddDependency(PomDependencyMgt dep, MavenDependencyType dependencyType) {
    MavenScope scope;
    if (dependencyType == MavenDependencyType.DEPENDENCY_MANAGEMENT) {
        scope = MavenScope.Compile;
    } else {
        String scopeString = dep.getScope();
        if (scopeString == null || scopeString.length() == 0) {
            scopeString = getDefaultScope(dep);
        }
        // unknown scope, defaulting to 'compile'
        scope = SCOPES.getOrDefault(scopeString, MavenScope.Compile);
    }
    String version = determineVersion(dep);
    String mappedVersion = convertVersionFromMavenSyntax(version);
    ModuleComponentSelector selector = DefaultModuleComponentSelector.newSelector(DefaultModuleIdentifier.newId(dep.getGroupId(), dep.getArtifactId()), new DefaultImmutableVersionConstraint(mappedVersion));
    // Example: http://repo2.maven.org/maven2/net/jini/jsk-platform/2.1/jsk-platform-2.1.pom
    if (selector.getModuleIdentifier().equals(componentIdentifier.getModuleIdentifier())) {
        return;
    }
    IvyArtifactName dependencyArtifact = null;
    boolean hasClassifier = dep.getClassifier() != null && dep.getClassifier().length() > 0;
    boolean hasNonJarType = dep.getType() != null && !"jar".equals(dep.getType());
    if (hasClassifier || hasNonJarType) {
        String type = "jar";
        if (dep.getType() != null) {
            type = dep.getType();
        }
        String ext = determineExtension(type);
        String classifier = hasClassifier ? dep.getClassifier() : getClassifierForType(type);
        dependencyArtifact = new DefaultIvyArtifactName(selector.getModule(), type, ext, classifier);
    }
    // experimentation shows the following, excluded modules are
    // inherited from parent POMs if either of the following is true:
    // the <exclusions> element is missing or the <exclusions> element
    // is present, but empty.
    List<ExcludeMetadata> excludes = Lists.newArrayList();
    List<ModuleIdentifier> excluded = dep.getExcludedModules();
    if (excluded.isEmpty()) {
        excluded = getDependencyMgtExclusions(dep);
    }
    for (ModuleIdentifier excludedModule : excluded) {
        DefaultExclude rule = new DefaultExclude(excludedModule);
        excludes.add(rule);
    }
    dependencies.add(new MavenDependencyDescriptor(scope, dependencyType, selector, dependencyArtifact, excludes));
}
Also used : DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) DefaultImmutableVersionConstraint(org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint) DefaultExclude(org.gradle.internal.component.external.descriptor.DefaultExclude) MavenScope(org.gradle.internal.component.external.descriptor.MavenScope) MavenDependencyDescriptor(org.gradle.internal.component.external.model.maven.MavenDependencyDescriptor) ModuleComponentSelector(org.gradle.api.artifacts.component.ModuleComponentSelector) DefaultModuleComponentSelector(org.gradle.internal.component.external.model.DefaultModuleComponentSelector) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) ModuleIdentifier(org.gradle.api.artifacts.ModuleIdentifier) DefaultModuleIdentifier(org.gradle.api.internal.artifacts.DefaultModuleIdentifier) ExcludeMetadata(org.gradle.internal.component.model.ExcludeMetadata)

Example 3 with MavenDependencyDescriptor

use of org.gradle.internal.component.external.model.maven.MavenDependencyDescriptor in project gradle by gradle.

the class GradlePomModuleDescriptorParser method doParseDescriptor.

@Override
protected ParseResult<MutableMavenModuleResolveMetadata> doParseDescriptor(DescriptorParseContext parserSettings, LocallyAvailableExternalResource resource, boolean validate) throws IOException, ParseException, SAXException {
    PomReader pomReader = new PomReader(resource, moduleIdentifierFactory);
    GradlePomModuleDescriptorBuilder mdBuilder = new GradlePomModuleDescriptorBuilder(pomReader, gradleVersionSelectorScheme, mavenVersionSelectorScheme);
    doParsePom(parserSettings, mdBuilder, pomReader);
    List<MavenDependencyDescriptor> dependencies = mdBuilder.getDependencies();
    ModuleComponentIdentifier cid = mdBuilder.getComponentIdentifier();
    MutableMavenModuleResolveMetadata metadata = metadataFactory.create(cid, dependencies);
    metadata.setStatus(mdBuilder.getStatus());
    if (pomReader.getRelocation() != null) {
        metadata.setPackaging("pom");
        metadata.setRelocated(true);
    } else {
        metadata.setPackaging(pomReader.getPackaging());
        metadata.setRelocated(false);
    }
    return ParseResult.of(metadata, pomReader.hasGradleMetadataMarker());
}
Also used : MutableMavenModuleResolveMetadata(org.gradle.internal.component.external.model.maven.MutableMavenModuleResolveMetadata) MavenDependencyDescriptor(org.gradle.internal.component.external.model.maven.MavenDependencyDescriptor) DefaultModuleComponentIdentifier(org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier)

Example 4 with MavenDependencyDescriptor

use of org.gradle.internal.component.external.model.maven.MavenDependencyDescriptor in project gradle by gradle.

the class DirectDependencyMetadataAdapter method getIvyArtifacts.

private List<IvyArtifactName> getIvyArtifacts() {
    ModuleDependencyMetadata originalMetadata = getOriginalMetadata();
    if (originalMetadata instanceof ConfigurationBoundExternalDependencyMetadata) {
        ConfigurationBoundExternalDependencyMetadata externalMetadata = (ConfigurationBoundExternalDependencyMetadata) originalMetadata;
        ExternalDependencyDescriptor descriptor = externalMetadata.getDependencyDescriptor();
        if (descriptor instanceof MavenDependencyDescriptor) {
            return fromMavenDescriptor((MavenDependencyDescriptor) descriptor);
        }
        if (descriptor instanceof IvyDependencyDescriptor) {
            return fromIvyDescriptor((IvyDependencyDescriptor) descriptor);
        }
    } else if (originalMetadata instanceof GradleDependencyMetadata) {
        return fromGradleMetadata((GradleDependencyMetadata) originalMetadata);
    }
    return Collections.emptyList();
}
Also used : IvyDependencyDescriptor(org.gradle.internal.component.external.model.ivy.IvyDependencyDescriptor) GradleDependencyMetadata(org.gradle.internal.component.external.model.GradleDependencyMetadata) MavenDependencyDescriptor(org.gradle.internal.component.external.model.maven.MavenDependencyDescriptor) ConfigurationBoundExternalDependencyMetadata(org.gradle.internal.component.external.model.ConfigurationBoundExternalDependencyMetadata) ModuleDependencyMetadata(org.gradle.internal.component.external.model.ModuleDependencyMetadata) ExternalDependencyDescriptor(org.gradle.internal.component.external.model.ExternalDependencyDescriptor)

Aggregations

MavenDependencyDescriptor (org.gradle.internal.component.external.model.maven.MavenDependencyDescriptor)4 ModuleIdentifier (org.gradle.api.artifacts.ModuleIdentifier)1 ModuleComponentIdentifier (org.gradle.api.artifacts.component.ModuleComponentIdentifier)1 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)1 DefaultModuleIdentifier (org.gradle.api.internal.artifacts.DefaultModuleIdentifier)1 DefaultImmutableVersionConstraint (org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint)1 DefaultExclude (org.gradle.internal.component.external.descriptor.DefaultExclude)1 MavenScope (org.gradle.internal.component.external.descriptor.MavenScope)1 AbstractLazyModuleComponentResolveMetadata (org.gradle.internal.component.external.model.AbstractLazyModuleComponentResolveMetadata)1 ConfigurationBoundExternalDependencyMetadata (org.gradle.internal.component.external.model.ConfigurationBoundExternalDependencyMetadata)1 DefaultModuleComponentIdentifier (org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier)1 DefaultModuleComponentSelector (org.gradle.internal.component.external.model.DefaultModuleComponentSelector)1 ExternalDependencyDescriptor (org.gradle.internal.component.external.model.ExternalDependencyDescriptor)1 GradleDependencyMetadata (org.gradle.internal.component.external.model.GradleDependencyMetadata)1 ModuleDependencyMetadata (org.gradle.internal.component.external.model.ModuleDependencyMetadata)1 MutableModuleComponentResolveMetadata (org.gradle.internal.component.external.model.MutableModuleComponentResolveMetadata)1 DefaultIvyModuleResolveMetadata (org.gradle.internal.component.external.model.ivy.DefaultIvyModuleResolveMetadata)1 IvyDependencyDescriptor (org.gradle.internal.component.external.model.ivy.IvyDependencyDescriptor)1 DefaultMavenModuleResolveMetadata (org.gradle.internal.component.external.model.maven.DefaultMavenModuleResolveMetadata)1 MutableMavenModuleResolveMetadata (org.gradle.internal.component.external.model.maven.MutableMavenModuleResolveMetadata)1