Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android compatibility checks #4070

Merged
merged 14 commits into from
Dec 23, 2022
Merged

Android compatibility checks #4070

merged 14 commits into from
Dec 23, 2022

Conversation

vitorpamplona
Copy link
Contributor

@vitorpamplona vitorpamplona commented Sep 23, 2022

Adding a maven plugin to check the compatibility of given modules with Android APIs:

  • base
  • structures
  • validation
  • converters

The idea is to declare compliance with Android 8 and up. The plugin runs through the source code to check if all classes and all methods used are available in that version of Android. Android 8 uses SDK 26 and was released in 2017. This should give us good coverage without blocking the use of newer Java APIs.

Run with:

  • ./mvnw animal-sniffer:check

…n all projects being used on the platform: base + android + converter + structures + validation.
@jamesagnew
Copy link
Collaborator

@vitorpamplona does this work for you?

I just checked it out, and when I run it I see the following error:

[ERROR] Failed to execute goal org.codehaus.mojo:animal-sniffer-maven-plugin:1.22:check (default-cli) on project hapi-fhir-server: Execution default-cli of goal org.codehaus.mojo:animal-sniffer-maven-plugin:1.22:check failed: PermittedSubclasses requires ASM9 -> [Help 1]

I thought maybe it was an issue because I'm running on JDK17 but I see the same error if I downgrade to JDK11. Bumping the ASM dependency to the animal sniffer plugin didn't help unfortunately.

@vitorpamplona
Copy link
Contributor Author

vitorpamplona commented Nov 9, 2022

Hum... it still works here, for Java11 and Java17 on MacOS.

FYI, base is not compliant anymore:

[ERROR] /Users/vitor/Documents/workspace/hapi-fhir/hapi-fhir-base/src/main/java/ca/uhn/fhir/validation/ValidationContext.java:57: Undefined reference: boolean java.util.Optional.isEmpty()

Optional.isEmpty is not available on Android.

@jamesagnew
Copy link
Collaborator

Weird! What does mvn -v give you in terms of an environment? I'm on:

❯ mvn -v
Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: /opt/homebrew/Cellar/maven/3.8.6/libexec
Java version: 11.0.17, vendor: Amazon.com Inc., runtime: /Users/james/.sdkman/candidates/java/11.0.17-amzn
Default locale: en_CA, platform encoding: UTF-8
OS name: "mac os x", version: "13.0", arch: "aarch64", family: "mac"

@vitorpamplona
Copy link
Contributor Author

➜  ./mvnw -v                  
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /Users/vitor/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3
Java version: 17.0.5, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk@17/17.0.5/libexec/openjdk.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "11.6.7", arch: "x86_64", family: "mac"

@vitorpamplona
Copy link
Contributor Author

Maybe this is an M1/M2 issue? I am still on intel.

@jamesagnew
Copy link
Collaborator

I wonder... I just got this new M2 MacBook. It's crazy fast, but definitely some things don't work well on it.

I'll try on my home linux/x86_64 machine tonight.

@vitorpamplona
Copy link
Contributor Author

Good to know... I am about to buy one :)

@jamesagnew
Copy link
Collaborator

Well, sure enough, this works just fine on my Linux box.

What a weird side effect.

I'm definitely good to merge this, although it should probably be moved to the CI profile in the POM so that it doesn't run by default (most of us on the project are on Macs). We'd also actually need to tackle the issues causing the failure before merging it. Would you be up for moving it into the CI profile, then doing any one of the following?

  • Set the plugin to warn but not fail and we can fix the API issues in a separate PR
  • Make me a contributor to your fork and I'll fix the API issues
  • You take a stab at fixing the API issues

PS - Despite this wacky behaviour, I highly recommend the M2! It cuts my build times in half compared to my 4 year old MBP, and the battery life is... well, i have trouble believing it. I worked away in IJ and watched a webinar yesterday for an hour and only used about 10%.

@JPercival
Copy link
Collaborator

@vitorpamplona - Can you merge the latest from master and revalidate?

@vitorpamplona
Copy link
Contributor Author

Good to go. But I can never get CI to pass :(

@vitorpamplona
Copy link
Contributor Author

Now we are a go! :) @JPercival

@codecov
Copy link

codecov bot commented Dec 23, 2022

Codecov Report

Base: 81.00% // Head: 81.31% // Increases project coverage by +0.30% 🎉

Coverage data is based on head (e74dc94) compared to base (02944ba).
Patch has no changes to coverable lines.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #4070      +/-   ##
============================================
+ Coverage     81.00%   81.31%   +0.30%     
- Complexity    23466    23619     +153     
============================================
  Files          1446     1421      -25     
  Lines         86175    86405     +230     
  Branches      11798    11698     -100     
============================================
+ Hits          69809    70258     +449     
+ Misses        11087    10962     -125     
+ Partials       5279     5185      -94     
Impacted Files Coverage Δ
...validation/validator/VersionTypeAdvisorDstu21.java 0.00% <0.00%> (-100.00%) ⬇️
...ir/jpa/provider/r4/BaseResourceProviderR4Test.java 0.00% <0.00%> (-95.32%) ⬇️
...ir/jpa/api/dao/MetadataKeyCurrentlyReindexing.java 40.00% <0.00%> (-60.00%) ⬇️
ca/uhn/fhir/mdm/api/IMdmLink.java 42.85% <0.00%> (-28.58%) ⬇️
...uhn/fhir/jpa/term/config/TermCodeSystemConfig.java 75.00% <0.00%> (-25.00%) ⬇️
...scription/match/deliver/email/EmailSenderImpl.java 75.00% <0.00%> (-25.00%) ⬇️
...a/uhn/fhir/jpa/mdm/svc/MdmLinkQuerySvcImplSvc.java 66.66% <0.00%> (-20.84%) ⬇️
...bscription/channel/impl/LinkedBlockingChannel.java 72.72% <0.00%> (-17.28%) ⬇️
...model/entity/ResourceIndexedComboStringUnique.java 56.75% <0.00%> (-16.22%) ⬇️
...hir/rest/server/servlet/ServletRequestDetails.java 73.56% <0.00%> (-15.84%) ⬇️
... and 306 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants