Search in sources :

Example 31 with ModuleVersionIdentifier

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

the class ValidatingIvyPublisher method validateMetadata.

private void validateMetadata(IvyNormalizedPublication publication) {
    IvyPublicationIdentity identity = publication.getProjectIdentity();
    IvyFieldValidator organisation = field(publication, "organisation", identity.getOrganisation()).notEmpty().validInFileName();
    IvyFieldValidator moduleName = field(publication, "module name", identity.getModule()).notEmpty().validInFileName();
    IvyFieldValidator revision = field(publication, "revision", identity.getRevision()).notEmpty().validInFileName();
    MutableIvyModuleResolveMetadata metadata = parseIvyFile(publication);
    ModuleVersionIdentifier moduleId = metadata.getModuleVersionId();
    organisation.matches(moduleId.getGroup());
    moduleName.matches(moduleId.getName());
    revision.matches(moduleId.getVersion());
    field(publication, "branch", metadata.getBranch()).optionalNotEmpty().doesNotContainSpecialCharacters(true);
    field(publication, "status", metadata.getStatus()).optionalNotEmpty().validInFileName();
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) MutableIvyModuleResolveMetadata(org.gradle.internal.component.external.model.MutableIvyModuleResolveMetadata)

Example 32 with ModuleVersionIdentifier

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

the class DefaultIncludedBuild method registerProject.

private void registerProject(Set<Pair<ModuleVersionIdentifier, ProjectComponentIdentifier>> availableModules, ProjectInternal project) {
    LocalComponentRegistry localComponentRegistry = project.getServices().get(LocalComponentRegistry.class);
    ProjectComponentIdentifier originalIdentifier = newProjectId(project);
    DefaultLocalComponentMetadata originalComponent = (DefaultLocalComponentMetadata) localComponentRegistry.getComponent(originalIdentifier);
    ProjectComponentIdentifier componentIdentifier = idForProjectInThisBuild(project.getPath());
    ModuleVersionIdentifier moduleId = originalComponent.getModuleVersionId();
    LOGGER.info("Registering " + project + " in composite build. Will substitute for module '" + moduleId.getModule() + "'.");
    availableModules.add(Pair.of(moduleId, componentIdentifier));
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) DefaultLocalComponentMetadata(org.gradle.internal.component.local.model.DefaultLocalComponentMetadata) LocalComponentRegistry(org.gradle.api.internal.artifacts.ivyservice.projectmodule.LocalComponentRegistry) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier) DefaultProjectComponentIdentifier(org.gradle.internal.component.local.model.DefaultProjectComponentIdentifier)

Example 33 with ModuleVersionIdentifier

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

the class ModuleMetadataFileGenerator method writeIdentity.

private void writeIdentity(ModuleVersionIdentifier coordinates, ImmutableAttributes attributes, SoftwareComponent component, Map<SoftwareComponent, ComponentData> componentCoordinates, Map<SoftwareComponent, SoftwareComponent> owners, JsonWriter jsonWriter) throws IOException {
    SoftwareComponent owner = owners.get(component);
    if (owner == null) {
        jsonWriter.name("component");
        jsonWriter.beginObject();
        jsonWriter.name("group");
        jsonWriter.value(coordinates.getGroup());
        jsonWriter.name("module");
        jsonWriter.value(coordinates.getName());
        jsonWriter.name("version");
        jsonWriter.value(coordinates.getVersion());
        writeAttributes(attributes, jsonWriter);
        jsonWriter.endObject();
    } else {
        ComponentData componentData = componentCoordinates.get(owner);
        ModuleVersionIdentifier ownerCoordinates = componentData.coordinates;
        jsonWriter.name("component");
        jsonWriter.beginObject();
        jsonWriter.name("url");
        jsonWriter.value(relativeUrlTo(coordinates, ownerCoordinates));
        jsonWriter.name("group");
        jsonWriter.value(ownerCoordinates.getGroup());
        jsonWriter.name("module");
        jsonWriter.value(ownerCoordinates.getName());
        jsonWriter.name("version");
        jsonWriter.value(ownerCoordinates.getVersion());
        writeAttributes(componentData.attributes, jsonWriter);
        jsonWriter.endObject();
    }
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) SoftwareComponent(org.gradle.api.component.SoftwareComponent)

Example 34 with ModuleVersionIdentifier

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

the class ModuleMetadataFileGenerator method writeDependency.

private void writeDependency(Dependency dependency, JsonWriter jsonWriter) throws IOException {
    jsonWriter.beginObject();
    if (dependency instanceof ProjectDependency) {
        ProjectDependency projectDependency = (ProjectDependency) dependency;
        ModuleVersionIdentifier identifier = projectDependencyResolver.resolve(ModuleVersionIdentifier.class, projectDependency);
        jsonWriter.name("group");
        jsonWriter.value(identifier.getGroup());
        jsonWriter.name("module");
        jsonWriter.value(identifier.getName());
        writeVersionConstraint(DefaultImmutableVersionConstraint.of(identifier.getVersion()), jsonWriter);
    } else {
        jsonWriter.name("group");
        jsonWriter.value(dependency.getGroup());
        jsonWriter.name("module");
        jsonWriter.value(dependency.getName());
        VersionConstraint vc;
        if (dependency instanceof ModuleVersionSelector) {
            vc = ((ExternalDependency) dependency).getVersionConstraint();
        } else {
            vc = DefaultImmutableVersionConstraint.of(Strings.nullToEmpty(dependency.getVersion()));
        }
        writeVersionConstraint(vc, jsonWriter);
    }
    if (dependency instanceof ModuleDependency) {
        writeExcludes((ModuleDependency) dependency, jsonWriter);
    }
    String reason = dependency.getReason();
    if (StringUtils.isNotEmpty(reason)) {
        jsonWriter.name("reason");
        jsonWriter.value(reason);
    }
    jsonWriter.endObject();
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) VersionConstraint(org.gradle.api.artifacts.VersionConstraint) DefaultImmutableVersionConstraint(org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint) ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) ModuleDependency(org.gradle.api.artifacts.ModuleDependency) ProjectDependency(org.gradle.api.artifacts.ProjectDependency)

Example 35 with ModuleVersionIdentifier

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

the class ModuleMetadataFileGenerator method collectCoordinates.

private void collectCoordinates(Collection<? extends PublicationInternal> publications, Map<SoftwareComponent, ComponentData> coordinates) {
    for (PublicationInternal publication : publications) {
        if (publication.getComponent() != null) {
            ModuleVersionIdentifier moduleVersionIdentifier = publication.getCoordinates();
            ImmutableAttributes attributes = publication.getAttributes();
            coordinates.put(publication.getComponent(), new ComponentData(moduleVersionIdentifier, attributes));
        }
    }
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) ImmutableAttributes(org.gradle.api.internal.attributes.ImmutableAttributes)

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