diff --git a/.github/workflows/build-quick.yml b/.github/workflows/build-quick.yml index 83a8560d0..9846a93ee 100644 --- a/.github/workflows/build-quick.yml +++ b/.github/workflows/build-quick.yml @@ -261,7 +261,7 @@ jobs: run: ./check-rust.bat - name: Run tests (Unit) - run: ./gradlew test rsdroid:lint ktlintCheck --daemon + run: ./gradlew test rsdroid:lint rsdroid-android:lint ktlintCheck --daemon - name: Run tests (Emulator) uses: reactivecircus/android-emulator-runner@v2 @@ -287,6 +287,14 @@ jobs: if-no-files-found: error path: rsdroid/build/outputs/aar + - name: Upload Android wrapper AAR as artifact + uses: actions/upload-artifact@v6 + if: '!cancelled()' + with: + name: rsdroid-android-aar-${{ matrix.os }} + if-no-files-found: error + path: rsdroid-android/build/outputs/aar + - name: Upload rsdroid-robo JAR as artifact uses: actions/upload-artifact@v6 if: '!cancelled()' diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 4bbeaba85..a794e8f42 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -175,6 +175,13 @@ jobs: if-no-files-found: error path: rsdroid/build/outputs/aar + - name: Upload Android wrapper AAR as artifact + uses: actions/upload-artifact@v6 + with: + name: rsdroid-android-aar + if-no-files-found: error + path: rsdroid-android/build/outputs/aar + - name: Upload rsdroid-robo JAR as artifact uses: actions/upload-artifact@v6 with: @@ -184,7 +191,7 @@ jobs: # following steps only run on workflow dispatch - - name: Publish AAR to Maven + - name: Publish backend and Android wrapper AARs to Maven if: "${{ github.event.inputs.mavenPublish != '' && github.event_name == 'workflow_dispatch'}}" env: ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_PRIVATE_KEY }} @@ -192,7 +199,7 @@ jobs: ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} run: | - ./gradlew rsdroid:publishAllPublicationsToMavenCentral -DtestBuildType=release -Dorg.gradle.daemon=false -Dorg.gradle.console=plain + ./gradlew rsdroid:publishAllPublicationsToMavenCentral rsdroid-android:publishAllPublicationsToMavenCentral -DtestBuildType=release -Dorg.gradle.daemon=false -Dorg.gradle.console=plain - name: Publish JAR to Maven if: "${{ github.event.inputs.mavenPublish != '' && github.event_name == 'workflow_dispatch'}}" diff --git a/README.md b/README.md index fc880044b..388be0930 100644 --- a/README.md +++ b/README.md @@ -90,10 +90,12 @@ set PATH=%PATH%;c:\msys64\usr\bin ## Building -Two main files need to be built: +The build produces three artifacts: - The main .aar file, which contains the backend Kotlin code, web assets, and Anki backend code compiled for Android. +- An Android wrapper .aar in `rsdroid-android/build/outputs/aar`. Its published +Maven metadata declares an API dependency on the main backend artifact. - A .jar that contains the backend code compiled for the host platform, for use with Robolectric unit tests. diff --git a/check-droid.bat b/check-droid.bat index 061832cc8..b49f9db41 100755 --- a/check-droid.bat +++ b/check-droid.bat @@ -3,4 +3,4 @@ if not exist rsdroid\build\outputs\aar\rsdroid-release.aar ( exit 1 ) -./gradlew rsdroid:lint rsdroid-instrumented:connectedCheck +./gradlew rsdroid:lint rsdroid-android:lint rsdroid-instrumented:connectedCheck diff --git a/check-droid.sh b/check-droid.sh index 2101d8c0b..8a5431096 100755 --- a/check-droid.sh +++ b/check-droid.sh @@ -9,4 +9,4 @@ test -f rsdroid/build/outputs/aar/rsdroid-release.aar || ( . ./set-android-ndk-home.sh -./gradlew rsdroid:lint rsdroid-instrumented:connectedCheck +./gradlew rsdroid:lint rsdroid-android:lint rsdroid-instrumented:connectedCheck diff --git a/gradle.properties b/gradle.properties index c6c74ac44..44d487f5e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,7 +19,7 @@ android.useAndroidX=true android.enableJetifier=false GROUP=io.github.david-allison -VERSION_NAME=0.1.72-anki26.09.3 +VERSION_NAME=0.1.73-anki26.09.3 POM_INCEPTION_YEAR=2020 diff --git a/rsdroid-android/README.md b/rsdroid-android/README.md new file mode 100644 index 000000000..e5401aa24 --- /dev/null +++ b/rsdroid-android/README.md @@ -0,0 +1,14 @@ +# rsdroid-android + +Android entry point for the Anki backend. This Android library exposes +[`:rsdroid`](../rsdroid) through an `api` dependency, so consumers can use the +backend API through this module. + +## Planned contents + +After the split, `anki-backend-android` will contain: + +- Android native libraries (`librsdroid.so` for each supported architecture). +- Web assets packaged as Android assets. +- Android SQLite adapters. + - Planned to be extracted later. \ No newline at end of file diff --git a/rsdroid-android/build.gradle b/rsdroid-android/build.gradle new file mode 100644 index 000000000..1a04c2e99 --- /dev/null +++ b/rsdroid-android/build.gradle @@ -0,0 +1,45 @@ +plugins { + alias(libs.plugins.android.library) + id 'signing' + alias(libs.plugins.gradle.maven.publish.plugin) +} + +android { + namespace = 'net.ankiweb.rsdroid.android' + compileSdk = libs.versions.compileSdk.get().toInteger() + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + + defaultConfig { + minSdk = libs.versions.minSdk.get().toInteger() + + consumerProguardFiles "consumer-rules.pro" + } + + buildTypes { + release { + minifyEnabled = false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + testOptions { + targetSdk = libs.versions.targetSdk.get().toInteger() + } + + lint { + targetSdk = libs.versions.targetSdk.get().toInteger() + } +} + +dependencies { + api project(path: ':rsdroid') +} + +mavenPublishing { + publishToMavenCentral(true) + signAllPublications() +} diff --git a/rsdroid-android/consumer-rules.pro b/rsdroid-android/consumer-rules.pro new file mode 100644 index 000000000..e69de29bb diff --git a/rsdroid-android/gradle.properties b/rsdroid-android/gradle.properties new file mode 100644 index 000000000..82bbe496d --- /dev/null +++ b/rsdroid-android/gradle.properties @@ -0,0 +1,5 @@ +POM_ARTIFACT_ID=anki-backend-android +POM_PACKAGING=aar + +POM_NAME=Anki Backend (Android) +POM_DESCRIPTION=Android entry point for the Anki backend diff --git a/rsdroid-android/proguard-rules.pro b/rsdroid-android/proguard-rules.pro new file mode 100644 index 000000000..481bb4348 --- /dev/null +++ b/rsdroid-android/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 38e95587c..7076d7dc9 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -8,4 +8,4 @@ pluginManagement { rootProject.name = "Anki-Android-Backend" -include(":rsdroid-testing", ":rsdroid-instrumented", ":rsdroid") \ No newline at end of file +include(":rsdroid-testing", ":rsdroid-instrumented", ":rsdroid", ":rsdroid-android")