1 package org.eclipse.aether.internal.impl.collect;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.eclipse.aether.RepositorySystemSession;
23 import org.eclipse.aether.collection.CollectResult;
24 import org.eclipse.aether.graph.Dependency;
25 import org.eclipse.aether.util.ConfigUtils;
26
27 class Results
28 {
29
30 private final CollectResult result;
31
32 private final int maxExceptions;
33
34 private final int maxCycles;
35
36 String errorPath;
37
38 @SuppressWarnings( { "checkstyle:magicnumber" } )
39 Results( CollectResult result, RepositorySystemSession session )
40 {
41 this.result = result;
42 maxExceptions = ConfigUtils.getInteger( session, 50, DefaultDependencyCollector.CONFIG_PROP_MAX_EXCEPTIONS );
43 maxCycles = ConfigUtils.getInteger( session, 10, DefaultDependencyCollector.CONFIG_PROP_MAX_CYCLES );
44 }
45
46 public void addException( Dependency dependency, Exception e, NodeStack nodes )
47 {
48 if ( maxExceptions < 0 || result.getExceptions().size() < maxExceptions )
49 {
50 result.addException( e );
51 if ( errorPath == null )
52 {
53 StringBuilder buffer = new StringBuilder( 256 );
54 for ( int i = 0; i < nodes.size(); i++ )
55 {
56 if ( buffer.length() > 0 )
57 {
58 buffer.append( " -> " );
59 }
60 Dependency dep = nodes.get( i ).getDependency();
61 if ( dep != null )
62 {
63 buffer.append( dep.getArtifact() );
64 }
65 }
66 if ( buffer.length() > 0 )
67 {
68 buffer.append( " -> " );
69 }
70 buffer.append( dependency.getArtifact() );
71 errorPath = buffer.toString();
72 }
73 }
74 }
75
76 public void addCycle( NodeStack nodes, int cycleEntry, Dependency dependency )
77 {
78 if ( maxCycles < 0 || result.getCycles().size() < maxCycles )
79 {
80 result.addCycle( new DefaultDependencyCycle( nodes, cycleEntry, dependency ) );
81 }
82 }
83
84 }