Status Update
Comments
bi...@google.com <bi...@google.com>
bi...@google.com <bi...@google.com> #2
Based on Ivan's first comment, I tested it out by setting release
to 8/9 and also targetCompatibility
/SourceCompatibity
to 8/9 respectively.
With release
set to 8 and targetCompatibility
/SourceCompatibity
set to 8 => build failed with "not able to resolve xx android classs"
With release
set to 9 and targetCompatibility
/SourceCompatibity
set to 9 => build finished
With release
set to 9 and targetCompatibility
/SourceCompatibity
set to 8 => build failed as expected (because we rely on source/target compatibility dsl to create jdk image)
So release
8 should not be allowed.
In terms of checking -source/-target
, java compiler doesn't allow using them together with --release
and you would get error like
> error: option -source cannot be used together with --release
so it seems we don't need to check -source/-target
? Ivan, WDYT?
ga...@google.com <ga...@google.com> #3
I think we should still validate that release/source/target are in sync, and emit a sync error if they are not, instead of waiting for the task execution to report this issue. This is also because AGP needs information on the targeted java version in order to figure out build flow (e.g. the image creation).
Also, we should report issue at configuration time if release
is set to 8.
bi...@google.com <bi...@google.com> #4
For reporting the issue if setting release
to 8 at configuration time, how do we make sure there is no configuration to JavaCompile
task from users after we configure JavaCompile
?(what if we do the check before they set release
to 8)
Do we have to use doFirst{} in this case?
ga...@google.com <ga...@google.com> #5
Users should interact with AGP using DSL/API. Configuring tasks directly is not supported. See how we handle other error/warning reporting.
bi...@google.com <bi...@google.com> #6
Yeah, configuring task directly should no longer be supported. But
ga...@google.com <ga...@google.com> #7
What happens if release
is set to 9, but source/target are not set?
What is the error message for release = 9 and source/target set to 8? Should we improve it?
Do we need to evaluate value of release
option during configuration (it is a doFirst
makes sense. If we need to get the actual value, then it makes sense to have these checks in configuration phase.
bi...@google.com <bi...@google.com> #8
The expectation from javac is that if you set release
, then don't set -source/-target
. If you set release
to 9 and -source/-target
to 8, then javac would complain about using them together.(not about the version being not in sync)
I am still confused about whether users can configure JavaCompile
task directly, can you confirm?
ga...@google.com <ga...@google.com> #9
I am still confused about whether users can configure JavaCompile task directly, can you confirm?
Users can configure JavaCompile
directly (it is just a property on the task).
Considering the main goal of -release
is to replace -source/-target/-bootclasspath
, it may make sense to discourage its usage in Android project. We can add a warning (asking users to avoid specifying it), and then turn that into an error at some point. What do you think?
bi...@google.com <bi...@google.com> #10
Fixed with Icf5adc2c469b8af68205ccd8aea377c9295834d6
Description
AGP should take value of
javaCompile.options.release
into account when setting up compilation:--release 8
should not be allowed as it does not allow AGP to change-bootclasspath
param value-source/-target
Original issue: https://issuetracker.google.com/185418460