use of org.eclipse.aether.artifact.DefaultArtifactType in project buck by facebook.
the class Resolver method getDependenciesFromPom.
private ImmutableList<Dependency> getDependenciesFromPom(Model model) {
return model.getDependencies().stream().map(dep -> {
ArtifactType stereotype = session.getArtifactTypeRegistry().get(dep.getType());
if (stereotype == null) {
stereotype = new DefaultArtifactType(dep.getType());
}
Map<String, String> props = null;
boolean system = dep.getSystemPath() != null && dep.getSystemPath().length() > 0;
if (system) {
props = ImmutableMap.of(ArtifactProperties.LOCAL_PATH, dep.getSystemPath());
}
@SuppressWarnings("PMD.PrematureDeclaration") DefaultArtifact artifact = new DefaultArtifact(dep.getGroupId(), dep.getArtifactId(), dep.getClassifier(), null, dep.getVersion(), props, stereotype);
ImmutableList<Exclusion> exclusions = FluentIterable.from(dep.getExclusions()).transform(input -> {
String group = input.getGroupId();
String artifact1 = input.getArtifactId();
group = (group == null || group.length() == 0) ? "*" : group;
artifact1 = (artifact1 == null || artifact1.length() == 0) ? "*" : artifact1;
return new Exclusion(group, artifact1, "*", "*");
}).toList();
return new Dependency(artifact, dep.getScope(), dep.isOptional(), exclusions);
}).collect(MoreCollectors.toImmutableList());
}
use of org.eclipse.aether.artifact.DefaultArtifactType in project fabric8 by jboss-fuse.
the class AetherBasedResolver method newRepositorySystemSession.
private static DefaultRepositorySystemSession newRepositorySystemSession() {
DefaultRepositorySystemSession session = new DefaultRepositorySystemSession();
DependencyTraverser depTraverser = new FatArtifactTraverser();
session.setDependencyTraverser(depTraverser);
DependencyManager depManager = new ClassicDependencyManager();
session.setDependencyManager(depManager);
DependencySelector depFilter = new AndDependencySelector(new ScopeDependencySelector("test", "provided"), new OptionalDependencySelector(), new ExclusionDependencySelector());
session.setDependencySelector(depFilter);
DependencyGraphTransformer transformer = new ConflictResolver(new NearestVersionSelector(), new JavaScopeSelector(), new SimpleOptionalitySelector(), new JavaScopeDeriver());
new ChainedDependencyGraphTransformer(transformer, new JavaDependencyContextRefiner());
session.setDependencyGraphTransformer(transformer);
DefaultArtifactTypeRegistry stereotypes = new DefaultArtifactTypeRegistry();
stereotypes.add(new DefaultArtifactType("pom"));
stereotypes.add(new DefaultArtifactType("maven-plugin", "jar", "", "java"));
stereotypes.add(new DefaultArtifactType("jar", "jar", "", "java"));
stereotypes.add(new DefaultArtifactType("ejb", "jar", "", "java"));
stereotypes.add(new DefaultArtifactType("ejb-client", "jar", "client", "java"));
stereotypes.add(new DefaultArtifactType("test-jar", "jar", "tests", "java"));
stereotypes.add(new DefaultArtifactType("javadoc", "jar", "javadoc", "java"));
stereotypes.add(new DefaultArtifactType("java-source", "jar", "sources", "java", false, false));
stereotypes.add(new DefaultArtifactType("war", "war", "", "java", false, true));
stereotypes.add(new DefaultArtifactType("ear", "ear", "", "java", false, true));
stereotypes.add(new DefaultArtifactType("rar", "rar", "", "java", false, true));
stereotypes.add(new DefaultArtifactType("par", "par", "", "java", false, true));
session.setArtifactTypeRegistry(stereotypes);
session.setArtifactDescriptorPolicy(new SimpleArtifactDescriptorPolicy(true, true));
Properties sysProps = (Properties) System.getProperties().clone();
session.setSystemProperties(sysProps);
session.setConfigProperties(sysProps);
// set timeout smaller than 30 minutes by default
session.setConfigProperty(ConfigurationProperties.REQUEST_TIMEOUT, TimeUnit.MINUTES.toMillis(5));
return session;
}
Aggregations