1 package org.apache.maven.plugin.surefire;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.ArrayList;
23 import java.util.Collection;
24 import java.util.Set;
25 import java.util.concurrent.ConcurrentHashMap;
26
27 import org.apache.maven.artifact.Artifact;
28 import org.apache.maven.surefire.booter.Classpath;
29
30 import javax.annotation.Nonnull;
31
32
33
34
35 @Deprecated
36 public class ClasspathCache
37 {
38 private static final ConcurrentHashMap<String, Classpath> CLASSPATHS =
39 new ConcurrentHashMap<>( 4 );
40
41 public static Classpath getCachedClassPath( @Nonnull String artifactId )
42 {
43 return CLASSPATHS.get( artifactId );
44 }
45
46 public static void setCachedClasspath( @Nonnull String key, @Nonnull Classpath classpath )
47 {
48 CLASSPATHS.put( key, classpath );
49 }
50
51 public static Classpath setCachedClasspath( @Nonnull String key, @Nonnull Set<Artifact> artifacts )
52 {
53 Collection<String> files = new ArrayList<>();
54 for ( Artifact artifact : artifacts )
55 {
56 files.add( artifact.getFile().getAbsolutePath() );
57 }
58 Classpath classpath = new Classpath( files );
59 setCachedClasspath( key, classpath );
60 return classpath;
61 }
62 }