use of org.gradle.api.artifacts.component.ModuleComponentIdentifier in project gradle by gradle.
the class DefaultIdeDependencyResolver method getIdeRepoFileDependencies.
public List<IdeExtendedRepoFileDependency> getIdeRepoFileDependencies(Configuration configuration) {
Set<ResolvedArtifactResult> artifacts = configuration.getIncoming().artifactView(new Action<ArtifactView.ViewConfiguration>() {
@Override
public void execute(ArtifactView.ViewConfiguration viewConfiguration) {
viewConfiguration.lenient(true);
viewConfiguration.componentFilter(IS_A_MODULE_ID);
}
}).getArtifacts().getArtifacts();
List<IdeExtendedRepoFileDependency> externalDependencies = new ArrayList<IdeExtendedRepoFileDependency>(artifacts.size());
for (ResolvedArtifactResult artifact : artifacts) {
ModuleComponentIdentifier moduleId = (ModuleComponentIdentifier) artifact.getId().getComponentIdentifier();
IdeExtendedRepoFileDependency ideRepoFileDependency = new IdeExtendedRepoFileDependency();
ideRepoFileDependency.setId(DefaultModuleVersionIdentifier.newId(moduleId.getModuleIdentifier(), moduleId.getVersion()));
externalDependencies.add(ideRepoFileDependency);
}
return externalDependencies;
}
use of org.gradle.api.artifacts.component.ModuleComponentIdentifier in project SpongeCommon by SpongePowered.
the class OutputDependenciesToJson method configToDescriptor.
private List<DependencyDescriptor> configToDescriptor(final ArtifactCollection conf, final Set<ModuleComponentIdentifier> excludedDeps) {
return conf.getArtifacts().stream().filter(dep -> {
final ComponentIdentifier ident = dep.getId().getComponentIdentifier();
return ident instanceof ModuleComponentIdentifier && !excludedDeps.contains(ident);
}).distinct().map(dependency -> {
final ModuleComponentIdentifier id = (ModuleComponentIdentifier) dependency.getId().getComponentIdentifier();
// Get file input stream for reading the file content
final String md5hash;
try (final InputStream in = new FileInputStream(dependency.getFile())) {
final MessageDigest hasher = MessageDigest.getInstance("MD5");
final byte[] buf = new byte[4096];
int read;
while ((read = in.read(buf)) != -1) {
hasher.update(buf, 0, read);
}
md5hash = OutputDependenciesToJson.toHexString(hasher.digest());
} catch (final IOException | NoSuchAlgorithmException ex) {
throw new GradleException("Failed to create hash for " + dependency, ex);
}
// create descriptor
return new DependencyDescriptor(id.getGroup(), id.getModule(), id.getVersion(), md5hash);
}).sorted(// sort dependencies for stable output
Comparator.naturalOrder()).collect(Collectors.toList());
}
use of org.gradle.api.artifacts.component.ModuleComponentIdentifier in project gradle by gradle.
the class IvyBackedArtifactPublisher method toPublishMetaData.
private BuildableIvyModulePublishMetadata toPublishMetaData(Module module, Set<? extends ConfigurationInternal> configurations) {
ModuleComponentIdentifier id = DefaultModuleComponentIdentifier.newId(module.getGroup(), module.getName(), module.getVersion());
DefaultIvyModulePublishMetadata publishMetaData = new DefaultIvyModulePublishMetadata(id, module.getStatus());
configurationComponentMetaDataBuilder.addConfigurations(publishMetaData, configurations);
return publishMetaData;
}
use of org.gradle.api.artifacts.component.ModuleComponentIdentifier in project gradle by gradle.
the class IvyModuleDescriptorConverter method forIvyModuleDescriptor.
public ModuleDescriptorState forIvyModuleDescriptor(ModuleDescriptor ivyDescriptor) {
ModuleRevisionId moduleRevisionId = ivyDescriptor.getModuleRevisionId();
ModuleComponentIdentifier componentIdentifier = DefaultModuleComponentIdentifier.newId(moduleRevisionId.getOrganisation(), moduleRevisionId.getName(), moduleRevisionId.getRevision());
MutableModuleDescriptorState state = new MutableModuleDescriptorState(componentIdentifier, ivyDescriptor.getStatus(), ivyDescriptor.isDefault());
state.setBranch(moduleRevisionId.getBranch());
state.setDescription(ivyDescriptor.getDescription());
state.setPublicationDate(ivyDescriptor.getPublicationDate());
Map<NamespaceId, String> extraInfo = Cast.uncheckedCast(ivyDescriptor.getExtraInfo());
state.getExtraInfo().putAll(extraInfo);
for (ExcludeRule excludeRule : ivyDescriptor.getAllExcludeRules()) {
addExcludeRule(state, excludeRule);
}
return state;
}
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, ComponentSelectionContext result, VersionSelector requestedVersionMatcher, VersionSelector rejectedVersionSelector) {
Collection<SpecRuleAction<? super ComponentSelection>> rules = componentSelectionRules.getRules();
// Loop over all listed versions, sorted by LATEST first
for (ModuleComponentResolveState candidate : sortLatestFirst(versions)) {
MetadataProvider metadataProvider = createMetadataProvider(candidate);
boolean versionMatches = versionMatches(requestedVersionMatcher, candidate, metadataProvider);
if (metadataIsNotUsable(result, metadataProvider)) {
return;
}
String version = candidate.getVersion().getSource();
if (!versionMatches) {
result.notMatched(version);
continue;
}
if (rejectedVersionSelector != null && rejectedVersionSelector.accept(version)) {
// Mark this version as rejected and continue
result.rejected(version);
continue;
} else {
ModuleComponentIdentifier candidateIdentifier = candidate.getId();
if (!isRejectedByRules(candidateIdentifier, rules, metadataProvider)) {
result.matches(candidateIdentifier);
return;
}
}
// Mark this version as rejected
result.rejected(version);
if (requestedVersionMatcher.matchesUniqueVersion()) {
// Only consider one candidate, because matchesUniqueVersion means that there's no ambiguity on the version number
break;
}
}
// if we reach this point, no match was found, either because there are no versions matching the selector
// or all of them were rejected
result.noMatchFound();
}
Aggregations