Skip to content

Commit 51db260

Browse files
committed
Add documentation about temporary compile outputs
Backport from #23251 to 7.6.1
1 parent a650e73 commit 51db260

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

subprojects/docs/src/docs/userguide/jvm/java_plugin.adoc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,26 @@ To help you understand how incremental compilation works, the following provides
509509
* Having a source structure that does not match the package names, while legal for compilation, might end up causing trouble in the toolchain.
510510
Even more if annotation processing and <<build_cache.adoc#build_cache,caching>> are involved.
511511

512+
Additionally, Gradle might temporarily change the output location while running incremental compilation.
513+
This might affect some annotation processors that inspect output locations or accept file paths as arguments (e.g., `-XepExcludedPaths` in Error Prone).
514+
There are two options:
515+
516+
- Disable `incremental after failure` by setting link:{javadocPath}/org/gradle/api/tasks/compile/CompileOptions.html#getIncrementalAfterFailure--[`options.incrementalAfterFailure`] to `false` on the JavaCompile task.
517+
- Keep `incremental after failure` enabled by instead passing a temporary output value to the annotation processor as a parameter so that the annotation processor is aware of the temporary path.
518+
519+
In the case of Error Prone, `-XepExcludedPaths` must be set. Given an existing value of `-XepExcludedPaths=.\*/build/generated/.*`, the updated value would be
520+
`-XepExcludedPaths=.\*/(build/generated|compileJava/compileTransaction/annotation-output)/.*`.
521+
522+
The following table shows the mapping from default output location to temporary output location:
523+
524+
.Compiler output to temporary output location
525+
|===
526+
| JavaCompile location property | Default output location | Temporary output location
527+
| `destinationDirectory` | `build/classes/java/main` | `build/tmp/<task-name>/compileTransaction/compile-output`
528+
| `options.generatedSourceOutputDirectory` | `build/generated/sources/annotationProcessor/java/main` | `build/tmp/<task-name>/compileTransaction/annotation-output`
529+
| `options.headerOutputDirectory` | `build/generated/sources/headers/java/main` | `build/tmp/<task-name>/compileTransaction/header-output`
530+
|===
531+
512532
[[sec:incremental_annotation_processing]]
513533
== Incremental annotation processing
514534

subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@ Use `implementation.bundle(libs.bundles.testing)` instead.
173173

174174
For more information, see the updated <<jvm_test_suite_plugin.adoc#sec:declare_an_additional_test_suite, declare an additional test suite>> example in the JVM Test Suite Plugin section of the user guide and the link:{groovyDslPath}/org.gradle.api.artifacts.dsl.DependencyAdder.html[`DependencyAdder`] page in the DSL reference.
175175

176+
==== Incremental compilation temporarily changes the output location
177+
178+
Incremental Java and Groovy compilation may now change the compiler output location.
179+
This might affect some annotation processors that allow users to wire some action to file paths (e.g. `-XepExcludedPaths` in Error Prone).
180+
This behaviour can be disabled by setting `options.incrementalAfterFailure` to `false`.
181+
Please refer to the <<java_plugin#sec:incremental_compilation_known_issues, userguide section about known incremental compilation issues>> for more details.
182+
176183
=== Deprecations
177184

178185
[[invalid_toolchain_specification_deprecation]]

0 commit comments

Comments
 (0)