Skip to content

Commit

Permalink
Revert "Create jdeps output from classpath entries (#1376)" (#1388)
Browse files Browse the repository at this point in the history
Intellij needs full jars to be able to attach sources, and providing ijars with jdeps is degrading experience when someone already uses full jars
  • Loading branch information
Vaidas Pilkauskas authored Apr 29, 2022
1 parent 470cd83 commit ddde9b3
Show file tree
Hide file tree
Showing 13 changed files with 7 additions and 144 deletions.
1 change: 0 additions & 1 deletion scala/private/common_outputs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ common_outputs = {
"manifest": "%{name}_MANIFEST.MF",
"statsfile": "%{name}.statsfile",
"diagnosticsfile": "%{name}.diagnosticsproto",
"jdeps": "%{name}.jdep",
}
6 changes: 1 addition & 5 deletions scala/private/phases/phase_compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ def _compile_or_empty(
manifest,
ctx.outputs.statsfile,
ctx.outputs.diagnosticsfile,
ctx.outputs.jdeps,
sources,
jars,
all_srcjars,
Expand Down Expand Up @@ -270,7 +269,6 @@ rm -f {jar_output}
# ensures that empty src targets still emit a statsfile and a diagnosticsfile
touch {statsfile}
touch {diagnosticsfile}
touch {jdepsfile}
""" + ijar_cmd

cmd = cmd.format(
Expand All @@ -279,10 +277,9 @@ touch {jdepsfile}
zipper = ctx.executable._zipper.path,
statsfile = ctx.outputs.statsfile.path,
diagnosticsfile = ctx.outputs.diagnosticsfile.path,
jdepsfile = ctx.outputs.jdeps.path,
)

outs = [ctx.outputs.jar, ctx.outputs.statsfile, ctx.outputs.diagnosticsfile, ctx.outputs.jdeps]
outs = [ctx.outputs.jar, ctx.outputs.statsfile, ctx.outputs.diagnosticsfile]
inputs = ctx.files.resources + [ctx.outputs.manifest]

ctx.actions.run_shell(
Expand All @@ -306,7 +303,6 @@ def _create_scala_compilation_provider(ctx, ijar, source_jar, deps_providers):
compile_jar = ijar,
source_jar = source_jar,
deps = deps_providers,
jdeps = ctx.outputs.jdeps,
exports = exports,
runtime_deps = runtime_deps,
neverlink = ctx.attr.neverlink,
Expand Down
4 changes: 1 addition & 3 deletions scala/private/rule_impls.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def compile_scala(
manifest,
statsfile,
diagnosticsfile,
jdepsPath,
sources,
cjars,
all_srcjars,
Expand Down Expand Up @@ -80,7 +79,6 @@ def compile_scala(
args.add("--Manifest", manifest)
args.add("--PrintCompileTime", print_compile_time)
args.add("--ExpectJavaOutput", expect_java_output)
args.add("--JDepsFilePath", jdepsPath)
args.add("--StrictDepsMode", dependency_info.strict_deps_mode)
args.add("--UnusedDependencyCheckerMode", dependency_info.unused_deps_mode)
args.add("--DependencyTrackingMethod", dependency_info.dependency_tracking_method)
Expand Down Expand Up @@ -111,7 +109,7 @@ def compile_scala(
if dependency_info.unused_deps_mode != "off":
args.add_all("--UnusedDepsIgnoredTargets", unused_dependency_checker_ignored_targets)

outs = [output, statsfile, diagnosticsfile, jdepsPath]
outs = [output, statsfile, diagnosticsfile]

ins = depset(
direct = [manifest] + sources + classpath_resources + resources + resource_jars,
Expand Down
3 changes: 0 additions & 3 deletions scala_proto/private/scala_proto_aspect.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def _compile_sources(ctx, toolchain, proto, src_jars, deps, stamp_label):
write_manifest_file(ctx.actions, manifest, None)
statsfile = ctx.actions.declare_file(ctx.label.name + "_scalac.statsfile")
diagnosticsfile = ctx.actions.declare_file(ctx.label.name + "_scalac.diagnosticsproto")
jdepsfile = ctx.actions.declare_file(ctx.label.name + ".jdeps")
compile_deps = deps + _compile_deps(ctx, toolchain)
merged_deps = java_common.merge(compile_deps)

Expand All @@ -104,7 +103,6 @@ def _compile_sources(ctx, toolchain, proto, src_jars, deps, stamp_label):
manifest,
statsfile,
diagnosticsfile,
jdepsfile,
sources = [],
cjars = merged_deps.compile_jars,
all_srcjars = depset(src_jars),
Expand All @@ -129,7 +127,6 @@ def _compile_sources(ctx, toolchain, proto, src_jars, deps, stamp_label):
output_jar = output,
compile_jar = output,
deps = compile_deps,
jdeps = jdepsfile,
exports = compile_deps,
runtime_deps = compile_deps,
)
Expand Down
11 changes: 0 additions & 11 deletions src/java/io/bazel/rulesscala/jdeps/BUILD

This file was deleted.

33 changes: 0 additions & 33 deletions src/java/io/bazel/rulesscala/jdeps/JdepsWriter.java

This file was deleted.

1 change: 0 additions & 1 deletion src/java/io/bazel/rulesscala/scalac/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ java_binary(
deps = [
"//scala/private/toolchain_deps:scala_compile_classpath",
"//src/java/io/bazel/rulesscala/io_utils",
"//src/java/io/bazel/rulesscala/jdeps",
"//third_party/bazel/src/main/protobuf:worker_protocol_java_proto",
"@io_bazel_rules_scala//src/java/io/bazel/rulesscala/jar",
"@io_bazel_rules_scala//src/java/io/bazel/rulesscala/worker",
Expand Down
4 changes: 1 addition & 3 deletions src/java/io/bazel/rulesscala/scalac/CompileOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class CompileOptions {
public final String[] unusedDepsIgnoredTargets;
public final String[] indirectJars;
public final String[] indirectTargets;
public final String jdepsFilePath;
public final String strictDepsMode;
public final String unusedDependencyCheckerMode;
public final String currentTarget;
Expand Down Expand Up @@ -61,7 +60,6 @@ public CompileOptions(String[] lines) {
indirectJars = args.getOrEmpty("IndirectJars");
indirectTargets = args.getOrEmpty("IndirectTargets");

jdepsFilePath = args.getSingleOrError("JDepsFilePath");
strictDepsMode = args.getSingleOrError("StrictDepsMode");
unusedDependencyCheckerMode = args.getSingleOrError("UnusedDependencyCheckerMode");
currentTarget = args.getSingleOrError("CurrentTarget");
Expand All @@ -77,7 +75,7 @@ public CompileOptions(String[] lines) {

static final class Args {

private static final String[] EMPTY = new String[]{};
private static final String[] EMPTY = new String[] {};
private final Map<String, String[]> index = new LinkedHashMap<>();

Args(String[] lines) {
Expand Down
19 changes: 4 additions & 15 deletions src/java/io/bazel/rulesscala/scalac/ScalacWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,9 @@

import io.bazel.rulesscala.io_utils.StreamCopy;
import io.bazel.rulesscala.jar.JarCreator;
import io.bazel.rulesscala.jdeps.JdepsWriter;
import io.bazel.rulesscala.worker.Worker;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.io.*;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -70,8 +61,6 @@ public void work(String[] args) throws Exception {
compileScalaSources(ops, scalaSources, classes);
}

JdepsWriter.write(ops.jdepsFilePath, ops.currentTarget, ops.classpath);

/** Copy the resources */
copyResources(ops.resourceSources, ops.resourceTargets, classes);

Expand Down Expand Up @@ -106,7 +95,7 @@ private static String[] collectSrcJarSources(
}

private static List<File> filterFilesByExtension(List<File> files, String extension) {
List<File> filtered = new ArrayList<>();
List<File> filtered = new ArrayList<File>();
for (File f : files) {
if (f.toString().endsWith(extension)) {
filtered.add(f);
Expand Down Expand Up @@ -249,7 +238,7 @@ private static String[] getPluginParamsFrom(CompileOptions ops) {
}

private static void compileScalaSources(CompileOptions ops, String[] scalaSources, Path classes)
throws IOException {
throws IllegalAccessException, IOException {

String[] pluginArgs = buildPluginArgs(ops.plugins);
String[] pluginParams = getPluginParamsFrom(ops);
Expand Down
4 changes: 0 additions & 4 deletions src/java/io/bazel/rulesscala/scalac/ScalacWorker3.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package io.bazel.rulesscala.scalac;

import static java.io.File.pathSeparator;

import io.bazel.rulesscala.jdeps.JdepsWriter;
import scala.Tuple2;
import io.bazel.rulesscala.io_utils.StreamCopy;
import io.bazel.rulesscala.jar.JarCreator;
Expand Down Expand Up @@ -78,8 +76,6 @@ public void work(String[] args) throws Exception {
compileScalaSources(ops, scalaSources, tmpPath);
}

JdepsWriter.write(ops.jdepsFilePath, ops.currentTarget, ops.classpath);

/** Copy the resources */
copyResources(ops.resourceSources, ops.resourceTargets, tmpPath);

Expand Down
13 changes: 0 additions & 13 deletions test/src/main/java/rulesscala/test/jdeps/BUILD

This file was deleted.

45 changes: 0 additions & 45 deletions test/src/main/java/rulesscala/test/jdeps/JdepsWriterTest.java

This file was deleted.

7 changes: 0 additions & 7 deletions twitter_scrooge/twitter_scrooge.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,6 @@ def _compile_generated_scala(
label.name + "_scalac.diagnosticsproto",
sibling = scrooge_jar,
)

jdepsFile = ctx.actions.declare_file(
label.name + ".jdeps",
sibling = scrooge_jar,
)

all_deps = _concat_lists(deps_java_info, implicit_deps)
merged_deps = java_common.merge(all_deps)

Expand All @@ -268,7 +262,6 @@ def _compile_generated_scala(
manifest,
statsfile,
diagnosticsfile,
jdepsFile,
sources = [],
cjars = merged_deps.transitive_compile_time_jars,
all_srcjars = depset([scrooge_jar]),
Expand Down

0 comments on commit ddde9b3

Please sign in to comment.