1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.supplier;
20
21 import java.util.function.Supplier;
22
23 import org.eclipse.aether.RepositorySystem;
24 import org.eclipse.aether.RepositorySystemSession.CloseableSession;
25 import org.eclipse.aether.RepositorySystemSession.SessionBuilder;
26 import org.eclipse.aether.artifact.ArtifactTypeRegistry;
27 import org.eclipse.aether.artifact.DefaultArtifactType;
28 import org.eclipse.aether.collection.DependencyGraphTransformer;
29 import org.eclipse.aether.collection.DependencyManager;
30 import org.eclipse.aether.collection.DependencySelector;
31 import org.eclipse.aether.collection.DependencyTraverser;
32 import org.eclipse.aether.resolution.ArtifactDescriptorPolicy;
33 import org.eclipse.aether.util.artifact.DefaultArtifactTypeRegistry;
34 import org.eclipse.aether.util.graph.manager.ClassicDependencyManager;
35 import org.eclipse.aether.util.graph.selector.AndDependencySelector;
36 import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector;
37 import org.eclipse.aether.util.graph.selector.OptionalDependencySelector;
38 import org.eclipse.aether.util.graph.selector.ScopeDependencySelector;
39 import org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer;
40 import org.eclipse.aether.util.graph.transformer.ConflictResolver;
41 import org.eclipse.aether.util.graph.transformer.JavaDependencyContextRefiner;
42 import org.eclipse.aether.util.graph.transformer.JavaScopeDeriver;
43 import org.eclipse.aether.util.graph.transformer.JavaScopeSelector;
44 import org.eclipse.aether.util.graph.transformer.NearestVersionSelector;
45 import org.eclipse.aether.util.graph.transformer.SimpleOptionalitySelector;
46 import org.eclipse.aether.util.graph.traverser.FatArtifactTraverser;
47 import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy;
48
49 import static java.util.Objects.requireNonNull;
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65 @Deprecated
66 public class SessionBuilderSupplier implements Supplier<SessionBuilder> {
67 protected final RepositorySystem repositorySystem;
68
69 public SessionBuilderSupplier(RepositorySystem repositorySystem) {
70 this.repositorySystem = requireNonNull(repositorySystem);
71 }
72
73 protected void configureSessionBuilder(SessionBuilder session) {
74 session.setDependencyTraverser(getDependencyTraverser());
75 session.setDependencyManager(getDependencyManager());
76 session.setDependencySelector(getDependencySelector());
77 session.setDependencyGraphTransformer(getDependencyGraphTransformer());
78 session.setArtifactTypeRegistry(getArtifactTypeRegistry());
79 session.setArtifactDescriptorPolicy(getArtifactDescriptorPolicy());
80 }
81
82 protected DependencyTraverser getDependencyTraverser() {
83 return new FatArtifactTraverser();
84 }
85
86 protected DependencyManager getDependencyManager() {
87 return new ClassicDependencyManager();
88 }
89
90 protected DependencySelector getDependencySelector() {
91 return new AndDependencySelector(
92 new ScopeDependencySelector("test", "provided"),
93 new OptionalDependencySelector(),
94 new ExclusionDependencySelector());
95 }
96
97 protected DependencyGraphTransformer getDependencyGraphTransformer() {
98 return new ChainedDependencyGraphTransformer(
99 new ConflictResolver(
100 new NearestVersionSelector(), new JavaScopeSelector(),
101 new SimpleOptionalitySelector(), new JavaScopeDeriver()),
102 new JavaDependencyContextRefiner());
103 }
104
105 protected ArtifactTypeRegistry getArtifactTypeRegistry() {
106 DefaultArtifactTypeRegistry stereotypes = new DefaultArtifactTypeRegistry();
107 stereotypes.add(new DefaultArtifactType("pom"));
108 stereotypes.add(new DefaultArtifactType("maven-plugin", "jar", "", "java"));
109 stereotypes.add(new DefaultArtifactType("jar", "jar", "", "java"));
110 stereotypes.add(new DefaultArtifactType("ejb", "jar", "", "java"));
111 stereotypes.add(new DefaultArtifactType("ejb-client", "jar", "client", "java"));
112 stereotypes.add(new DefaultArtifactType("test-jar", "jar", "tests", "java"));
113 stereotypes.add(new DefaultArtifactType("javadoc", "jar", "javadoc", "java"));
114 stereotypes.add(new DefaultArtifactType("java-source", "jar", "sources", "java", false, false));
115 stereotypes.add(new DefaultArtifactType("war", "war", "", "java", false, true));
116 stereotypes.add(new DefaultArtifactType("ear", "ear", "", "java", false, true));
117 stereotypes.add(new DefaultArtifactType("rar", "rar", "", "java", false, true));
118 stereotypes.add(new DefaultArtifactType("par", "par", "", "java", false, true));
119 return stereotypes;
120 }
121
122 protected ArtifactDescriptorPolicy getArtifactDescriptorPolicy() {
123 return new SimpleArtifactDescriptorPolicy(true, true);
124 }
125
126
127
128
129
130
131
132
133
134
135
136 @Override
137 public SessionBuilder get() {
138 SessionBuilder builder = repositorySystem.createSessionBuilder();
139 configureSessionBuilder(builder);
140 return builder;
141 }
142 }