Search in sources :

Example 6 with DefaultImmutableVersionConstraint

use of org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint in project gradle by gradle.

the class ModuleComponentSelectorSerializer method readVersionConstraint.

public VersionConstraint readVersionConstraint(Decoder decoder) throws IOException {
    String preferred = decoder.readString();
    int cpt = decoder.readSmallInt();
    List<String> rejects = Lists.newArrayListWithCapacity(cpt);
    for (int i = 0; i < cpt; i++) {
        rejects.add(decoder.readString());
    }
    return new DefaultImmutableVersionConstraint(preferred, rejects);
}
Also used : DefaultImmutableVersionConstraint(org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint) VersionConstraint(org.gradle.api.artifacts.VersionConstraint) DefaultImmutableVersionConstraint(org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint)

Example 7 with DefaultImmutableVersionConstraint

use of org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint in project gradle by gradle.

the class GradlePomModuleDescriptorParser method doParsePom.

private void doParsePom(DescriptorParseContext parserSettings, GradlePomModuleDescriptorBuilder mdBuilder, PomReader pomReader) throws IOException, SAXException {
    if (pomReader.hasParent()) {
        // Is there any other parent properties?
        ModuleComponentSelector parentId = DefaultModuleComponentSelector.newSelector(pomReader.getParentGroupId(), pomReader.getParentArtifactId(), new DefaultImmutableVersionConstraint(pomReader.getParentVersion()));
        PomReader parentPomReader = parsePomForSelector(parserSettings, parentId, pomReader.getAllPomProperties());
        pomReader.setPomParent(parentPomReader);
    }
    pomReader.resolveGAV();
    String groupId = pomReader.getGroupId();
    String artifactId = pomReader.getArtifactId();
    String 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.<String, String>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(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

DefaultImmutableVersionConstraint (org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint)7 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)5 DefaultModuleComponentSelector (org.gradle.internal.component.external.model.DefaultModuleComponentSelector)4 VersionConstraint (org.gradle.api.artifacts.VersionConstraint)3 ModuleIdentifier (org.gradle.api.artifacts.ModuleIdentifier)2 DefaultExclude (org.gradle.internal.component.external.descriptor.DefaultExclude)2 DefaultIvyArtifactName (org.gradle.internal.component.model.DefaultIvyArtifactName)2 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)2 List (java.util.List)1 Map (java.util.Map)1 DependencyArtifactDescriptor (org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor)1 ExcludeRule (org.apache.ivy.core.module.descriptor.ExcludeRule)1 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)1 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)1 ImmutableVersionConstraint (org.gradle.api.internal.artifacts.ImmutableVersionConstraint)1 DefaultMutableVersionConstraint (org.gradle.api.internal.artifacts.dependencies.DefaultMutableVersionConstraint)1 Artifact (org.gradle.internal.component.external.descriptor.Artifact)1 MavenScope (org.gradle.internal.component.external.descriptor.MavenScope)1 IvyDependencyDescriptor (org.gradle.internal.component.external.model.IvyDependencyDescriptor)1 MavenDependencyDescriptor (org.gradle.internal.component.external.model.MavenDependencyDescriptor)1