Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crude output of jdeps from vanilla java builder for intellij plugin #6587

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,12 @@ public VanillaJavaBuilderResult run(List<String> args) throws IOException {
writeNativeHeaderOutput(optionsParser, nativeHeaderDir);
}
writeGeneratedSourceOutput(optionsParser);
// the jdeps output doesn't include any information about dependencies, but Bazel still expects
// the file to be created
if (optionsParser.getOutputDepsProtoFile() != null) {
try (OutputStream os =
Files.newOutputStream(Paths.get(optionsParser.getOutputDepsProtoFile()))) {
Deps.Dependencies.newBuilder()
.setRuleLabel(optionsParser.getTargetLabel())
.addAllDependency(collectDependencies(fileManager))
.setSuccess(ok)
.build()
.writeTo(os);
Expand Down Expand Up @@ -223,6 +222,15 @@ public VanillaJavaBuilderResult run(List<String> args) throws IOException {
return new VanillaJavaBuilderResult(ok, output.toString());
}

private ImmutableList<Deps.Dependency> collectDependencies(StandardJavaFileManager fileManager) {
ImmutableList.Builder<Deps.Dependency> builder = ImmutableList.builder();
for (File file : fileManager.getLocation(StandardLocation.CLASS_PATH)) {
String path = file.toString();
builder.add(Deps.Dependency.newBuilder().setKind(Deps.Dependency.Kind.EXPLICIT).setPath(path).build());
Copy link
Contributor

@cushon cushon Nov 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an over-approximation of the deps that were needed, and defeats the point of the optimization IntelliJ is doing. It might make more sense to just provide a way to disable the Intellij plugins' jdeps handling and use the full classpath.

A better solution for VanillaJavaBuilder might be to have it use the bytecode-based
strict deps / jdeps tool:

}
return builder.build();
}

/** Returns the sources to compile, including any source jar entries. */
private ImmutableList<JavaFileObject> getSources(
OptionsParser optionsParser, StandardJavaFileManager fileManager) throws IOException {
Expand Down