use of org.gradle.api.internal.artifacts.repositories.resolver.MavenUniqueSnapshotComponentIdentifier in project gradle by gradle.
the class ComponentIdentifierSerializer method write.
public void write(Encoder encoder, ComponentIdentifier value) throws IOException {
if (value == null) {
throw new IllegalArgumentException("Provided component identifier may not be null");
}
Implementation implementation = resolveImplementation(value);
encoder.writeByte(implementation.getId());
if (implementation == Implementation.MODULE) {
ModuleComponentIdentifier moduleComponentIdentifier = (ModuleComponentIdentifier) value;
encoder.writeString(moduleComponentIdentifier.getGroup());
encoder.writeString(moduleComponentIdentifier.getModule());
encoder.writeString(moduleComponentIdentifier.getVersion());
} else if (implementation == Implementation.SNAPSHOT) {
MavenUniqueSnapshotComponentIdentifier snapshotIdentifier = (MavenUniqueSnapshotComponentIdentifier) value;
encoder.writeString(snapshotIdentifier.getGroup());
encoder.writeString(snapshotIdentifier.getModule());
encoder.writeString(snapshotIdentifier.getVersion());
encoder.writeString(snapshotIdentifier.getTimestamp());
} else if (implementation == Implementation.BUILD) {
ProjectComponentIdentifier projectComponentIdentifier = (ProjectComponentIdentifier) value;
BuildIdentifier build = projectComponentIdentifier.getBuild();
buildIdentifierSerializer.write(encoder, build);
encoder.writeString(projectComponentIdentifier.getProjectPath());
} else if (implementation == Implementation.LIBRARY) {
LibraryBinaryIdentifier libraryIdentifier = (LibraryBinaryIdentifier) value;
encoder.writeString(libraryIdentifier.getProjectPath());
encoder.writeString(libraryIdentifier.getLibraryName());
encoder.writeString(libraryIdentifier.getVariant());
} else {
throw new IllegalStateException("Unsupported implementation type: " + implementation);
}
}
use of org.gradle.api.internal.artifacts.repositories.resolver.MavenUniqueSnapshotComponentIdentifier in project gradle by gradle.
the class DefaultMavenPomMetadataSource method parseMetaDataFromResource.
protected MutableMavenModuleResolveMetadata parseMetaDataFromResource(ModuleComponentIdentifier moduleComponentIdentifier, LocallyAvailableExternalResource cachedResource, ExternalResourceArtifactResolver artifactResolver, DescriptorParseContext context, String repoName) {
MutableMavenModuleResolveMetadata metaData = pomParser.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);
metaData.setId(snapshotComponentIdentifier);
metaData.setSnapshotTimestamp(snapshotComponentIdentifier.getTimestamp());
} else {
checkMetadataConsistency(moduleComponentIdentifier, metaData);
}
MutableMavenModuleResolveMetadata result = MavenResolver.processMetaData(metaData);
if (validator.isUsableModule(repoName, result, artifactResolver)) {
return result;
}
return null;
}
Aggregations