Search in sources :

Example 36 with IvyArtifactName

use of org.gradle.internal.component.model.IvyArtifactName in project gradle by gradle.

the class ExternalResourceResolver method getDependencyArtifactNames.

private Set<IvyArtifactName> getDependencyArtifactNames(String moduleName, Set<IvyArtifactName> artifacts) {
    Set<IvyArtifactName> artifactSet = Sets.newLinkedHashSet();
    artifactSet.addAll(artifacts);
    if (artifactSet.isEmpty()) {
        artifactSet.add(new DefaultIvyArtifactName(moduleName, "jar", "jar"));
    }
    return artifactSet;
}
Also used : DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName)

Example 37 with IvyArtifactName

use of org.gradle.internal.component.model.IvyArtifactName in project gradle by gradle.

the class MutableModuleDescriptorState method createModuleDescriptor.

public static MutableModuleDescriptorState createModuleDescriptor(ModuleComponentIdentifier componentIdentifier, Set<IvyArtifactName> componentArtifacts) {
    MutableModuleDescriptorState moduleDescriptorState = new MutableModuleDescriptorState(componentIdentifier);
    for (IvyArtifactName artifactName : componentArtifacts) {
        moduleDescriptorState.addArtifact(artifactName, Collections.singleton(org.gradle.api.artifacts.Dependency.DEFAULT_CONFIGURATION));
    }
    if (componentArtifacts.isEmpty()) {
        IvyArtifactName defaultArtifact = new DefaultIvyArtifactName(componentIdentifier.getModule(), "jar", "jar");
        moduleDescriptorState.addArtifact(defaultArtifact, Collections.singleton(org.gradle.api.artifacts.Dependency.DEFAULT_CONFIGURATION));
    }
    return moduleDescriptorState;
}
Also used : DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName)

Example 38 with IvyArtifactName

use of org.gradle.internal.component.model.IvyArtifactName in project gradle by gradle.

the class DefaultResolvedDependencyTest method createResolvedArtifact.

public static DefaultResolvedArtifact createResolvedArtifact(final Mockery context, final String name, final String type, final String extension, final File file) {
    final IvyArtifactName artifactStub = context.mock(IvyArtifactName.class, "artifact" + name);
    context.checking(new Expectations() {

        {
            allowing(artifactStub).getName();
            will(returnValue(name));
            allowing(artifactStub).getType();
            will(returnValue(type));
            allowing(artifactStub).getExtension();
            will(returnValue(extension));
            allowing(artifactStub).getClassifier();
            will(returnValue(null));
        }
    });
    final Factory artifactSource = context.mock(Factory.class);
    context.checking(new Expectations() {

        {
            allowing(artifactSource).create();
            will(returnValue(file));
        }
    });
    final ResolvedDependency resolvedDependency = context.mock(ResolvedDependency.class);
    final ResolvedModuleVersion version = context.mock(ResolvedModuleVersion.class);
    context.checking(new Expectations() {

        {
            allowing(resolvedDependency).getModule();
            will(returnValue(version));
            allowing(version).getId();
            will(returnValue(new DefaultModuleVersionIdentifier("group", name, "1.2")));
        }
    });
    return new DefaultResolvedArtifact(resolvedDependency.getModule().getId(), artifactStub, context.mock(ComponentArtifactIdentifier.class), context.mock(TaskDependency.class), artifactSource);
}
Also used : Expectations(org.jmock.Expectations) TaskDependency(org.gradle.api.tasks.TaskDependency) ComponentArtifactIdentifier(org.gradle.api.artifacts.component.ComponentArtifactIdentifier) ResolvedModuleVersion(org.gradle.api.artifacts.ResolvedModuleVersion) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) ResolvedDependency(org.gradle.api.artifacts.ResolvedDependency) Factory(org.gradle.internal.Factory)

Example 39 with IvyArtifactName

use of org.gradle.internal.component.model.IvyArtifactName in project gradle by gradle.

the class PreResolvedResolvableArtifact method transformedTo.

@Override
public ResolvableArtifact transformedTo(File file) {
    IvyArtifactName artifactName = DefaultIvyArtifactName.forFile(file, getClassifier());
    ComponentArtifactIdentifier newId = new ComponentFileArtifactIdentifier(artifactId.getComponentIdentifier(), artifactName);
    return new PreResolvedResolvableArtifact(owner, artifactName, newId, calculatedValueContainerFactory.create(Describables.of(newId), file), builtBy, calculatedValueContainerFactory);
}
Also used : ComponentArtifactIdentifier(org.gradle.api.artifacts.component.ComponentArtifactIdentifier) ComponentFileArtifactIdentifier(org.gradle.internal.component.local.model.ComponentFileArtifactIdentifier) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName)

