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