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