Search in sources :

Example 36 with ModuleVersionIdentifier

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

the class ModuleMetadataFileGenerator method writeVariants.

private void writeVariants(PublicationInternal publication, SoftwareComponent component, Map<SoftwareComponent, ComponentData> componentCoordinates, JsonWriter jsonWriter) throws IOException {
    boolean started = false;
    for (UsageContext usageContext : ((SoftwareComponentInternal) component).getUsages()) {
        if (!started) {
            jsonWriter.name("variants");
            jsonWriter.beginArray();
            started = true;
        }
        writeVariantHostedInThisModule(publication, usageContext, jsonWriter);
    }
    if (component instanceof ComponentWithVariants) {
        for (SoftwareComponent childComponent : ((ComponentWithVariants) component).getVariants()) {
            ModuleVersionIdentifier childCoordinates;
            if (childComponent instanceof ComponentWithCoordinates) {
                childCoordinates = ((ComponentWithCoordinates) childComponent).getCoordinates();
            } else {
                ComponentData componentData = componentCoordinates.get(childComponent);
                childCoordinates = componentData == null ? null : componentData.coordinates;
            }
            assert childCoordinates != null;
            if (childComponent instanceof SoftwareComponentInternal) {
                for (UsageContext usageContext : ((SoftwareComponentInternal) childComponent).getUsages()) {
                    if (!started) {
                        jsonWriter.name("variants");
                        jsonWriter.beginArray();
                        started = true;
                    }
                    writeVariantHostedInAnotherModule(publication.getCoordinates(), childCoordinates, usageContext, jsonWriter);
                }
            }
        }
    }
    if (started) {
        jsonWriter.endArray();
    }
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) ComponentWithCoordinates(org.gradle.api.component.ComponentWithCoordinates) UsageContext(org.gradle.api.internal.component.UsageContext) ComponentWithVariants(org.gradle.api.component.ComponentWithVariants) SoftwareComponentInternal(org.gradle.api.internal.component.SoftwareComponentInternal) SoftwareComponent(org.gradle.api.component.SoftwareComponent)

Example 37 with ModuleVersionIdentifier

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

the class DefaultMavenPublication method addProjectDependency.

private void addProjectDependency(ProjectDependency dependency, Set<MavenDependencyInternal> dependencies) {
    ModuleVersionIdentifier identifier = projectDependencyResolver.resolve(ModuleVersionIdentifier.class, dependency);
    dependencies.add(new DefaultMavenDependency(identifier.getGroup(), identifier.getName(), identifier.getVersion(), Collections.<DependencyArtifact>emptyList(), getExcludeRules(dependency)));
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) DefaultModuleVersionIdentifier(org.gradle.api.internal.artifacts.DefaultModuleVersionIdentifier) DefaultMavenDependency(org.gradle.api.publish.maven.internal.dependencies.DefaultMavenDependency) DependencyArtifact(org.gradle.api.artifacts.DependencyArtifact)

Example 38 with ModuleVersionIdentifier

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

the class DefaultMavenPublication method getArtifactFileName.

private String getArtifactFileName(String classifier, String extension) {
    StringBuilder artifactPath = new StringBuilder();
    ModuleVersionIdentifier coordinates = getCoordinates();
    artifactPath.append(coordinates.getName());
    artifactPath.append('-');
    artifactPath.append(coordinates.getVersion());
    if (GUtil.isTrue(classifier)) {
        artifactPath.append('-');
        artifactPath.append(classifier);
    }
    if (GUtil.isTrue(extension)) {
        artifactPath.append('.');
        artifactPath.append(extension);
    }
    return artifactPath.toString();
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) DefaultModuleVersionIdentifier(org.gradle.api.internal.artifacts.DefaultModuleVersionIdentifier)

Aggregations

ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)38 ComponentIdentifier (org.gradle.api.artifacts.component.ComponentIdentifier)8 ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)7 DependencyResult (org.gradle.api.artifacts.result.DependencyResult)7 ResolvedDependencyResult (org.gradle.api.artifacts.result.ResolvedDependencyResult)7 File (java.io.File)6 UnresolvedDependencyResult (org.gradle.api.artifacts.result.UnresolvedDependencyResult)6 List (java.util.List)5 ResolvedArtifact (org.gradle.api.artifacts.ResolvedArtifact)5 DefaultModuleVersionIdentifier (org.gradle.api.internal.artifacts.DefaultModuleVersionIdentifier)5 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 ComponentSelector (org.gradle.api.artifacts.component.ComponentSelector)4 Module (org.gradle.api.internal.artifacts.Module)4 DefaultLocalComponentMetadata (org.gradle.internal.component.local.model.DefaultLocalComponentMetadata)4 ImmutableList (com.google.common.collect.ImmutableList)3 Configuration (org.gradle.api.artifacts.Configuration)3 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)3 ResolvedComponentResult (org.gradle.api.artifacts.result.ResolvedComponentResult)3 JarDependency (com.android.builder.dependency.JarDependency)2