use of org.gradle.internal.component.external.model.maven.MavenDependencyDescriptor in project gradle by gradle.
the class ModuleComponentResolveMetadataSerializer method read.
@Override
public ModuleComponentResolveMetadata read(Decoder decoder) throws EOFException, Exception {
Map<Integer, MavenDependencyDescriptor> deduplicationDependencyCache = Maps.newHashMap();
MutableModuleComponentResolveMetadata mutable = delegate.read(decoder, moduleIdentifierFactory, deduplicationDependencyCache);
readPlatformOwners(decoder, mutable);
AbstractLazyModuleComponentResolveMetadata resolveMetadata = (AbstractLazyModuleComponentResolveMetadata) mutable.asImmutable();
if (resolveMetadata instanceof DefaultIvyModuleResolveMetadata) {
return ivySerializationHelper.readMetadata(decoder, (DefaultIvyModuleResolveMetadata) resolveMetadata);
} else if (resolveMetadata instanceof DefaultMavenModuleResolveMetadata) {
return mavenSerializationHelper.readMetadata(decoder, (DefaultMavenModuleResolveMetadata) resolveMetadata, deduplicationDependencyCache);
} else {
throw new IllegalStateException("Unknown resolved metadata type: " + resolveMetadata.getClass());
}
}
use of org.gradle.internal.component.external.model.maven.MavenDependencyDescriptor in project gradle by gradle.
the class GradlePomModuleDescriptorBuilder method doAddDependency.
private void doAddDependency(PomDependencyMgt dep, MavenDependencyType dependencyType) {
MavenScope scope;
if (dependencyType == MavenDependencyType.DEPENDENCY_MANAGEMENT) {
scope = MavenScope.Compile;
} else {
String scopeString = dep.getScope();
if (scopeString == null || scopeString.length() == 0) {
scopeString = getDefaultScope(dep);
}
// unknown scope, defaulting to 'compile'
scope = SCOPES.getOrDefault(scopeString, MavenScope.Compile);
}
String version = determineVersion(dep);
String mappedVersion = convertVersionFromMavenSyntax(version);
ModuleComponentSelector selector = DefaultModuleComponentSelector.newSelector(DefaultModuleIdentifier.newId(dep.getGroupId(), dep.getArtifactId()), new DefaultImmutableVersionConstraint(mappedVersion));
// Example: http://repo2.maven.org/maven2/net/jini/jsk-platform/2.1/jsk-platform-2.1.pom
if (selector.getModuleIdentifier().equals(componentIdentifier.getModuleIdentifier())) {
return;
}
IvyArtifactName dependencyArtifact = null;
boolean hasClassifier = dep.getClassifier() != null && dep.getClassifier().length() > 0;
boolean hasNonJarType = dep.getType() != null && !"jar".equals(dep.getType());
if (hasClassifier || hasNonJarType) {
String type = "jar";
if (dep.getType() != null) {
type = dep.getType();
}
String ext = determineExtension(type);
String classifier = hasClassifier ? dep.getClassifier() : getClassifierForType(type);
dependencyArtifact = new DefaultIvyArtifactName(selector.getModule(), type, ext, classifier);
}
// experimentation shows the following, excluded modules are
// inherited from parent POMs if either of the following is true:
// the <exclusions> element is missing or the <exclusions> element
// is present, but empty.
List<ExcludeMetadata> excludes = Lists.newArrayList();
List<ModuleIdentifier> excluded = dep.getExcludedModules();
if (excluded.isEmpty()) {
excluded = getDependencyMgtExclusions(dep);
}
for (ModuleIdentifier excludedModule : excluded) {
DefaultExclude rule = new DefaultExclude(excludedModule);
excludes.add(rule);
}
dependencies.add(new MavenDependencyDescriptor(scope, dependencyType, selector, dependencyArtifact, excludes));
}
use of org.gradle.internal.component.external.model.maven.MavenDependencyDescriptor in project gradle by gradle.
the class GradlePomModuleDescriptorParser method doParseDescriptor.
@Override
protected ParseResult<MutableMavenModuleResolveMetadata> doParseDescriptor(DescriptorParseContext parserSettings, LocallyAvailableExternalResource resource, boolean validate) throws IOException, ParseException, SAXException {
PomReader pomReader = new PomReader(resource, moduleIdentifierFactory);
GradlePomModuleDescriptorBuilder mdBuilder = new GradlePomModuleDescriptorBuilder(pomReader, gradleVersionSelectorScheme, mavenVersionSelectorScheme);
doParsePom(parserSettings, mdBuilder, pomReader);
List<MavenDependencyDescriptor> dependencies = mdBuilder.getDependencies();
ModuleComponentIdentifier cid = mdBuilder.getComponentIdentifier();
MutableMavenModuleResolveMetadata metadata = metadataFactory.create(cid, dependencies);
metadata.setStatus(mdBuilder.getStatus());
if (pomReader.getRelocation() != null) {
metadata.setPackaging("pom");
metadata.setRelocated(true);
} else {
metadata.setPackaging(pomReader.getPackaging());
metadata.setRelocated(false);
}
return ParseResult.of(metadata, pomReader.hasGradleMetadataMarker());
}
use of org.gradle.internal.component.external.model.maven.MavenDependencyDescriptor in project gradle by gradle.
the class DirectDependencyMetadataAdapter method getIvyArtifacts.
private List<IvyArtifactName> getIvyArtifacts() {
ModuleDependencyMetadata originalMetadata = getOriginalMetadata();
if (originalMetadata instanceof ConfigurationBoundExternalDependencyMetadata) {
ConfigurationBoundExternalDependencyMetadata externalMetadata = (ConfigurationBoundExternalDependencyMetadata) originalMetadata;
ExternalDependencyDescriptor descriptor = externalMetadata.getDependencyDescriptor();
if (descriptor instanceof MavenDependencyDescriptor) {
return fromMavenDescriptor((MavenDependencyDescriptor) descriptor);
}
if (descriptor instanceof IvyDependencyDescriptor) {
return fromIvyDescriptor((IvyDependencyDescriptor) descriptor);
}
} else if (originalMetadata instanceof GradleDependencyMetadata) {
return fromGradleMetadata((GradleDependencyMetadata) originalMetadata);
}
return Collections.emptyList();
}
Aggregations