Skip to content

Commit 25a0afe

Browse files
Strum355claude
andcommitted
fix(workspace): fix Maven binary resolution and glob pattern matching
Use getCustomPathOrElse for Maven binary resolution (matching Gradle), and handle Java PathMatcher quirk where **/X/** doesn't match paths where X is the first component. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 16cf471 commit 25a0afe

2 files changed

Lines changed: 21 additions & 23 deletions

File tree

src/main/java/io/github/guacsec/trustifyda/impl/ExhortApi.java

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ List<Path> discoverWorkspaceManifests(Path workspaceDir, Set<String> ignorePatte
881881
Path pomXml = workspaceDir.resolve("pom.xml");
882882
if (Files.isRegularFile(pomXml)) {
883883
List<Path> mavenManifests = discoverMavenModules(workspaceDir, ignorePatterns);
884-
if (mavenManifests.size() > 1) {
884+
if (!mavenManifests.isEmpty()) {
885885
return mavenManifests;
886886
}
887887
}
@@ -1070,29 +1070,17 @@ static List<String> parseMavenModuleList(String raw) {
10701070
* @param startDir the directory from which to start searching for mvnw
10711071
* @return the resolved Maven binary path, or null if Maven is not available
10721072
*/
1073-
private String resolveMavenBinary(Path startDir) {
1074-
try {
1075-
boolean preferWrapper = Operations.getWrapperPreference("mvn");
1076-
String mvn = Operations.isWindows() ? "mvn.cmd" : "mvn";
1077-
if (preferWrapper) {
1078-
String wrapperName = Operations.isWindows() ? "mvnw.cmd" : "mvnw";
1079-
String mvnw =
1080-
JavaMavenProvider.traverseForMvnw(
1081-
wrapperName, startDir.resolve("pom.xml").toString(), null);
1082-
if (mvnw != null) {
1083-
try {
1084-
Operations.runProcess(startDir, mvnw, "-v");
1085-
return mvnw;
1086-
} catch (Exception e) {
1087-
LOG.warning("Maven wrapper found but not accessible: " + e.getMessage());
1088-
}
1089-
}
1073+
private static String resolveMavenBinary(Path startDir) {
1074+
if (Operations.getWrapperPreference("mvn")) {
1075+
String wrapperName = Operations.isWindows() ? "mvnw.cmd" : "mvnw";
1076+
String wrapper =
1077+
JavaMavenProvider.traverseForMvnw(
1078+
wrapperName, startDir.resolve("pom.xml").toString(), null);
1079+
if (wrapper != null) {
1080+
return wrapper;
10901081
}
1091-
return Operations.getExecutable(mvn, "-v");
1092-
} catch (Exception e) {
1093-
LOG.warning("Failed to resolve Maven binary: " + e.getMessage());
1094-
return null;
10951082
}
1083+
return Operations.getCustomPathOrElse("mvn");
10961084
}
10971085

10981086
/**

src/main/java/io/github/guacsec/trustifyda/utils/WorkspaceUtils.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,17 @@ public static List<Path> filterByIgnorePatterns(
4343

4444
List<PathMatcher> matchers =
4545
ignorePatterns.stream()
46-
.map(p -> FileSystems.getDefault().getPathMatcher("glob:" + p))
46+
.flatMap(
47+
p -> {
48+
var fs = FileSystems.getDefault();
49+
java.util.stream.Stream.Builder<PathMatcher> b =
50+
java.util.stream.Stream.builder();
51+
b.add(fs.getPathMatcher("glob:" + p));
52+
if (p.startsWith("**/")) {
53+
b.add(fs.getPathMatcher("glob:" + p.substring(3)));
54+
}
55+
return b.build();
56+
})
4757
.toList();
4858

4959
return manifests.stream()

0 commit comments

Comments
 (0)