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