Skip to content

Commit 48d4cb2

Browse files
committed
fix/build: resolve project path to absolute and surface empty-build failures
Two coupled papercuts in the level-2 build path: - A relative `--input` doubled the project path. The build runs with its working directory set to the project root, but gradleBuild passed the raw (relative) `-p <projectPath>` (maven was already absolutized, gradle was not), so it resolved against the root to `<root>/<root>`, the build failed, and zero application classes loaded. Normalize the path to absolute once at the buildProjectAndStreamClassFiles entry point so every downstream tool is consistent. - A failed build was swallowed: buildProjectAndStreamClassFiles returns an empty list (never null) on failure, but ScopeUtils only guarded `== null`, so analysis proceeded with an empty scope and died later with a cryptic WALA "Could not create entrypoint callsites" error. Guard on emptiness too and report the real cause (build failed / no compiled classes / bad input path).
1 parent 6c7081d commit 48d4cb2

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/main/java/com/ibm/cldk/utils/BuildProject.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,11 @@ private static boolean buildProject(String projectPath, String build) {
194194
* @return true if the streaming was successful, false otherwise.
195195
*/
196196
public static List<Path> buildProjectAndStreamClassFiles(String projectPath, String build) throws IOException {
197-
return buildProject(projectPath, build) ? classFilesStream(projectPath) : new ArrayList<>();
197+
// Normalize to an absolute path up front: the build runs with its working directory set to the
198+
// project root, so a relative `-p`/`-f` would resolve against it and double the path (e.g.
199+
// `<root>/<root>`), making the build fail and yielding zero application classes.
200+
String absProjectPath = Paths.get(projectPath).toAbsolutePath().normalize().toString();
201+
return buildProject(absProjectPath, build) ? classFilesStream(absProjectPath) : new ArrayList<>();
198202
}
199203

200204
private static boolean mkLibDepDirs(String projectPath) {

src/main/java/com/ibm/cldk/utils/ScopeUtils.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,12 @@ public static AnalysisScope createScope(String projectPath, String applicationDe
105105

106106
List<Path> applicationClassFiles = BuildProject.buildProjectAndStreamClassFiles(projectPath, build);
107107
Log.debug("Application class files: " + String.valueOf(applicationClassFiles.size()));
108-
if (applicationClassFiles == null) {
109-
Log.error("No application classes found.");
108+
// An empty list (not null) is what a failed build returns, so guard on emptiness too — otherwise
109+
// analysis proceeds with zero application classes and fails later with a cryptic WALA entrypoint
110+
// error instead of surfacing the real cause (the project build failed or produced no classes).
111+
if (applicationClassFiles == null || applicationClassFiles.isEmpty()) {
112+
Log.error("No application classes found — the project build may have failed or produced no "
113+
+ "compiled classes. Check the build output above and that the input path is correct.");
110114
throw new RuntimeException("No application classes found.");
111115
}
112116
Log.info("Adding application classes to scope.");

0 commit comments

Comments
 (0)