Example 40 with IvyArtifactName

use of org.gradle.internal.component.model.IvyArtifactName in project gradle by gradle.

the class GradleModuleMetadataParser method consumeDependencies.

private List<ModuleDependency> consumeDependencies(JsonReader reader) throws IOException {
    List<ModuleDependency> dependencies = new ArrayList<>();
    reader.beginArray();
    while (reader.peek() != END_ARRAY) {
        String group = null;
        String module = null;
        String reason = null;
        ImmutableAttributes attributes = ImmutableAttributes.EMPTY;
        VersionConstraint version = DefaultImmutableVersionConstraint.of();
        ImmutableList<ExcludeMetadata> excludes = ImmutableList.of();
        List<VariantCapability> requestedCapabilities = ImmutableList.of();
        IvyArtifactName artifactSelector = null;
        boolean endorseStrictVersions = false;
        reader.beginObject();
        while (reader.peek() != END_OBJECT) {
            String name = reader.nextName();
            switch(name) {
                case "group":
                    group = reader.nextString();
                    break;
                case "module":
                    module = reader.nextString();
                    break;
                case "version":
                    version = consumeVersion(reader);
                    break;
                case "excludes":
                    excludes = consumeExcludes(reader);
                    break;
                case "reason":
                    reason = reader.nextString();
                    break;
                case "attributes":
                    attributes = consumeAttributes(reader);
                    break;
                case "requestedCapabilities":
                    requestedCapabilities = consumeCapabilities(reader, false);
                    break;
                case "endorseStrictVersions":
                    endorseStrictVersions = reader.nextBoolean();
                    break;
                case "thirdPartyCompatibility":
                    reader.beginObject();
                    while (reader.peek() != END_OBJECT) {
                        String compatibilityFeatureName = reader.nextName();
                        if (compatibilityFeatureName.equals("artifactSelector")) {
                            artifactSelector = consumeArtifactSelector(reader);
                        } else {
                            consumeAny(reader);
                        }
                    }
                    reader.endObject();
                    break;
                default:
                    consumeAny(reader);
                    break;
            }
        }
        assertDefined(reader, "group", group);
        assertDefined(reader, "module", module);
        reader.endObject();
        dependencies.add(new ModuleDependency(group, module, version, excludes, reason, attributes, requestedCapabilities, endorseStrictVersions, artifactSelector));
    }
    reader.endArray();
    return dependencies;
}
Also used : ImmutableAttributes(org.gradle.api.internal.attributes.ImmutableAttributes) ImmutableVersionConstraint(org.gradle.api.internal.artifacts.ImmutableVersionConstraint) VersionConstraint(org.gradle.api.artifacts.VersionConstraint) DefaultImmutableVersionConstraint(org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint) ArrayList(java.util.ArrayList) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) ExcludeMetadata(org.gradle.internal.component.model.ExcludeMetadata)

Aggregations

IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)52 DefaultIvyArtifactName (org.gradle.internal.component.model.DefaultIvyArtifactName)28 DefaultExclude (org.gradle.internal.component.external.descriptor.DefaultExclude)7 ExcludeMetadata (org.gradle.internal.component.model.ExcludeMetadata)7 File (java.io.File)6 Artifact (org.gradle.internal.component.external.descriptor.Artifact)6 ModuleIdentifier (org.gradle.api.artifacts.ModuleIdentifier)5 ComponentArtifactIdentifier (org.gradle.api.artifacts.component.ComponentArtifactIdentifier)5 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)5 ImmutableList (com.google.common.collect.ImmutableList)4 DefaultImmutableVersionConstraint (org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint)4 ComponentArtifactMetadata (org.gradle.internal.component.model.ComponentArtifactMetadata)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 List (java.util.List)3 Map (java.util.Map)3 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)3 ModuleVersionSelector (org.gradle.api.artifacts.ModuleVersionSelector)3 DefaultResolvedArtifact (org.gradle.api.internal.artifacts.DefaultResolvedArtifact)3 ImmutableAttributes (org.gradle.api.internal.attributes.ImmutableAttributes)3 MavenScope (org.gradle.internal.component.external.descriptor.MavenScope)3