public void addDependencyForRelocation(ModuleVersionSelector selector) { // Some POMs depend on themselves through their parent POM, don't add this dependency // since Ivy doesn't allow this! // Example: http://repo2.maven.org/maven2/com/atomikos/atomikos-util/3.6.4/atomikos-util-3.6.4.pom if (selector.getGroup().equals(descriptor.getComponentIdentifier().getGroup()) && selector.getName().equals(descriptor.getComponentIdentifier().getModule())) { return; } // TODO - this is a constant ListMultimap<String, String> confMappings = ArrayListMultimap.create(); // Map dependency on all public configurations for (Configuration m2Conf : GradlePomModuleDescriptorBuilder.MAVEN2_CONFIGURATIONS.values()) { if (m2Conf.isVisible()) { confMappings.put(m2Conf.getName(), m2Conf.getName()); } } dependencies.add(new IvyDependencyMetadata(selector, confMappings)); }
private void listModuleVersionsFromCache(DependencyMetadata dependency, BuildableModuleVersionListingResolveResult result) { ModuleVersionSelector requested = dependency.getRequested(); final ModuleIdentifier moduleId = getCacheKey(requested); ModuleVersionsCache.CachedModuleVersionList cachedModuleVersionList = moduleVersionsCache.getCachedModuleResolution(delegate, moduleId); if (cachedModuleVersionList != null) { Set<String> versionList = cachedModuleVersionList.getModuleVersions(); Set<ModuleVersionIdentifier> versions = CollectionUtils.collect(versionList, new Transformer<ModuleVersionIdentifier, String>() { public ModuleVersionIdentifier transform(String original) { return new DefaultModuleVersionIdentifier(moduleId, original); } }); if (cachePolicy.mustRefreshVersionList(moduleId, versions, cachedModuleVersionList.getAgeMillis())) { LOGGER.debug("Version listing in dynamic revision cache is expired: will perform fresh resolve of '{}' in '{}'", requested, delegate.getName()); } else { result.listed(versionList); // When age == 0, verified since the start of this build, assume listing hasn't changed result.setAuthoritative(cachedModuleVersionList.getAgeMillis() == 0); } } }
public void resolve(DependencyMetadata dependency, BuildableComponentIdResolveResult result) { ModuleVersionSelector requested = dependency.getRequested(); LOGGER.debug("Attempting to resolve version for {} using repositories {}", requested, repositoryNames); List<Throwable> errors = new ArrayList<Throwable>(); List<RepositoryResolveState> resolveStates = new ArrayList<RepositoryResolveState>(); for (ModuleComponentRepository repository : repositories) { resolveStates.add(new RepositoryResolveState(dependency, repository)); } final RepositoryChainModuleResolution latestResolved = findLatestModule(resolveStates, errors); if (latestResolved != null) { LOGGER.debug("Using {} from {}", latestResolved.module.getId(), latestResolved.repository); for (Throwable error : errors) { LOGGER.debug("Discarding resolve failure.", error); } result.resolved(metaDataFactory.transform(latestResolved)); return; } if (!errors.isEmpty()) { result.failed(new ModuleVersionResolveException(requested, errors)); } else { notFound(result, requested, resolveStates); } }
public DslOriginDependencyMetadata createDependencyDescriptor(String clientConfiguration, AttributeContainer clientAttributes, ModuleDependency dependency) { ProjectDependencyInternal projectDependency = (ProjectDependencyInternal) dependency; projectDependency.beforeResolved(); Module module = getProjectModule(dependency); ModuleVersionSelector requested = new DefaultModuleVersionSelector(module.getGroup(), module.getName(), module.getVersion()); ComponentSelector selector = DefaultProjectComponentSelector.newSelector(projectDependency.getDependencyProject()); LocalComponentDependencyMetadata dependencyMetaData = new LocalComponentDependencyMetadata( selector, requested, clientConfiguration, clientAttributes, projectDependency.getTargetConfiguration(), convertArtifacts(dependency.getArtifacts()), convertExcludeRules(clientConfiguration, dependency.getExcludeRules()), false, false, dependency.isTransitive()); return new DslOriginDependencyMetadataWrapper(dependencyMetaData, dependency); }
public DslOriginDependencyMetadata createDependencyDescriptor(String clientConfiguration, AttributeContainer clientAttributes, ModuleDependency dependency) { ExternalModuleDependency externalModuleDependency = (ExternalModuleDependency) dependency; boolean force = externalModuleDependency.isForce(); boolean changing = externalModuleDependency.isChanging(); boolean transitive = externalModuleDependency.isTransitive(); ModuleVersionSelector requested = new DefaultModuleVersionSelector(nullToEmpty(dependency.getGroup()), nullToEmpty(dependency.getName()), nullToEmpty(dependency.getVersion())); ModuleComponentSelector selector = DefaultModuleComponentSelector.newSelector(requested); LocalComponentDependencyMetadata dependencyMetaData = new LocalComponentDependencyMetadata( selector, requested, clientConfiguration, clientAttributes, dependency.getTargetConfiguration(), convertArtifacts(dependency.getArtifacts()), convertExcludeRules(clientConfiguration, dependency.getExcludeRules()), force, changing, transitive); return new DslOriginDependencyMetadataWrapper(dependencyMetaData, dependency); }
public void convert(String notation, NotationConvertResult<? super ModuleVersionSelector> result) throws TypeConversionException { ParsedModuleStringNotation parsed; try { parsed = new ParsedModuleStringNotation(notation, null); } catch (IllegalDependencyNotation e) { throw new InvalidUserDataException( "Invalid format: '" + notation + "'. The correct notation is a 3-part group:name:version notation, " + "e.g: 'org.gradle:gradle-core:1.0'"); } if (parsed.getGroup() == null || parsed.getName() == null || parsed.getVersion() == null) { throw new InvalidUserDataException( "Invalid format: '" + notation + "'. Group, name and version cannot be empty. Correct example: " + "'org.gradle:gradle-core:1.0'"); } result.converted(newSelector(parsed.getGroup(), parsed.getName(), parsed.getVersion())); }
private static String format(ModuleVersionSelector selector, Collection<String> locations, Collection<String> unmatchedVersions, Collection<String> rejectedVersions) { StringBuilder builder = new StringBuilder(); if (unmatchedVersions.isEmpty() && rejectedVersions.isEmpty()) { builder.append(String.format("Could not find any matches for %s as no versions of %s:%s are available.", selector, selector.getGroup(), selector.getName())); } else { builder.append(String.format("Could not find any version that matches %s.", selector)); if (!unmatchedVersions.isEmpty()) { builder.append(String.format("%nVersions that do not match:")); appendSizeLimited(builder, unmatchedVersions); } if (!rejectedVersions.isEmpty()) { builder.append(String.format("%nVersions rejected by component selection rules:")); appendSizeLimited(builder, rejectedVersions); } } addLocations(builder, locations); return builder.toString(); }
@Override public DependencyMetadata withTarget(ComponentSelector target) { if (target instanceof ModuleComponentSelector) { ModuleComponentSelector moduleTarget = (ModuleComponentSelector) target; ModuleVersionSelector requestedVersion = DefaultModuleVersionSelector.newSelector(moduleTarget.getGroup(), moduleTarget.getModule(), moduleTarget.getVersion()); if (requestedVersion.equals(requested)) { return this; } return withRequested(requestedVersion); } else if (target instanceof ProjectComponentSelector) { ProjectComponentSelector projectTarget = (ProjectComponentSelector) target; return new DefaultProjectDependencyMetadata(projectTarget, this); } else { throw new IllegalArgumentException("Unexpected selector provided: " + target); } }
public LocalComponentDependencyMetadata(ComponentSelector selector, ModuleVersionSelector requested, String moduleConfiguration, AttributeContainer moduleAttributes, String dependencyConfiguration, Set<IvyArtifactName> artifactNames, List<Exclude> excludes, boolean force, boolean changing, boolean transitive) { this.selector = selector; this.requested = requested; this.moduleConfiguration = moduleConfiguration; this.moduleAttributes = moduleAttributes; this.dependencyConfiguration = dependencyConfiguration; this.artifactNames = artifactNames; this.excludes = excludes; this.exclusions = ModuleExclusions.excludeAny(excludes); this.force = force; this.changing = changing; this.transitive = transitive; }
@Override public LocalOriginDependencyMetadata withTarget(ComponentSelector target) { if (target instanceof ModuleComponentSelector) { ModuleComponentSelector moduleTarget = (ModuleComponentSelector) target; ModuleVersionSelector requestedVersion = DefaultModuleVersionSelector.newSelector(moduleTarget.getGroup(), moduleTarget.getModule(), moduleTarget.getVersion()); if (selector.equals(target) && requested.equals(requestedVersion)) { return this; } return copyWithTarget(moduleTarget, requestedVersion); } else if (target instanceof ProjectComponentSelector) { if (target.equals(selector)) { return this; } return copyWithTarget(target, requested); } else { throw new AssertionError("Invalid component selector type for substitution: " + target); } }
public ModuleComponentIdentifier choose(ModuleVersionListing versions, DependencyMetaData dependency, ModuleComponentRepositoryAccess moduleAccess) { ModuleVersionSelector requested = dependency.getRequested(); Collection<SpecRuleAction<? super ComponentSelection>> rules = componentSelectionRules.getRules(); for (Versioned candidate : sortLatestFirst(versions)) { ModuleComponentIdentifier candidateIdentifier = DefaultModuleComponentIdentifier.newId(requested.getGroup(), requested.getName(), candidate.getVersion()); MetaDataSupplier metaDataSupplier = new MetaDataSupplier(dependency, candidateIdentifier, moduleAccess); if (versionMatches(requested, candidateIdentifier, metaDataSupplier)) { if (!isRejectedByRules(candidateIdentifier, rules, metaDataSupplier)) { return candidateIdentifier; } if (versionMatcher.matchesUniqueVersion(requested.getVersion())) { break; } } } return null; }
private void listModuleVersionsFromCache(DependencyMetaData dependency, BuildableModuleComponentVersionSelectionResolveResult result) { ModuleVersionSelector requested = dependency.getRequested(); final ModuleIdentifier moduleId = getCacheKey(requested); ModuleVersionsCache.CachedModuleVersionList cachedModuleVersionList = moduleVersionsCache.getCachedModuleResolution(delegate, moduleId); if (cachedModuleVersionList != null) { ModuleVersionListing versionList = cachedModuleVersionList.getModuleVersions(); Set<ModuleVersionIdentifier> versions = CollectionUtils.collect(versionList.getVersions(), new Transformer<ModuleVersionIdentifier, Versioned>() { public ModuleVersionIdentifier transform(Versioned original) { return new DefaultModuleVersionIdentifier(moduleId, original.getVersion()); } }); if (cachePolicy.mustRefreshVersionList(moduleId, versions, cachedModuleVersionList.getAgeMillis())) { LOGGER.debug("Version listing in dynamic revision cache is expired: will perform fresh resolve of '{}' in '{}'", requested, delegate.getName()); } else { result.listed(versionList); // When age == 0, verified since the start of this build, assume listing hasn't changed result.setAuthoritative(cachedModuleVersionList.getAgeMillis() == 0); } } }
public void resolve(DependencyMetaData dependency, BuildableComponentIdResolveResult result) { ModuleVersionSelector module = dependency.getRequested(); DefaultDependencyResolveDetails details = new DefaultDependencyResolveDetails(module); try { rule.execute(details); } catch (Throwable e) { result.failed(new ModuleVersionResolveException(module, e)); return; } if (details.isUpdated()) { DependencyMetaData substitutedDependency = dependency.withRequestedVersion(details.getTarget()); resolver.resolve(substitutedDependency, result); result.setSelectionReason(details.getSelectionReason()); return; } resolver.resolve(dependency, result); }
public void resolve(DependencyMetaData dependency, BuildableComponentResolveResult result) { ModuleVersionSelector requested = dependency.getRequested(); LOGGER.debug("Attempting to resolve module '{}' using repositories {}", requested, moduleVersionRepositoryNames); List<Throwable> errors = new ArrayList<Throwable>(); final RepositoryChainModuleResolution latestResolved = findLatestModule(dependency, errors); if (latestResolved != null) { LOGGER.debug("Using module '{}' from repository '{}'", latestResolved.module.getId(), latestResolved.repository.getName()); for (Throwable error : errors) { LOGGER.debug("Discarding resolve failure.", error); } result.resolved(metaDataFactory.transform(latestResolved)); return; } if (!errors.isEmpty()) { result.failed(new ModuleVersionResolveException(requested, errors)); } else { result.notFound(requested); } }
private boolean getBestMatchingDependencyWithMetaData(DependencyMetaData dependency, ModuleAccess moduleAccess) { ModuleVersionSelector selector = dependency.getRequested(); for (Versioned candidate : selectionResult.getVersions().sortLatestFirst(latestStrategy)) { // Resolve the metadata DependencyMetaData moduleVersionDependency = dependency.withRequestedVersion(candidate.getVersion()); moduleAccess.getDependency(moduleVersionDependency, resolveResult); if (resolveResult.getState() != BuildableModuleVersionMetaDataResolveResult.State.Resolved) { // Couldn't load listed module LOGGER.warn("Could not load metadata for '{}' of listed module '{}' - ignoring.", candidate, selector); resolveResult.reset(); return true; } if (versionMatcher.accept(selector.getVersion(), resolveResult.getMetaData())) { // We already resolved the correct module. return true; } resolveResult.reset(); } return false; }
public void localListModuleVersions(DependencyMetaData dependency, BuildableModuleVersionSelectionResolveResult result) { ModuleVersionSelector requested = dependency.getRequested(); final ModuleIdentifier moduleId = moduleExtractor.transform(requested); ModuleVersionsCache.CachedModuleVersionList cachedModuleVersionList = moduleVersionsCache.getCachedModuleResolution(delegate, moduleId); if (cachedModuleVersionList != null) { ModuleVersionListing versionList = cachedModuleVersionList.getModuleVersions(); Set<ModuleVersionIdentifier> versions = CollectionUtils.collect(versionList.getVersions(), new Transformer<ModuleVersionIdentifier, Versioned>() { public ModuleVersionIdentifier transform(Versioned original) { return new DefaultModuleVersionIdentifier(moduleId, original.getVersion()); } }); if (cachePolicy.mustRefreshVersionList(moduleId, versions, cachedModuleVersionList.getAgeMillis())) { LOGGER.debug("Version listing in dynamic revision cache is expired: will perform fresh resolve of '{}' in '{}'", requested, delegate.getName()); } else { if (cachedModuleVersionList.getAgeMillis() == 0) { // Verified since the start of this build, assume still missing result.listed(versionList); } else { // Was missing last time we checked result.probablyListed(versionList); } } } }
public ModuleVersionSelector parseType(CharSequence notation) { ParsedModuleStringNotation parsed; try { parsed = new ParsedModuleStringNotation(notation.toString(), null); } catch (IllegalDependencyNotation e) { throw new InvalidUserDataException( "Invalid format: '" + notation + "'. The Correct notation is a 3-part group:name:version notation, " + "e.g: 'org.gradle:gradle-core:1.0'"); } if (parsed.getGroup() == null || parsed.getName() == null || parsed.getVersion() == null) { throw new InvalidUserDataException( "Invalid format: '" + notation + "'. Group, name and version cannot be empty. Correct example: " + "'org.gradle:gradle-core:1.0'"); } return newSelector(parsed.getGroup(), parsed.getName(), parsed.getVersion()); }
protected MutableModuleVersionMetaData findMetaDataArtifact(DependencyMetaData dependency, ArtifactResolver artifactResolver) { ModuleVersionArtifactMetaData artifact = getMetaDataArtifactFor(dependency); if (artifact == null) { return null; } ExternalResource metaDataResource = artifactResolver.resolveMetaDataArtifact(artifact); if (metaDataResource == null) { return null; } MutableModuleVersionMetaData moduleVersionMetaData = getArtifactMetadata(artifact, metaDataResource); if (isCheckconsistency()) { ModuleVersionSelector requested = dependency.getRequested(); ModuleVersionIdentifier requestedId = DefaultModuleVersionIdentifier.newId(requested.getGroup(), requested.getName(), requested.getVersion()); checkMetadataConsistency(requestedId, moduleVersionMetaData); } return moduleVersionMetaData; }
private LocalOriginDependencyMetadata moduleDependencyMetadata(ModuleDependencySpec moduleDependency, String usageConfigurationName) { ModuleVersionSelector requested = moduleVersionSelectorFrom(moduleDependency); ModuleComponentSelector selector = DefaultModuleComponentSelector.newSelector(requested); // TODO: This hard-codes the assumption of a 'compile' configuration on the external module // Instead, we should be creating an API configuration for each resolved module return dependencyMetadataFor(selector, requested, usageConfigurationName, CONFIGURATION_COMPILE); }
/** * This generates local dependency metadata for a dependency, but with a specific trick: normally, "usage" represents * the kind of dependency which is requested. For example, a library may require the API of a component, or the runtime of a component. * However, for external dependencies, there's no configuration called 'API' or 'runtime': we're mapping them to 'compile', which is * assumed to exist. Therefore, this method takes 2 arguments: one is the requested usage ("API") and the other is the mapped usage * ("compile"). For local libraries, both should be equal, but for external dependencies, they will be different. */ private LocalOriginDependencyMetadata dependencyMetadataFor(ComponentSelector selector, ModuleVersionSelector requested, String usageConfigurationName, String mappedUsageConfiguration) { return new LocalComponentDependencyMetadata( selector, requested, usageConfigurationName, null, mappedUsageConfiguration, Collections.<IvyArtifactName>emptySet(), EXCLUDE_RULES, false, false, true); }
public ModuleForcingResolveRule(Collection<? extends ModuleVersionSelector> forcedModules) { if (!forcedModules.isEmpty()) { this.forcedModules = new HashMap<ModuleIdentifier, String>(); for (ModuleVersionSelector module : forcedModules) { this.forcedModules.put(new DefaultModuleIdentifier(module.getGroup(), module.getName()), module.getVersion()); } } else { this.forcedModules = null; } }
public DefaultResolutionStrategy setForcedModules(Object ... moduleVersionSelectorNotations) { mutationValidator.validateMutation(STRATEGY); Set<ModuleVersionSelector> modules = ModuleVersionSelectorParsers.multiParser().parseNotation(moduleVersionSelectorNotations); this.forcedModules.clear(); this.forcedModules.addAll(modules); return this; }
private static ModuleVersionSelector determineTarget(DependencySubstitutionInternal delegate) { // Temporary logic until we add DependencySubstitution back in if (delegate.getTarget() instanceof ModuleComponentSelector) { ModuleComponentSelector moduleComponentSelector = (ModuleComponentSelector) delegate.getTarget(); return DefaultModuleVersionSelector.newSelector(moduleComponentSelector.getGroup(), moduleComponentSelector.getModule(), moduleComponentSelector.getVersion()); } // If the target is a project component, it must be unmodified from the requested return delegate.getOldRequested(); }
protected void printDependency(IvyModulePublishMetadata metadata, LocalOriginDependencyMetadata dep, SimpleXmlWriter writer) throws IOException { writer.startElement("dependency"); ModuleVersionSelector requested = dep.getRequested(); writer.attribute("org", requested.getGroup()); writer.attribute("name", requested.getName()); writer.attribute("rev", requested.getVersion()); if (dep.getDynamicConstraintVersion() != null && !dep.getDynamicConstraintVersion().equals(requested.getVersion())) { writer.attribute("revConstraint", dep.getDynamicConstraintVersion()); } if (dep.isForce()) { writer.attribute("force", "true"); } if (dep.isChanging()) { writer.attribute("changing", "true"); } if (!dep.isTransitive()) { writer.attribute("transitive", "false"); } writer.attribute("conf", getConfMapping(dep)); for (IvyArtifactName dependencyArtifact : dep.getArtifacts()) { printDependencyArtifact(writer, dependencyArtifact, dep.getModuleConfiguration()); } printDependencyExcludeRules(metadata, writer, dep.getExcludes()); writer.endElement(); }
private static void addDependency(List<IvyDependencyMetadata> result, DependencyDescriptor dependencyDescriptor) { ModuleRevisionId revisionId = dependencyDescriptor.getDependencyRevisionId(); ModuleVersionSelector requested = DefaultModuleVersionSelector.newSelector(revisionId.getOrganisation(), revisionId.getName(), revisionId.getRevision()); ListMultimap<String, String> configMappings = ArrayListMultimap.create(); for (Map.Entry<String, List<String>> entry : readConfigMappings(dependencyDescriptor).entrySet()) { configMappings.putAll(entry.getKey(), entry.getValue()); } List<Artifact> artifacts = Lists.newArrayList(); for (DependencyArtifactDescriptor ivyArtifact : dependencyDescriptor.getAllDependencyArtifacts()) { IvyArtifactName ivyArtifactName = new DefaultIvyArtifactName(ivyArtifact.getName(), ivyArtifact.getType(), ivyArtifact.getExt(), (String) ivyArtifact.getExtraAttributes().get(CLASSIFIER)); artifacts.add(new Artifact(ivyArtifactName, Sets.newHashSet(ivyArtifact.getConfigurations()))); } List<Exclude> excludes = Lists.newArrayList(); for (ExcludeRule excludeRule : dependencyDescriptor.getAllExcludeRules()) { excludes.add(forIvyExclude(excludeRule)); } result.add(new IvyDependencyMetadata( requested, dependencyDescriptor.getDynamicConstraintDependencyRevisionId().getRevision(), false, dependencyDescriptor.isChanging(), dependencyDescriptor.isTransitive(), configMappings, artifacts, excludes)); }
public boolean supplyModuleVersions(ModuleVersionSelector requested, BuildableModuleVersionListingResolveResult result) { Set<String> versions = moduleVersionListing.get(requested); if (versions == null) { return false; } result.listed(versions); return true; }
public void resolve(DependencyMetadata dependency, BuildableComponentIdResolveResult result) { ModuleVersionSelector requested = dependency.getRequested(); if (versionSelectorScheme.parseSelector(requested.getVersion()).isDynamic()) { dynamicRevisionResolver.resolve(dependency, result); } else { DefaultModuleComponentIdentifier id = new DefaultModuleComponentIdentifier(requested.getGroup(), requested.getName(), requested.getVersion()); DefaultModuleVersionIdentifier mvId = new DefaultModuleVersionIdentifier(requested.getGroup(), requested.getName(), requested.getVersion()); result.resolved(id, mvId); } }
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 = new MetadataProvider(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(); }
private void notFound(BuildableComponentIdResolveResult result, ModuleVersionSelector requested, List<RepositoryResolveState> resolveStates) { Set<String> unmatchedVersions = new LinkedHashSet<String>(); Set<String> rejectedVersions = new LinkedHashSet<String>(); for (RepositoryResolveState resolveState : resolveStates) { resolveState.applyTo(result, unmatchedVersions, rejectedVersions); } result.failed(new ModuleVersionNotFoundException(requested, result.getAttempted(), unmatchedVersions, rejectedVersions)); }
public CandidateResult(DependencyMetadata dependencyMetadata, String version, ModuleComponentRepository repository, AttemptCollector attemptCollector) { this.dependencyMetadata = dependencyMetadata; this.version = version; this.repository = repository; this.attemptCollector = attemptCollector; ModuleVersionSelector requested = dependencyMetadata.getRequested(); this.identifier = DefaultModuleComponentIdentifier.newId(requested.getGroup(), requested.getName(), version); }
private void writeDependency(DependencyMetadata dep) throws IOException { ModuleVersionSelector selector = dep.getRequested(); writeString(selector.getGroup()); writeString(selector.getName()); writeString(selector.getVersion()); if (dep instanceof IvyDependencyMetadata) { IvyDependencyMetadata ivyDependency = (IvyDependencyMetadata) dep; encoder.writeByte(TYPE_IVY); writeDependencyConfigurationMapping(ivyDependency); writeArtifacts(ivyDependency.getDependencyArtifacts()); writeExcludeRules(ivyDependency.getDependencyExcludes()); writeString(ivyDependency.getDynamicConstraintVersion()); writeBoolean(ivyDependency.isForce()); writeBoolean(ivyDependency.isChanging()); writeBoolean(ivyDependency.isTransitive()); } else if (dep instanceof MavenDependencyMetadata) { MavenDependencyMetadata mavenDependency = (MavenDependencyMetadata) dep; encoder.writeByte(TYPE_MAVEN); writeArtifacts(mavenDependency.getDependencyArtifacts()); writeExcludeRules(mavenDependency.getDependencyExcludes()); encoder.writeSmallInt(mavenDependency.getScope().ordinal()); encoder.writeBoolean(mavenDependency.isOptional()); } else { throw new IllegalStateException("Unexpected dependency type"); } }
private DependencyMetadata readDependency() throws IOException { ModuleVersionSelector requested = DefaultModuleVersionSelector.newSelector(readString(), readString(), readString()); byte type = decoder.readByte(); switch (type) { case TYPE_IVY: SetMultimap<String, String> configMappings = readDependencyConfigurationMapping(); List<Artifact> artifacts = readDependencyArtifactDescriptors(); List<Exclude> excludes = readExcludeRules(); String dynamicConstraintVersion = readString(); boolean force = readBoolean(); boolean changing = readBoolean(); boolean transitive = readBoolean(); return new IvyDependencyMetadata(requested, dynamicConstraintVersion, force, changing, transitive, configMappings, artifacts, excludes); case TYPE_MAVEN: artifacts = readDependencyArtifactDescriptors(); excludes = readExcludeRules(); MavenScope scope = MavenScope.values()[decoder.readSmallInt()]; boolean optional = decoder.readBoolean(); return new MavenDependencyMetadata(scope, optional, requested, artifacts, excludes); default: throw new IllegalArgumentException("Unexpected dependency type found."); } }
private void addUnresolvedDependency(DependencyGraphEdge dependency, ModuleVersionSelector requested, ModuleVersionResolveException failure) { BrokenDependency breakage = failuresByRevisionId.get(requested); if (breakage == null) { breakage = new BrokenDependency(failure); failuresByRevisionId.put(requested, breakage); } breakage.requiredBy.add(dependency.getFrom()); }
public ModuleVersionSelectorResolveState getSelector(DependencyMetadata dependencyMetadata) { ModuleVersionSelector requested = dependencyMetadata.getRequested(); ModuleVersionSelectorResolveState resolveState = selectors.get(requested); if (resolveState == null) { resolveState = new ModuleVersionSelectorResolveState(dependencyMetadata, idResolver, this); selectors.put(requested, resolveState); } return resolveState; }
@Override public DependencyMetadata withRequestedVersion(String requestedVersion) { if (requestedVersion.equals(requested.getVersion())) { return this; } ModuleVersionSelector newRequested = DefaultModuleVersionSelector.newSelector(requested.getGroup(), requested.getName(), requestedVersion); return withRequested(newRequested); }
public MavenDependencyMetadata(MavenScope scope, boolean optional, ModuleVersionSelector requested, List<Artifact> artifacts, List<Exclude> excludes) { super(requested, artifacts); this.scope = scope; this.optional = optional; if (optional && scope != MavenScope.Test && scope != MavenScope.System) { moduleConfigurations = ImmutableSet.of("optional"); } else { moduleConfigurations = ImmutableSet.of(scope.name().toLowerCase()); } this.excludes = ImmutableList.copyOf(excludes); this.exclusions = ModuleExclusions.excludeAny(excludes); }
public IvyDependencyMetadata(ModuleVersionSelector requested, String dynamicConstraintVersion, boolean force, boolean changing, boolean transitive, Multimap<String, String> confMappings, List<Artifact> artifacts, List<Exclude> excludes) { super(requested, artifacts); this.dynamicConstraintVersion = dynamicConstraintVersion; this.force = force; this.changing = changing; this.transitive = transitive; this.confs = ImmutableSetMultimap.copyOf(confMappings); this.excludes = ImmutableList.copyOf(excludes); }
@Override public void execute(DependencyResolveDetails dep) { ModuleVersionSelector requested = dep.getRequested(); final String version = requested.getVersion(); if (SrcVersion.isSrcVersion(version)) { final SrcdepsService srcdepsService = Wiring.getInjector().getInstance(SrcdepsService.class); srcdepsService.buildIfNecessary(requested.getGroup(), requested.getName(), version); } }