-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[multiple] Java 8 target for all plugins with -Werror compiler arg #3216
[multiple] Java 8 target for all plugins with -Werror compiler arg #3216
Conversation
PROBLEM: Upgrading to Java 12 will cause the following innocuous warnings to become build failures due to the "-Werror" flag: ``` > Task :connectivity:compileReleaseJavaWithJavac FAILED warning: [options] source value 7 is obsolete and will be removed in a future release warning: [options] target value 7 is obsolete and will be removed in a future release warning: [options] To suppress warnings about obsolete options, use -Xlint:-options. error: warnings found and -Werror specified FAILURE: Build failed with an exception. ``` Example: https://github.com/WorldHealthOrganization/app/runs/1318596280 FIX: Target Java 8 for all plugins that use the `-Werror` compiler argument: ``` android { ... compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } ``` The plugins were all found with: ``` $ find . -name build.gradle | xargs grep Werror ./packages/connectivity/connectivity/android/build.gradle:def args = ["-Xlint:deprecation","-Xlint:unchecked","-Werror"] ./packages/camera/android/build.gradle:def args = ["-Xlint:deprecation","-Xlint:unchecked","-Werror"] ./packages/video_player/video_player/android/build.gradle:def args = ["-Xlint:deprecation","-Xlint:unchecked","-Werror"] ./packages/android_alarm_manager/android/build.gradle:def args = ["-Xlint:deprecation","-Xlint:unchecked","-Werror"] ./packages/android_intent/android/build.gradle:def args = ["-Xlint:deprecation","-Xlint:unchecked","-Werror"] ``` I think the config was broken for video_player. Also updated a few example apps too. WORKAROUND: As a temporary workaround, developers can downgrade to Java 11 which doesn't warn that Java 7 is obsolete. Example: https://github.com/WorldHealthOrganization/app/pull/1669/files#diff-710a4407aba47ffddf61ee9be9490428d5d0883759b18e490858db28e1ace4afR86 REGRESSION: @hamdikahloun - thanks for your work on the Connectivity package. Adding `-Werror` flags is a positive thing but I think is best combined with Java 8 to ensure that the warning don't become error. Your PR: flutter#3051 FYI @mehmetf, @Salakar, @bkonyi, @ened, @dnfield as you've all edited Java 8 targets
@brunobowden Essentially, the target will be the same (Java 1.8), but it's important to use the constant, right? Therefore I would not see functional changes for most users. Under which circumstance would you use Java 12 for Android though? I thought Android kind of lived in the past, toolchain wise. Is this introduced in the latest AGP versions? Would you recommend adding the language level to generated plugin code by default? IMO you will definitely need changelog & version bump ( |
@ened - I was wary about making change too quickly but I essentially agree with everything you've said:
AGP 3.0.0 and above has limited support for Java 8 through desugaring (see links below). So use of some of the more advance features might cause issues.
I expect this is the right thing to do but I'd like to have someone with more experience weigh in on this. Since it should only be minimal wrapper files, they shouldn't need advanced Java capabilities... and using Java 8 LTS seems the most appropriate choice. Fundamentally pinning versions does improve stability and consistency.
Correct for some of the plugins.... there's no change and no version bump is needed. Of the rest, 2 plugins have a clear change, the other 2 plugins I'm unsure about due to the nested "android" config in the build.gradle.
|
@ened - as for Java 12, that was mainly a random choice for the CI. We downgraded to Java 11 as it didn't consider Java 7 as obsolete. It took me quite a long time to track down the problem though and it's nice to solve it for others.... particularly the standard Flutter libraries. |
@ened - please excuse me but I've been snowed under with the World Health Organization App. I will come back to this when I can or you're free to take it and finish it yourself. |
@blasten Are you familiar with the settings here to review this? Is the outer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@stuartmorgan that is a bug |
@brunobowden If you can merge in latest master to resolve the conflict (that should also fix the Windows Plugins CI failure), and add the version bumps (erring on the side of doing it where it may not be strictly necessary is fine), we can get this landed. |
I'll give it a go this morning...
…On Wed, Apr 28, 2021 at 8:51 AM stuartmorgan ***@***.***> wrote:
@brunobowden <https://github.com/brunobowden> If you can merge in latest
master to resolve the conflict (that should also fix the Windows Plugins CI
failure), and add the version bumps (erring on the side of doing it where
it may not be strictly necessary is fine), we can get this landed.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3216 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFF3K7VFEWNDM3FYUCPV2LTLAVJBANCNFSM4TB4VPEA>
.
|
@blasten Do you have cycles to get this PR over the finish line? |
I can probably get to it in a week or so's time.... but feel free to take
it over and do it yourself as that may be easier.
Bruno
…On Tue, Aug 10, 2021 at 6:31 PM stuartmorgan ***@***.***> wrote:
@blasten <https://github.com/blasten> Do you have cycles to get this PR
over the finish line?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3216 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFF3K6C3JUAFATTYAY46Z3T4FPALANCNFSM4TB4VPEA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
.
|
Merged in master, and added metadata updates (version bumps for the changed plugins that aren't deprecated, just CHANGELOG entries for those that are). This should land once tests cycle green. |
Description
Upgrading to Java 12 will cause the following innocuous warnings
to become build failures due to the "-Werror" flag:
Example: https://github.com/WorldHealthOrganization/app/runs/1318596280
Fix
Target Java 8 for all plugins that use the
-Werror
compiler argument:The plugins were all found with:
I think the config was broken for video_player. Also updated a few example apps too.
Workaround
As a temporary workaround, developers can downgrade to Java 11 (e.g. 11.0.9) or lower
which doesn't warn that Java 7 is obsolete. Example:
https://github.com/WorldHealthOrganization/app/pull/1669/files#diff-710a4407aba47ffddf61ee9be9490428d5d0883759b18e490858db28e1ace4afR86
Regression
@hamdikahloun - thanks for your work on the Connectivity package. Adding
-Werror
flags is a positive thing but I think is best combined with Java 8 compile to ensure that
the warnings don't become errors. Your PR: #3051
FYI @mehmetf, @Salakar, @bkonyi, @ened, @dnfield as you've all edited Java 8 targets
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.///
).flutter analyze
) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?