How does problem reporting work with incremental c...
# community-support
a
How does problem reporting work with incremental compile? Let's say I run
gradlew classes
after a
gradlew clean
and I get java warnings in my code. Then I run
gradlew classes
again and I get no warnings. How do I get Gradle to re-report the warnings on the 2nd (incremental) compile? To me it looks as though Gradle is saying that I've fixed the warnings. Is there a command line arg to make sure all outstanding warnings are displayed on the incremental compile?
v
Well, if you do not compile the files, there are not warnings. If you want to get the warnings, you need to do the actual compile.
For example by giving
--rerun
to the task in question
Or
--rerun-tasks
to rerun all tasks.
a
--rerun
doesn't appear to output the warnings again, it seems only
clean classes
will redisplay them. I guess there's no kind of "problems state" stored to be able to reprint warnings. I notice this in Intellij when the build is delegated to Gradle. If I do a
Rebuild Project
then I'll get the warnings/errors from all projects. If I change something in 1 subproject and run
Build project
then all those previous warnings on other subprojects disappear even though they are still issues. Feels like they shouldn't disappear and that Gradle should be keeping them as the output of the task and reprinting that output when the task says
up to date
.
v
That sounds strange, that
--rerun
does not help. I just tried it. I used a deprecated symbol in a class and did compilation and got the deprecated warning. I changed a different class and did compilation and got no warning. I ran the task with
--rerun
without any source changes and I got the deprecated warning again.
Check with the timestamp of the class files whether really all were written newly after using
--rerun
, otherwise you might either have did something wrong or found a bug.
Regarding preserving the warnings for compile-avoided files, I guess you need to open a feature request for that to see what the Gradle folks think about it.
t
Fwiw, if you care about warnings, then you should promote them to errors (at least temporarily) with
-Werror
(for JavaCompile; other languages have equivalent functionality).
a
Ah -
--rerun
reports the warnings and creates new class files if I use
gradlew compileJava --rerun
but not
gradlew classes --rerun
. Is that a bug?
Thanks for the
-Werror
info - I like the "temporary" promotion idea.
t
Is that a bug?
No, it's how
--rerun
works: it only applies to the exact task named on the command line. Alternatively, use
--rerun-tasks
to rerun all tasks.
☝️ 1
a
Ah - gotcha. Thanks for the help Vampire and Thomas
👌 1