Skip to content

Commit e624254

Browse files
authored
Collect generates source as well as dependency information (#15)
* Switch to using the JDT Batch compiler directly, dropping the use of the tool interface. * Add support for computing list of generated sources during annotation processing. * Add support for computing list of used dependencies. * Add support for configuring access rules based on strict dependency checking.
1 parent bf805f2 commit e624254

21 files changed

+1481
-246
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Once this is completed, add this to your `.bazelrc`:
1212
build --extra_toolchains=@bazel_jdt_java_toolchain//jdt:all
1313
```
1414

15-
By default the `jdt_java_toolchain` is using `local_jdk` for compilation.
15+
By default the `jdt_java_toolchain` is using `local_jdk` for compilation.
1616
Please create your own `default_java_toolchain` if this doesn't work for your use case.
1717

1818
Have a look at `jdt/BUILD` to see which JDKs are supported.
@@ -35,17 +35,18 @@ and point directly at the source of this repo for development and testing.
3535

3636
Unfortunately this means additional steps are required for developers. This script can be
3737
used to facilitate the steps.
38+
3839
```
3940
#!/bin/bash
4041
4142
bazel build :JdtJavaBuilder_deploy.jar
4243
cp -fv bazel-bin/JdtJavaBuilder_deploy.jar compiler/export/
4344
44-
bazel build //compiler/third_party/turbine:turbine_direct_binary_deploy.jar
45+
bazel build //compiler/third_party/turbine:turbine_direct_binary_deploy.jar
4546
cp -fv bazel-bin/compiler/third_party/turbine/turbine_direct_binary_deploy.jar compiler/tools/
4647
```
4748

48-
For your convinience, the `build-toolchain` script is provided in this repository.
49+
For your convenience, the `build-toolchain` script is provided in this repository.
4950

5051

5152
## Debugging
@@ -85,8 +86,8 @@ ERROR: /Users/username/app/main/core/some-java-target/BUILD.bazel:4:13: Building
8586
/Users/username/tools/Darwin/jdk/bin/java -jar external/jdt_java_toolchain/builder/export/JdtJavaBuilder_deploy.jar @bazel-out/darwin-fastbuild/bin/some-java-target/libtarget-class.jar-0.params @bazel-out/darwin-fastbuild/bin/some-java-target/libtarget-class.jar-1.params)
8687
```
8788

88-
Either take the *SUBCOMMAND* or *ERROR* command.
89-
You can ignore the `exec env` part.
89+
Either take the *SUBCOMMAND* or *ERROR* command.
90+
You can ignore the `exec env` part.
9091

9192
The interesting two steps are:
9293

@@ -99,7 +100,7 @@ cd /private/var/tmp/_bazel_username/hash/execroot/core
99100
```
100101

101102
The first is the execution directory and the latter the command.
102-
You need to cd into the execution directory and then run the command yourself.
103+
You need to `cd` into the execution directory and then run the command yourself.
103104
But this time add the remote debug arguments (before `-jar`) as follows:
104105

105106
```
@@ -120,3 +121,4 @@ The VS Code Bazel Java extension should also work.
120121
## Releasing
121122

122123
See [RELEASING README](dist/README.md).
124+

compiler/BUILD

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ java_library(
3535
"@rules_jdt_org_ow2_asm_asm_commons",
3636
"@rules_jdt_org_ow2_asm_asm_tree",
3737
],
38+
javacopts = [
39+
"--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
40+
"--add-exports=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
41+
"--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
42+
"--add-exports=jdk.compiler/com.sun.tools.javac.resources=ALL-UNNAMED",
43+
"--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
44+
"--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
45+
],
3846
visibility = ["//:__subpackages__"],
3947
)
4048

compiler/src/main/buildjar/com/google/devtools/build/buildjar/JavaLibraryBuildRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public JavaLibraryBuildRequest(
176176
this.processingModule = processingBuilder.build();
177177

178178
ImmutableList.Builder<BlazeJavaCompilerPlugin> pluginsBuilder =
179-
ImmutableList.<BlazeJavaCompilerPlugin>builder();//.add(dependencyModule.getPlugin());
179+
ImmutableList.<BlazeJavaCompilerPlugin>builder().add(dependencyModule.getPlugin());
180180
processingModule.registerPlugin(pluginsBuilder);
181181
pluginsBuilder.addAll(extraPlugins);
182182
this.plugins = pluginsBuilder.build();

0 commit comments

Comments
 (0)