use of org.gradle.api.artifacts.component.ModuleComponentIdentifier in project gradle by gradle.
the class MavenResolver method parseMetaDataFromResource.
protected MutableMavenModuleResolveMetadata parseMetaDataFromResource(ModuleComponentIdentifier moduleComponentIdentifier, LocallyAvailableExternalResource cachedResource, DescriptorParseContext context) {
MutableMavenModuleResolveMetadata metaData = metaDataParser.parseMetaData(context, cachedResource);
if (moduleComponentIdentifier instanceof MavenUniqueSnapshotComponentIdentifier) {
// Snapshot POMs use -SNAPSHOT instead of the timestamp as version, so validate against the expected id
MavenUniqueSnapshotComponentIdentifier snapshotComponentIdentifier = (MavenUniqueSnapshotComponentIdentifier) moduleComponentIdentifier;
checkMetadataConsistency(snapshotComponentIdentifier.getSnapshotComponent(), metaData);
// Use the requested id. Currently we're discarding the MavenUniqueSnapshotComponentIdentifier and replacing with DefaultModuleComponentIdentifier as pretty
// much every consumer of the meta-data is expecting a DefaultModuleComponentIdentifier.
ModuleComponentIdentifier lossyId = DefaultModuleComponentIdentifier.newId(moduleComponentIdentifier.getGroup(), moduleComponentIdentifier.getModule(), moduleComponentIdentifier.getVersion());
metaData.setComponentId(lossyId);
metaData.setSnapshotTimestamp(snapshotComponentIdentifier.getTimestamp());
} else {
checkMetadataConsistency(moduleComponentIdentifier, metaData);
}
return processMetaData(metaData);
}
use of org.gradle.api.artifacts.component.ModuleComponentIdentifier in project gradle by gradle.
the class IvyXmlModuleDescriptorWriter method printInfoTag.
private static void printInfoTag(ModuleDescriptorState descriptor, SimpleXmlWriter writer) throws IOException {
ModuleComponentIdentifier id = descriptor.getComponentIdentifier();
writer.startElement("info");
writer.attribute("organisation", id.getGroup());
writer.attribute("module", id.getModule());
String branch = descriptor.getBranch();
if (branch != null) {
writer.attribute("branch", branch);
}
writer.attribute("revision", id.getVersion());
writer.attribute("status", descriptor.getStatus());
if (descriptor.isGenerated()) {
writer.attribute("default", "true");
}
printUnusedContent(descriptor, writer);
for (Map.Entry<NamespaceId, String> entry : descriptor.getExtraInfo().entrySet()) {
if (entry.getValue() == null || entry.getValue().length() == 0) {
continue;
}
NamespaceId namespaceId = entry.getKey();
writer.startElement("ns:" + namespaceId.getName());
writer.attribute("xmlns:ns", namespaceId.getNamespace());
writer.characters(entry.getValue());
writer.endElement();
}
writer.endElement();
}
use of org.gradle.api.artifacts.component.ModuleComponentIdentifier in project gradle by gradle.
the class DefaultVersionedComponentChooser method selectNewestMatchingComponent.
public void selectNewestMatchingComponent(Collection<? extends ModuleComponentResolveState> versions, BuildableComponentSelectionResult result, ModuleVersionSelector requested) {
VersionSelector requestedVersion = versionSelectorScheme.parseSelector(requested.getVersion());
Collection<SpecRuleAction<? super ComponentSelection>> rules = componentSelectionRules.getRules();
for (ModuleComponentResolveState candidate : sortLatestFirst(versions)) {
MetadataProvider metadataProvider = createMetadataProvider(candidate);
boolean versionMatches = versionMatches(requestedVersion, candidate, metadataProvider);
if (!metadataProvider.isUsable()) {
applyTo(metadataProvider, result);
return;
}
if (!versionMatches) {
result.notMatched(candidate.getVersion());
continue;
}
ModuleComponentIdentifier candidateIdentifier = candidate.getId();
boolean accepted = !isRejectedByRules(candidateIdentifier, rules, metadataProvider);
if (!metadataProvider.isUsable()) {
applyTo(metadataProvider, result);
return;
}
if (accepted) {
result.matches(candidateIdentifier);
return;
}
result.rejected(candidate.getVersion());
if (requestedVersion.matchesUniqueVersion()) {
// Only consider one candidate
break;
}
}
result.noMatchFound();
}
use of org.gradle.api.artifacts.component.ModuleComponentIdentifier in project gradle by gradle.
the class DependencyResolverIvyPublisher method publish.
public void publish(IvyNormalizedPublication publication, PublicationAwareRepository repository) {
ModuleVersionPublisher publisher = repository.createPublisher();
IvyPublicationIdentity projectIdentity = publication.getProjectIdentity();
ModuleComponentIdentifier moduleVersionIdentifier = DefaultModuleComponentIdentifier.newId(projectIdentity.getOrganisation(), projectIdentity.getModule(), projectIdentity.getRevision());
// Use the legacy metadata type so that we can leverage `ModuleVersionPublisher.publish()`
DefaultIvyModulePublishMetadata publishMetaData = new DefaultIvyModulePublishMetadata(moduleVersionIdentifier, "");
for (IvyArtifact publishArtifact : publication.getArtifacts()) {
publishMetaData.addArtifact(createIvyArtifact(publishArtifact), publishArtifact.getFile());
}
IvyArtifactName ivyDescriptor = new DefaultIvyArtifactName("ivy", "ivy", "xml");
publishMetaData.addArtifact(ivyDescriptor, publication.getIvyDescriptorFile());
File gradleModuleDescriptorFile = publication.getGradleModuleDescriptorFile();
if (gradleModuleDescriptorFile != null && gradleModuleDescriptorFile.exists()) {
// may not exist if experimental features are disabled
IvyArtifactName gradleDescriptor = new DefaultIvyArtifactName(projectIdentity.getModule(), "json", "module");
publishMetaData.addArtifact(gradleDescriptor, gradleModuleDescriptorFile);
}
publisher.publish(publishMetaData);
}
use of org.gradle.api.artifacts.component.ModuleComponentIdentifier in project spring-security by spring-projects.
the class DependencyExcludesTests method currentVersionAndCandidateVersion.
private ComponentSelectionWithCurrent currentVersionAndCandidateVersion(ComponentSelection componentSelection, String currentVersion, String candidateVersion) {
ModuleComponentIdentifier candidate = mock(ModuleComponentIdentifier.class);
given(componentSelection.getCandidate()).willReturn(candidate);
ComponentSelectionWithCurrent selection = new ComponentSelectionWithCurrent(currentVersion, componentSelection);
given(candidate.getVersion()).willReturn(candidateVersion);
given(componentSelection.getCandidate()).willReturn(candidate);
return selection;
}
Aggregations