dexmagic / jakartaee-mobile

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jakartaee-mobile Readme

Richard Schilling (https://github.com/dexmagic/)
June 9, 2023 Seattle

I was porting some libraries to Android that are built on Java Architecture for XML Binding (JAXB) to Android and ran into some barriers. I'll repeat them here for anyone else who has struggled with the same thing:

  1. Lots of people seem to have the same need.
  2. The Android project used to build JAXB need to be set up to support Android 19 and higher (see links on Java 19 below).
  3. There is a need for a complete XML binding on Android, and JAXB isn't implemented on Android.
  4. As Java itself changes, I need a working project to verify what features of the Java language are actually supported in any Android production build.

Jakarta EE to the rescue!

There are some additional benefits in creating this project that have to do with building Android libraries and apps on the latest version of Android Studio, Gradle Plugin, and Java source level.

  1. Java 9 Modules means that liraries written for Android need to avoid namespace collisions.
  2. Any JAXB solution on Android close as possible to Oracles' implementation on the Java platform. This is required to minimize the work required to port existing JAXB generate code (client code and potentially server code as well) to Android.
  3. I need to stay ahead of the impact using sourceCompatibility JavaVersion.VERSION_19 and higher would have Android applications.
  4. I need to know how gradle plugin 8.0 and higher impact older Android applications so I can migrate them.
  5. I need to be able to modify and test the Android port without the risk of introducing any issues the original project.

And what better way to achieve all those goals than to build an app with the latest Gradle plugin and highest available Java Source compatability. So this project ports the relevant code at https://github.com/jakartaee to run on Android, AND specifies the source compatability of ANDROID_19.

About This Project

This project copies code from https://github.com/jakartaee with the minimal changes possible. At the moment this is the most viable option to create an Android port. Some changes that cannot be merged back into the original repository are required, however. So simply making direct copies of source that can be compiled on the Android platform is the best option at the moment.

For example, module-info.java files need to be left out because they create errors. Including this file from the jaxb-api project into the module jaxbapi of this repository ...

module jakarta.xml.bind {
    requires transitive jakarta.activation;
    requires transitive java.xml;
    requires java.logging;

    exports jakarta.xml.bind;
    exports jakarta.xml.bind.annotation;
    exports jakarta.xml.bind.annotation.adapters;
    exports jakarta.xml.bind.attachment;
    exports jakarta.xml.bind.helpers;
    exports jakarta.xml.bind.util;

    uses jakarta.xml.bind.JAXBContextFactory;
}

causes the following error:

jakartaee-mobile/android/jaxbapi/src/main/java/module-info.java:18: error: module not found: jakarta.activation
    requires transitive jakarta.activation;
                               ^

Some Useful Links

Java 8 And Beyond

In order to build and maintain applications that run Java EE/JAXB code it's important to have the latest language support. That is the reason this project specifies a very high JavaVersion in build.gradle files. Here is an example from the jaxbapi module in this project:

android {
    namespace 'jakarta.xml.bind'
    compileSdk 33

    defaultConfig {
        minSdk 33
        targetSdk 33
        
        // ...
    }

    buildTypes {
        // ...
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_19
        targetCompatibility JavaVersion.VERSION_19
    }
}

Lots of reading is required to fully understand all the reaasons you would specify JavaVersion.VERSION_19 and higher in your gradle files. So here are some convenient links to help you catch up if you need to.

Gradle Compatability and Java Version 19

As of this writing (June 9, 2023) Gradle does not support Java 20, so the highest Java version I could specify is VERSION_19.

Some notes:

  • Gradle 7.6 is the first version that supports Android 19.

Oracle Source Docs and Information

Jakarta EE

The Eclipse project also implemements a version of JAXB.

Some Additional Links and Reading Material

About

License:Eclipse Public License 2.0


Languages

Language:Java 99.9%Language:HTML 0.1%Language:Kotlin 0.0%Language:Ruby 0.0%