1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugins.assembly.io;
20
21
22
23
24 class PrefixedClasspathLocatorStrategy extends ClasspathResourceLocatorStrategy {
25
26 private final String prefix;
27
28 PrefixedClasspathLocatorStrategy(String prefix) {
29 this.prefix = formatPrefix(prefix);
30 }
31
32 private String formatPrefix(String prefix) {
33 if (prefix.startsWith("/")) {
34 prefix = prefix.substring(1);
35 }
36
37 if (prefix.length() > 0 && !prefix.endsWith("/")) {
38 prefix += "/";
39 }
40
41 return prefix;
42 }
43
44 @Override
45 public Location resolve(String locationSpecification, MessageHolder messageHolder) {
46 String spec = formatLocation(locationSpecification);
47
48 return super.resolve(spec, messageHolder);
49 }
50
51 private String formatLocation(String location) {
52 if (location.startsWith("/")) {
53 location = location.substring(1);
54 }
55
56 return prefix + location;
57 }
58 }