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