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.archive.archiver;
20
21 import java.io.File;
22
23 import org.codehaus.plexus.archiver.ArchivedFileSet;
24 import org.codehaus.plexus.components.io.filemappers.FileMapper;
25 import org.codehaus.plexus.components.io.fileselectors.FileSelector;
26 import org.codehaus.plexus.components.io.functions.InputStreamTransformer;
27
28
29
30
31 class PrefixedArchivedFileSet implements ArchivedFileSet {
32 private static final FileMapper[] EMPTY_FILE_MAPPERS_ARRAY = new FileMapper[0];
33
34 private final String rootPrefix;
35
36 private final ArchivedFileSet fileSet;
37
38 private final FileSelector[] selectors;
39
40
41
42
43
44
45 PrefixedArchivedFileSet(ArchivedFileSet fileSet, String rootPrefix, FileSelector[] selectors) {
46 this.fileSet = fileSet;
47 this.selectors = selectors;
48
49 if (rootPrefix.length() > 0 && !rootPrefix.endsWith("/")) {
50 this.rootPrefix = rootPrefix + "/";
51 } else {
52 this.rootPrefix = rootPrefix;
53 }
54 }
55
56
57
58
59 @Override
60 public File getArchive() {
61 return fileSet.getArchive();
62 }
63
64
65
66
67 @Override
68 public String[] getExcludes() {
69 return fileSet.getExcludes();
70 }
71
72
73
74
75 @Override
76 public FileSelector[] getFileSelectors() {
77 return PrefixedFileSet.combineSelectors(fileSet.getFileSelectors(), selectors);
78 }
79
80
81
82
83 @Override
84 public String[] getIncludes() {
85 return fileSet.getIncludes();
86 }
87
88
89
90
91 @Override
92 public String getPrefix() {
93 String prefix = fileSet.getPrefix();
94 if (prefix.startsWith("/")) {
95 if (prefix.length() > 1) {
96 prefix = prefix.substring(1);
97 } else {
98 prefix = "";
99 }
100 }
101
102 return rootPrefix + prefix;
103 }
104
105
106
107
108 @Override
109 public boolean isCaseSensitive() {
110 return fileSet.isCaseSensitive();
111 }
112
113
114
115
116 @Override
117 public boolean isIncludingEmptyDirectories() {
118 return fileSet.isIncludingEmptyDirectories();
119 }
120
121
122
123
124 @Override
125 public boolean isUsingDefaultExcludes() {
126 return fileSet.isUsingDefaultExcludes();
127 }
128
129 @Override
130 public InputStreamTransformer getStreamTransformer() {
131 return fileSet.getStreamTransformer();
132 }
133
134 @Override
135 public FileMapper[] getFileMappers() {
136 return EMPTY_FILE_MAPPERS_ARRAY;
137 }
138 }