Skip to content

Commit e9ba95a

Browse files
authored
fix: report found languages when failing on missing compiled .class (#1026)
1 parent 6153ef2 commit e9ba95a

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/main/java/org/sonar/plugins/findbugs/FindbugsConfiguration.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,23 +150,29 @@ void initializeFindbugsProject(Project findbugsProject, ClasspathLocator classpa
150150
}
151151

152152
public IllegalStateException buildMissingCompiledCodeException() {
153-
String message = "One (sub)project contains Java source files that are not compiled (" + fileSystem.baseDir().getPath() + ").";
153+
StringBuilder message = new StringBuilder("One (sub)project contains Java source files that are not compiled (" + fileSystem.baseDir().getPath() + ").");
154+
155+
for (String language : FindbugsPlugin.SUPPORTED_JVM_LANGUAGES) {
156+
if (fileSystem.hasFiles(fileSystem.predicates().hasLanguage(language))) {
157+
message.append("\nProject has " + language + " source file(s), they must be compiled to be analyzed.");
158+
}
159+
}
154160

155161
if (!config.hasKey(SONAR_JAVA_BINARIES) || config.getStringArray(SONAR_JAVA_BINARIES).length == 0) {
156-
message += "\nProperty sonar.java.binaries was not set, it is required to locate the compiled .class files. For instance set the property to: sonar.java.binaries=target/classes";
162+
message.append("\nProperty sonar.java.binaries was not set, it is required to locate the compiled .class files. For instance set the property to: sonar.java.binaries=target/classes");
157163
} else {
158-
message += "\nsonar.java.binaries was set to " + config.get(SONAR_JAVA_BINARIES).orElse(null);
164+
message.append("\nsonar.java.binaries was set to " + config.get(SONAR_JAVA_BINARIES).orElse(null));
159165
}
160166

161167
if (javaResourceLocator.classpath().isEmpty()) {
162-
message += "\nSonar JavaResourceLocator.classpath was empty";
168+
message.append("\nSonar JavaResourceLocator.classpath was empty");
163169
}
164170

165171
if (javaResourceLocator.classFilesToAnalyze().isEmpty()) {
166-
message += "\nSonar JavaResourceLocator.classFilesToAnalyze was empty";
172+
message.append("\nSonar JavaResourceLocator.classFilesToAnalyze was empty");
167173
}
168174

169-
return new IllegalStateException(message);
175+
return new IllegalStateException(message.toString());
170176
}
171177

172178
/**

0 commit comments

Comments
 (0)