1 package org.apache.maven.plugin.cxx.utils;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import java.io.File;
22 import java.util.List;
23
24 import org.apache.maven.model.FileSet;
25
26 import org.codehaus.plexus.util.DirectoryScanner;
27
28
29
30
31
32
33
34 public class FileSetManager
35 {
36 private DirectoryScanner scan( FileSet fileSet )
37 {
38 File basedir = new File( fileSet.getDirectory() );
39
40 if ( !basedir.exists() || !basedir.isDirectory() )
41 {
42 return null;
43 }
44
45 DirectoryScanner scanner = new DirectoryScanner();
46
47 List<String> includesList = fileSet.getIncludes();
48 List<String> excludesList = fileSet.getExcludes();
49
50 if ( includesList.size() > 0 )
51 {
52 scanner.setIncludes( (String[]) includesList.toArray( new String[0] ) );
53 }
54
55 if ( excludesList.size() > 0 )
56 {
57 scanner.setExcludes( (String[]) excludesList.toArray( new String[0] ) );
58 }
59
60 if ( true )
61 {
62 scanner.addDefaultExcludes();
63 }
64
65 scanner.setBasedir( basedir );
66 scanner.setFollowSymlinks( true );
67
68 scanner.scan();
69
70 return scanner;
71 }
72
73 private static final String[] EMPTY_STRING_ARRAY = new String[0];
74
75 public String[] getIncludedFiles( FileSet fileSet )
76 {
77 DirectoryScanner scanner = scan( fileSet );
78
79 if ( scanner != null )
80 {
81 return scanner.getIncludedFiles();
82 }
83
84 return EMPTY_STRING_ARRAY;
85 }
86
87 public String[] getExcludedFiles( FileSet fileSet )
88 {
89 DirectoryScanner scanner = scan( fileSet );
90
91 if ( scanner != null )
92 {
93 return scanner.getExcludedFiles();
94 }
95
96 return EMPTY_STRING_ARRAY;
97 }
98
99 public String[] getIncludedDirectories( FileSet fileSet )
100 {
101 DirectoryScanner scanner = scan( fileSet );
102
103 if ( scanner != null )
104 {
105 return scanner.getIncludedDirectories();
106 }
107
108 return EMPTY_STRING_ARRAY;
109 }
110
111 public String[] getExcludedDirectories( FileSet fileSet )
112 {
113 DirectoryScanner scanner = scan( fileSet );
114
115 if ( scanner != null )
116 {
117 return scanner.getExcludedDirectories();
118 }
119
120 return EMPTY_STRING_ARRAY;
121 }
122 }