Skip to content

Commit

Permalink
Add an error when srcjar is missing instead of failing
Browse files Browse the repository at this point in the history
  • Loading branch information
guw committed Nov 3, 2023
1 parent ee574b4 commit f9b0c92
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,17 @@ public void analyzeSourceDirectories(MultiStatus result) throws CoreException {
.collect(toList());
for (IPath srcjar : srcJars) {
var srcjarFolder = extractSrcJar(bazelTarget, srcjar);
collectJavaSourcesInFolder(srcjarFolder).forEach(javaSourceEntryCollector::apply);
if (srcjarFolder == null) {
result.add(
Status.error(
format(
"The generated sources '%s' (produced by '%s') are missing. Please check the build output for errors. The project will not compile.",
srcjar,
bazelTarget.getLabel())));

} else {
collectJavaSourcesInFolder(srcjarFolder).forEach(javaSourceEntryCollector::apply);
}
}
} else {
throw new CoreException(Status.error(format("Unexpected source '%s'!", srcEntry)));
Expand Down Expand Up @@ -346,13 +356,18 @@ private IPath detectPackagePath(JavaSourceEntry fileEntry) {
* the target producing the source jar
* @param srcjar
* the path to the source jar
* @return absolute file system path to the directory containing the extracted sources
* @return absolute file system path to the directory containing the extracted sources or <code>null</code> if the
* srcjar does not exists
* @throws CoreException
*/
private IPath extractSrcJar(BazelTarget bazelTarget, IPath srcjar) throws CoreException {
var jarFile = bazelWorkspace.getBazelBinLocation()
.append(bazelTarget.getBazelPackage().getWorkspaceRelativePath())
.append(srcjar);
if (!isRegularFile(jarFile.toPath())) {
return null;
}

var targetDirectory = jarFile.removeLastSegments(1).append("_eclipse").append(srcjar.lastSegment());

var destination = targetDirectory.toPath();
Expand Down

0 comments on commit f9b0c92

Please sign in to comment.