2525import java .nio .file .Files ;
2626import java .nio .file .Path ;
2727import java .nio .file .PathMatcher ;
28- import java .nio .file .Paths ;
2928import java .util .Collection ;
30- import java .util .Collections ;
3129
30+ import static java .util .Collections .emptyList ;
31+ import static java .util .Collections .singletonList ;
3232import static org .assertj .core .api .Assertions .assertThat ;
3333
3434/**
@@ -52,7 +52,7 @@ void untrackedGitIgnoredFileIsExcluded(@TempDir Path tempDir) throws Exception {
5252 git .add ().addFilepattern (".gitignore" ).call ();
5353 git .commit ().setMessage ("initial" ).call ();
5454
55- assertThat (MavenMojoProjectParser .isExcluded (repo , Collections . emptyList (), Paths . get ("generated.txt" )))
55+ assertThat (MavenMojoProjectParser .isExcluded (repo , emptyList (), Path . of ("generated.txt" )))
5656 .as ("untracked gitignored file should be excluded" )
5757 .isTrue ();
5858 }
@@ -71,7 +71,7 @@ void trackedGitIgnoredFileIsNotExcluded(@TempDir Path tempDir) throws Exception
7171 git .add ().addFilepattern (".gitignore" ).call ();
7272 git .commit ().setMessage ("add gitignore" ).call ();
7373
74- assertThat (MavenMojoProjectParser .isExcluded (repo , Collections . emptyList (), Paths . get ("tracked-ignored.txt" )))
74+ assertThat (MavenMojoProjectParser .isExcluded (repo , emptyList (), Path . of ("tracked-ignored.txt" )))
7575 .as ("tracked gitignored file should NOT be excluded" )
7676 .isFalse ();
7777 }
@@ -88,7 +88,7 @@ void untrackedFileInGitIgnoredDirectoryIsExcluded(@TempDir Path tempDir) throws
8888 git .add ().addFilepattern (".gitignore" ).call ();
8989 git .commit ().setMessage ("initial" ).call ();
9090
91- assertThat (MavenMojoProjectParser .isExcluded (repo , Collections . emptyList (), Paths . get ("target/output.txt" )))
91+ assertThat (MavenMojoProjectParser .isExcluded (repo , emptyList (), Path . of ("target/output.txt" )))
9292 .as ("untracked file in gitignored directory should be excluded" )
9393 .isTrue ();
9494 }
@@ -107,28 +107,28 @@ void trackedFileInGitIgnoredDirectoryIsNotExcluded(@TempDir Path tempDir) throws
107107 git .add ().addFilepattern (".gitignore" ).call ();
108108 git .commit ().setMessage ("add gitignore" ).call ();
109109
110- assertThat (MavenMojoProjectParser .isExcluded (repo , Collections . emptyList (), Paths . get ("target/output.txt" )))
110+ assertThat (MavenMojoProjectParser .isExcluded (repo , emptyList (), Path . of ("target/output.txt" )))
111111 .as ("tracked file in gitignored directory should NOT be excluded" )
112112 .isFalse ();
113113 }
114114 }
115115
116116 @ Test
117117 void exclusionMatcherMatchesDirectly () {
118- Collection <PathMatcher > matchers = Collections . singletonList (
118+ Collection <PathMatcher > matchers = singletonList (
119119 FileSystems .getDefault ().getPathMatcher ("glob:**/secret.properties" ));
120120
121- assertThat (MavenMojoProjectParser .isExcluded (null , matchers , Paths . get ("config/secret.properties" )))
121+ assertThat (MavenMojoProjectParser .isExcluded (null , matchers , Path . of ("config/secret.properties" )))
122122 .as ("path matching exclusion pattern should be excluded" )
123123 .isTrue ();
124124 }
125125
126126 @ Test
127127 void exclusionMatcherDoesNotMatchUnrelatedPath () {
128- Collection <PathMatcher > matchers = Collections . singletonList (
128+ Collection <PathMatcher > matchers = singletonList (
129129 FileSystems .getDefault ().getPathMatcher ("glob:**/secret.properties" ));
130130
131- assertThat (MavenMojoProjectParser .isExcluded (null , matchers , Paths . get ("config/application.properties" )))
131+ assertThat (MavenMojoProjectParser .isExcluded (null , matchers , Path . of ("config/application.properties" )))
132132 .as ("path not matching exclusion pattern should not be excluded" )
133133 .isFalse ();
134134 }
@@ -137,10 +137,10 @@ void exclusionMatcherDoesNotMatchUnrelatedPath() {
137137 void exclusionMatcherMatchesRootFileViaPrefixedSlash () {
138138 // PathMatcher won't match "pom.xml" against "**/pom.xml" without a leading slash;
139139 // isExcluded handles this by re-checking with a "/" prefix for relative paths
140- Collection <PathMatcher > matchers = Collections . singletonList (
140+ Collection <PathMatcher > matchers = singletonList (
141141 FileSystems .getDefault ().getPathMatcher ("glob:**/pom.xml" ));
142142
143- assertThat (MavenMojoProjectParser .isExcluded (null , matchers , Paths . get ("pom.xml" )))
143+ assertThat (MavenMojoProjectParser .isExcluded (null , matchers , Path . of ("pom.xml" )))
144144 .as ("root-level file should match **/pom.xml via leading-slash prefixing" )
145145 .isTrue ();
146146 }
@@ -149,21 +149,21 @@ void exclusionMatcherMatchesRootFileViaPrefixedSlash() {
149149 void exclusionMatcherMatchesRootFileWithLeadingSlash () {
150150 // When the path already has a leading slash, it should match directly
151151 // without needing the prefixing logic
152- Collection <PathMatcher > matchers = Collections . singletonList (
152+ Collection <PathMatcher > matchers = singletonList (
153153 FileSystems .getDefault ().getPathMatcher ("glob:**/pom.xml" ));
154154
155- assertThat (MavenMojoProjectParser .isExcluded (null , matchers , Paths . get ("/pom.xml" )))
155+ assertThat (MavenMojoProjectParser .isExcluded (null , matchers , Path . of ("/pom.xml" )))
156156 .as ("root-level file with leading slash should match **/pom.xml directly" )
157157 .isTrue ();
158158 }
159159
160160 @ Test
161161 void exclusionMatcherMatchesSubdirFileWithoutPrefixing () {
162162 // A file in a subdirectory should match directly without needing the "/" prefix path
163- Collection <PathMatcher > matchers = Collections . singletonList (
163+ Collection <PathMatcher > matchers = singletonList (
164164 FileSystems .getDefault ().getPathMatcher ("glob:**/pom.xml" ));
165165
166- assertThat (MavenMojoProjectParser .isExcluded (null , matchers , Paths . get ("module/pom.xml" )))
166+ assertThat (MavenMojoProjectParser .isExcluded (null , matchers , Path . of ("module/pom.xml" )))
167167 .as ("subdirectory file should match **/pom.xml directly" )
168168 .isTrue ();
169169 }
0 commit comments