1818 */
1919package org .apache .maven .impl ;
2020
21- import java .nio .file .FileSystem ;
2221import java .nio .file .Path ;
23- import java .nio .file .PathMatcher ;
2422import java .util .List ;
2523import java .util .Objects ;
2624import java .util .Optional ;
3937public final class DefaultSourceRoot implements SourceRoot {
4038 private final Path directory ;
4139
42- private final List <PathMatcher > includes ;
40+ private final List <String > includes ;
4341
44- private final List <PathMatcher > excludes ;
42+ private final List <String > excludes ;
4543
4644 private final ProjectScope scope ;
4745
@@ -65,9 +63,8 @@ public final class DefaultSourceRoot implements SourceRoot {
6563 * @param source a source element from the model
6664 */
6765 public DefaultSourceRoot (final Session session , final Path baseDir , final Source source ) {
68- FileSystem fs = baseDir .getFileSystem ();
69- includes = matchers (fs , source .getIncludes ());
70- excludes = matchers (fs , source .getExcludes ());
66+ includes = source .getIncludes ();
67+ excludes = source .getExcludes ();
7168 stringFiltering = source .isStringFiltering ();
7269 enabled = source .isEnabled ();
7370 moduleName = nonBlank (source .getModule ());
@@ -106,9 +103,8 @@ public DefaultSourceRoot(final Path baseDir, ProjectScope scope, Resource resour
106103 throw new IllegalArgumentException ("Source declaration without directory value." );
107104 }
108105 directory = baseDir .resolve (value ).normalize ();
109- FileSystem fs = directory .getFileSystem ();
110- includes = matchers (fs , resource .getIncludes ());
111- excludes = matchers (fs , resource .getExcludes ());
106+ includes = resource .getIncludes ();
107+ excludes = resource .getExcludes ();
112108 stringFiltering = Boolean .parseBoolean (resource .getFiltering ());
113109 enabled = true ;
114110 moduleName = null ;
@@ -144,13 +140,15 @@ public DefaultSourceRoot(final ProjectScope scope, final Language language, fina
144140 * @param scope scope of source code (main or test)
145141 * @param language language of the source code
146142 * @param directory directory of the source code
147- */
143+ * @param includes list of patterns for the files to include, or {@code null} if unspecified
144+ * @param excludes list of patterns for the files to exclude, or {@code null} if unspecified
145+ * */
148146 public DefaultSourceRoot (
149147 final ProjectScope scope ,
150148 final Language language ,
151149 final Path directory ,
152- List <PathMatcher > includes ,
153- List <PathMatcher > excludes ) {
150+ List <String > includes ,
151+ List <String > excludes ) {
154152 this .scope = Objects .requireNonNull (scope );
155153 this .language = language ;
156154 this .directory = Objects .requireNonNull (directory );
@@ -176,38 +174,6 @@ private static String nonBlank(String value) {
176174 return value ;
177175 }
178176
179- /**
180- * Creates a path matcher for each pattern.
181- * The path separator is {@code /} on all platforms, including Windows.
182- * The prefix before the {@code :} character is the syntax.
183- * If no syntax is specified, {@code "glob"} is assumed.
184- *
185- * @param fs the file system of the root directory
186- * @param patterns the patterns for which to create path matcher
187- * @return a path matcher for each pattern
188- */
189- private static List <PathMatcher > matchers (FileSystem fs , List <String > patterns ) {
190- final var matchers = new PathMatcher [patterns .size ()];
191- for (int i = 0 ; i < matchers .length ; i ++) {
192- String rawPattern = patterns .get (i );
193- String pattern = rawPattern .contains (":" ) ? rawPattern : "glob:" + rawPattern ;
194- matchers [i ] = new PathMatcher () {
195- final PathMatcher delegate = fs .getPathMatcher (pattern );
196-
197- @ Override
198- public boolean matches (Path path ) {
199- return delegate .matches (path );
200- }
201-
202- @ Override
203- public String toString () {
204- return rawPattern ;
205- }
206- };
207- }
208- return List .of (matchers );
209- }
210-
211177 /**
212178 * {@return the root directory where the sources are stored}.
213179 */
@@ -221,7 +187,7 @@ public Path directory() {
221187 */
222188 @ Override
223189 @ SuppressWarnings ("ReturnOfCollectionOrArrayField" ) // Safe because unmodifiable
224- public List <PathMatcher > includes () {
190+ public List <String > includes () {
225191 return includes ;
226192 }
227193
@@ -230,7 +196,7 @@ public List<PathMatcher> includes() {
230196 */
231197 @ Override
232198 @ SuppressWarnings ("ReturnOfCollectionOrArrayField" ) // Safe because unmodifiable
233- public List <PathMatcher > excludes () {
199+ public List <String > excludes () {
234200 return excludes ;
235201 }
236202
0 commit comments