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();
}
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));
}
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();
}
}
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();
}
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));
}
}
}
Aggregations