Skip to content

Commit

Permalink
Show a warning for missing sources
Browse files Browse the repository at this point in the history
  • Loading branch information
guw committed Sep 14, 2023
1 parent 2e05461 commit cb455bf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ public Collection<ClasspathEntry> computeClasspath(BazelProject workspaceProject
WORKSPACE_BUILDPATH_PROBLEM_MARKER,
Status.warning(
"Some generated jars were ommitted from the classpath because they don't exist locally. Consider runing 'bazel build //...' to build any missing library."));
} else if (generatedLibrariesDiscovery.isFoundMissingSrcJars()) {
createMarker(
workspaceProject.getProject(),
WORKSPACE_BUILDPATH_PROBLEM_MARKER,
Status.warning(
"Some source jars are missing. Bazel does not build them by default. Consider runing 'bazel build --output_groups=+_source_jars //...' to build any missing source jar."));
}

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class LibrariesDiscoveryUtil {
protected Path outputBase;

private boolean foundMissingJars;
private boolean foundMissingSrcJars;

public LibrariesDiscoveryUtil(BazelWorkspace bazelWorkspace) throws CoreException {
this.bazelWorkspace = bazelWorkspace;
Expand Down Expand Up @@ -79,6 +80,10 @@ protected void collectJarsAsClasspathEntries(List<ArtifactLocation> jars, Artifa
classpath.getExtraAttributes().put(IClasspathAttribute.TEST, Boolean.TRUE.toString());
}
classpath.setBazelTargetOrigin(origin);
if ((classpath.getSourceAttachmentPath() != null)
&& !isRegularFile(classpath.getSourceAttachmentPath().toPath())) {
foundMissingSrcJars = true;
}
result.add(classpath);
} else {
foundMissingJars = true;
Expand Down Expand Up @@ -223,13 +228,21 @@ protected Label guessJarLabelFromLocation(Path jarPath) {
}

/**
* @return <code>true</code> if there jars were omitted from the result because they cannot be found locally
* @return <code>true</code> if jars were omitted from the result because they cannot be found locally
* (<code>false</code> otherwise)
*/
public boolean isFoundMissingJars() {
return foundMissingJars;
}

/**
* @return <code>true</code> if source jars were discovered which cannot be found locally (<code>false</code>
* otherwise)
*/
public boolean isFoundMissingSrcJars() {
return foundMissingSrcJars;
}

protected ArtifactLocation jarLabelToArtifactLocation(String jar, boolean isGenerated) {
if ((jar == null) || jar.isBlank()) {
return null;
Expand Down

0 comments on commit cb455bf

Please sign in to comment.