use of org.gradle.api.artifacts.component.ModuleComponentIdentifier in project gradle by gradle.
the class DefaultArtifactPublisher method toPublishMetaData.
private DefaultIvyModulePublishMetadata toPublishMetaData(Module module, Set<? extends ConfigurationInternal> configurations, boolean validateArtifacts) {
ModuleComponentIdentifier id = DefaultModuleComponentIdentifier.newId(DefaultModuleIdentifier.newId(module.getGroup(), module.getName()), module.getVersion());
DefaultIvyModulePublishMetadata publishMetaData = new DefaultIvyModulePublishMetadata(id, module.getStatus());
addConfigurations(publishMetaData, configurations, validateArtifacts);
return publishMetaData;
}
use of org.gradle.api.artifacts.component.ModuleComponentIdentifier in project gradle by gradle.
the class AbstractRealisedModuleResolveMetadataSerializationHelper method readFiles.
protected ImmutableList<? extends ModuleComponentArtifactMetadata> readFiles(Decoder decoder, ModuleComponentIdentifier componentIdentifier) throws IOException {
ImmutableList.Builder<ModuleComponentArtifactMetadata> artifacts = new ImmutableList.Builder<>();
int artifactsCount = decoder.readSmallInt();
for (int i = 0; i < artifactsCount; i++) {
String name = decoder.readString();
String type = decoder.readString();
String extension = decoder.readNullableString();
String classifier = decoder.readNullableString();
String timestamp = decoder.readNullableString();
String version;
ModuleComponentIdentifier cid = componentIdentifier;
if (timestamp != null) {
version = decoder.readString();
cid = new MavenUniqueSnapshotComponentIdentifier(componentIdentifier.getModuleIdentifier(), version, timestamp);
}
boolean alternativeArtifact = decoder.readBoolean();
DefaultIvyArtifactName alternative = null;
if (alternativeArtifact) {
String altName = decoder.readString();
String altType = decoder.readString();
String altExtension = decoder.readNullableString();
String altClassifier = decoder.readNullableString();
alternative = new DefaultIvyArtifactName(altName, altType, altExtension, altClassifier);
}
boolean optional = decoder.readBoolean();
if (optional) {
artifacts.add(new ModuleComponentOptionalArtifactMetadata(cid, new DefaultIvyArtifactName(name, type, extension, classifier)));
} else {
if (alternativeArtifact) {
artifacts.add(new DefaultModuleComponentArtifactMetadata(cid, new DefaultIvyArtifactName(name, type, extension, classifier), new DefaultModuleComponentArtifactMetadata(cid, alternative)));
} else {
artifacts.add(new DefaultModuleComponentArtifactMetadata(cid, new DefaultIvyArtifactName(name, type, extension, classifier)));
}
}
}
int filesCount = decoder.readSmallInt();
for (int i = 0; i < filesCount; i++) {
String fileName = decoder.readString();
String uri = decoder.readString();
artifacts.add(new UrlBackedArtifactMetadata(componentIdentifier, fileName, uri));
}
return artifacts.build();
}
use of org.gradle.api.artifacts.component.ModuleComponentIdentifier in project gradle by gradle.
the class DependencyLockingArtifactVisitor method visitNode.
@Override
public void visitNode(DependencyGraphNode node) {
boolean changing = false;
ComponentIdentifier identifier = node.getOwner().getComponentId();
ComponentResolveMetadata metadata = node.getOwner().getMetadata();
if (metadata != null && metadata.isChanging()) {
changing = true;
}
if (!node.isRoot() && identifier instanceof ModuleComponentIdentifier) {
ModuleComponentIdentifier id = (ModuleComponentIdentifier) identifier;
if (identifier instanceof MavenUniqueSnapshotComponentIdentifier) {
id = ((MavenUniqueSnapshotComponentIdentifier) id).getSnapshotComponent();
}
if (!id.getVersion().isEmpty()) {
if (allResolvedModules.add(id)) {
if (changing) {
addChangingModule(id);
}
if (dependencyLockingState.mustValidateLockState()) {
ModuleComponentIdentifier lockedId = modulesToBeLocked.remove(id.getModuleIdentifier());
if (lockedId == null) {
if (!dependencyLockingState.getIgnoredEntryFilter().isSatisfiedBy(id)) {
extraModules.add(id);
}
} else if (!lockedId.getVersion().equals(id.getVersion()) && !isNodeRejected(node)) {
// Need to check that versions do match, mismatch indicates a force was used
forcedModules.put(lockedId, id.getVersion());
}
}
}
}
}
}
use of org.gradle.api.artifacts.component.ModuleComponentIdentifier in project gradle by gradle.
the class DefaultDependencyLockingProvider method loadLockState.
@Override
public DependencyLockingState loadLockState(String configurationName) {
recordUsage();
loadLockState();
if (!writeLocks || partialUpdate) {
List<String> lockedModules = findLockedModules(configurationName);
if (lockedModules == null && lockMode.get() == LockMode.STRICT) {
throw new MissingLockStateException(context.identityPath(configurationName).toString());
}
if (lockedModules != null) {
Set<ModuleComponentIdentifier> results = Sets.newHashSetWithExpectedSize(lockedModules.size());
for (String module : lockedModules) {
ModuleComponentIdentifier lockedIdentifier = parseLockNotation(configurationName, module);
if (!getCompoundLockEntryFilter().isSatisfiedBy(lockedIdentifier) && !isSubstitutedInComposite(lockedIdentifier)) {
results.add(lockedIdentifier);
}
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Loaded lock state for configuration '{}', state is: {}", context.identityPath(configurationName), lockedModules);
} else {
LOGGER.info("Loaded lock state for configuration '{}'", context.identityPath(configurationName));
}
boolean strictlyValidate = !partialUpdate && lockMode.get() != LockMode.LENIENT;
return new DefaultDependencyLockingState(strictlyValidate, results, getIgnoredEntryFilter());
}
}
return DefaultDependencyLockingState.EMPTY_LOCK_CONSTRAINT;
}
use of org.gradle.api.artifacts.component.ModuleComponentIdentifier in project atlas by alibaba.
the class AtlasDependencyGraph method computeMavenCoordinates.
@NonNull
private static MavenCoordinates computeMavenCoordinates(@NonNull ResolvedArtifactResult artifact) {
// instance should be a hashable.
AtlasDependencyGraph.HashableResolvedArtifactResult hashableResult = (AtlasDependencyGraph.HashableResolvedArtifactResult) artifact;
ComponentIdentifier id = artifact.getId().getComponentIdentifier();
final File artifactFile = artifact.getFile();
final String fileName = artifactFile.getName();
String extension = hashableResult.getDependencyType().getExtension();
if (id instanceof ModuleComponentIdentifier) {
ModuleComponentIdentifier moduleComponentId = (ModuleComponentIdentifier) id;
final String module = moduleComponentId.getModule();
final String version = moduleComponentId.getVersion();
String classifier = null;
if (!artifact.getFile().isDirectory()) {
// attempts to compute classifier based on the filename.
String pattern = "^" + module + "-" + version + "-(.+)\\." + extension + "$";
Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(fileName);
if (m.matches()) {
classifier = m.group(1);
}
}
return new MavenCoordinatesImpl(moduleComponentId.getGroup(), module, version, extension, classifier);
} else if (id instanceof ProjectComponentIdentifier) {
return new MavenCoordinatesImpl("artifacts", ((ProjectComponentIdentifier) id).getProjectPath(), "unspecified");
} else if (id instanceof OpaqueComponentArtifactIdentifier) {
// We have a file based dependency
if (hashableResult.getDependencyType() == DependencyType.JAVA) {
return getMavenCoordForLocalFile(artifactFile);
} else {
// local aar?
assert artifactFile.isDirectory();
return getMavenCoordForLocalFile(artifactFile);
}
}
throw new RuntimeException("Don't know how to compute maven coordinate for artifact '" + artifact.getId().getDisplayName() + "' with component identifier of type '" + id.getClass() + "'.");
}
Aggregations