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
23
24
25 class PrefixedClasspathLocatorStrategy
26 extends ClasspathResourceLocatorStrategy
27 {
28
29 private final String prefix;
30
31 PrefixedClasspathLocatorStrategy( String prefix )
32 {
33 this.prefix = formatPrefix( prefix );
34 }
35
36 private String formatPrefix( String prefix )
37 {
38 if ( prefix.startsWith( "/" ) )
39 {
40 prefix = prefix.substring( 1 );
41 }
42
43 if ( prefix.length() > 0 && !prefix.endsWith( "/" ) )
44 {
45 prefix += "/";
46 }
47
48 return prefix;
49 }
50
51 @Override
52 public Location resolve( String locationSpecification, MessageHolder messageHolder )
53 {
54 String spec = formatLocation( locationSpecification );
55
56 return super.resolve( spec, messageHolder );
57 }
58
59 private String formatLocation( String location )
60 {
61 if ( location.startsWith( "/" ) )
62 {
63 location = location.substring( 1 );
64 }
65
66 return prefix + location;
67 }
68
69 }