google / google/compile-testing

Avoid implicitly compiling sources from the classpath

Open
#149 4 comments 0 reactions 0 assignees View on GitHub
P3
Dominant language
Java
Stars
722
Forks
129
Avg merge
11m
Merged PRs (30d)
4

Description

You can see some internal discussion on CL 198652081, but in short:

- Truth depends on `guava-gwt`.
- The `guava-gwt` jar contains `.java` files.
- Truth has a test that uses Compile-Testing, and it compiles not just the file we give it but also (automatically and undesired by us) those `.java` files.
- This used to work, but because Truth uses `guava-android` but `guava-gwt` uses `guava-jre`, Maven puts `guava-android` on the classpath when `guava-gwt` needs `guava-jre` and its dependencies. So now the compilation fails.

We're going to work around this by:

- Making Truth pass `-sourcepath ''` to Compile-Testing.
- Adding an explicit dependency from `guava-gwt` to some dependencies that it uses directly but currently gets transitively through `guava-jre`.

But maybe Compile-Testing should be setting `-sourcepath ''` internally automatically? (Or maybe there's something else similar it should be doing; I've heard that all this is [surprisingly complex](https://blog.ltgt.net/most-build-tools-misuse-javac/).)

On the other hand, probably few people will be affected by this: They won't have `.java` files on their classpath, and even if they do, the files will compile fine because the dependencies will be there. Still, I wonder if they will see unexpected warnings or other output in some cases. (*Maybe* I've seen some reports of weird Compile-Testing behavior before in AutoValue or something? I'll see if I can dig anything up.) And presumably it's at least a little wasteful to compile files that we don't need.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.