1 package org.apache.maven.plugins.assembly.io;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.net.URL;
23
24
25
26
27 class ClasspathResourceLocatorStrategy
28 implements LocatorStrategy
29 {
30
31 private String tempFilePrefix = "location.";
32
33 private String tempFileSuffix = ".cpurl";
34
35 private boolean tempFileDeleteOnExit = true;
36
37
38
39
40 ClasspathResourceLocatorStrategy()
41 {
42 }
43
44
45 public Location resolve( String locationSpecification, MessageHolder messageHolder )
46 {
47 ClassLoader cloader = Thread.currentThread().getContextClassLoader();
48
49 URL resource = cloader.getResource( locationSpecification );
50
51 Location location = null;
52
53 if ( resource != null )
54 {
55 location = new URLLocation( resource, locationSpecification, tempFilePrefix, tempFileSuffix,
56 tempFileDeleteOnExit );
57 }
58 else
59 {
60 messageHolder.addMessage( "Failed to resolve classpath resource: " + locationSpecification
61 + " from classloader: " + cloader );
62 }
63
64 return location;
65 }
66
67 }