apache / apache/maven-compiler-plugin
[MCOMPILER-209] Incremental compilation doesn't work unless useIncrementalCompilation is set to 'false'
- Dominant language
- Java
- Stars
- 261
- Forks
- 191
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 8
Description
**[Michael Ekstrand](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=ekstrand)** opened **[MCOMPILER-209](https://issues.apache.org/jira/browse/MCOMPILER-209?redirect=false)** and commented
The compiler plugin has the [useIncrementalCompilation](https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#useIncrementalCompilation) flag. However, when this flag is set to `true` and using the `javac` compiler, the compilation is not very incremental; the compiler always at least claims it is rebuilding all source files (and compile times are consistent with this being what it is actually doing, though it is hard to tell). If I set `useIncrementalCompilation` to `false`, then it actually does report that some modules are up-to-date, and some only need a subset of their files compiled.
It seems that one or more of the following is happening:
* `useIncrementalCompilation` has some meaning that is very different from what a user would expect, actually controlling whether the compiler plugin uses some internal incremental compilation mechanism vs. incremental compilation support built-in to the particular compiler backend. One would expect this flag to turn on incremental compilation vs. build-everything.
* The log messages do not reflect what it is actually doing; that is, it seems possible that it's saying "Compiling 164 source files" when it's really handing 164 source files off to the compiler for potential compilation. If this is the case, it is very confusing and misleading.
* The logic of `useIncrementalCompilation` is just inverted. Looking at the source code for the abstract compiler MOJO, it doesn't look like it's quite this simple, but I also don't know what all the various components at work are doing.
* There is a bug in the implementation of `useIncrementalCompilation`.
The result of all this is incremental compilation with Maven is very confusing and difficult to understand.
---
**Affects:** 3.1
**Attachments:**
- [image-2020-07-08-22-03-02-443.png](https://issues.apache.org/jira/secure/attachment/13007344/image-2020-07-08-22-03-02-443.png) (_15.07 kB_)
- [MCOMPILER_209_reversed_if_else_branches_for_useIncrementalCompilation_flag.patch](https://issues.apache.org/jira/secure/attachment/12888611/MCOMPILER_209_reversed_if_else_branches_for_useIncrementalCompilation_flag.patch) (_1.11 kB_)
- [SO_AJ_MavenSoftExceptions.zip](https://issues.apache.org/jira/secure/attachment/12714878/SO_AJ_MavenSoftExceptions.zip) (_2.86 kB_)
**Issue Links:**
- [FLINK-8847](https://issues.apache.org/jira/browse/FLINK-8847) Modules containing package-info.java are always recompiled
62 votes, 98 watchers
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the abstract compiler MOJO source referenced in the report and inspect the attached reversed-if/else patch for useIncrementalCompilation. Reproduce the javac behavior with the flag set to true and false, comparing reported and actual compilation scope. Done means the flag behavior and log messages consistently match incremental compilation expectations, with the relevant regression coverage updated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100