diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 902f4e0..82ac4a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,13 +26,19 @@ jobs: name: "test (${{ matrix.target }})" steps: - name: Check out code - uses: "actions/checkout@v4" + uses: actions/checkout@v6 - - name: Set up JDK 21 - uses: "actions/setup-java@v4" + - name: Set up JDK 25 + uses: actions/setup-java@v5 with: - distribution: "temurin" - java-version: 21 + distribution: 'temurin' + java-version: '25' + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v6 + with: + cache-provider: basic + validate-wrappers: true - name: Test with Gradle run: "./gradlew :htmlconverter:${{ matrix.target }}Test" @@ -42,17 +48,18 @@ jobs: steps: - name: Check out code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - - name: Set up JDK 21 - uses: actions/setup-java@v4 + - name: Set up JDK 25 + uses: actions/setup-java@v5 with: distribution: 'temurin' java-version: '21' - name: Set up Gradle - uses: gradle/actions/setup-gradle@v4 + uses: gradle/actions/setup-gradle@v6 with: + cache-provider: basic validate-wrappers: true - name: Build with Gradle diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 907f286..a36efa5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -11,21 +11,22 @@ jobs: steps: - name: Check out code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - - name: Set up JDK 21 - uses: actions/setup-java@v4 + - name: Set up JDK 25 + uses: actions/setup-java@v5 with: distribution: 'temurin' - java-version: '21' + java-version: '25' - name: Set up Gradle - uses: gradle/actions/setup-gradle@v4 + uses: gradle/actions/setup-gradle@v6 with: + cache-provider: basic validate-wrappers: true - name: Publish to Maven Central - run: ./gradlew clean publishToMavenCentral --no-configuration-cache + run: ./gradlew clean publishToMavenCentral env: ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVENCENTRALUSERNAME }} ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVENCENTRALPASSWORD }} diff --git a/README.md b/README.md index 3f470a4..3fe2c40 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ It can be considered as a multiplatform replacement for Android's [`Html.fromHtm #### Android -* Open the project in Android Studio and click ▶ **sample** (run configuration) to build and run. -* _OR_ from the command line: `./gradlew sample:installDebug` to install to a connected device. +* Open the project in Android Studio and click ▶ **androidApp** (run configuration) to build and run. +* _OR_ from the command line: `./gradlew androidApp:installDebug` to install to a connected device. #### Desktop (JVM) diff --git a/androidApp/.gitignore b/androidApp/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/androidApp/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/androidApp/build.gradle.kts b/androidApp/build.gradle.kts new file mode 100644 index 0000000..46a2edb --- /dev/null +++ b/androidApp/build.gradle.kts @@ -0,0 +1,48 @@ +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.jetbrainsCompose) + alias(libs.plugins.compose.compiler) +} + +android { + namespace = "be.digitalia.compose.htmlconverter.sample" + compileSdk = 36 + + defaultConfig { + applicationId = "be.digitalia.compose.htmlconverter.sample" + minSdk = 21 + targetSdk = 36 + versionCode = 1 + versionName = "1.0.0" + } + + buildTypes { + release { + isMinifyEnabled = true + isShrinkResources = true + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt")) + } + packaging { + resources { + excludes += listOf( + "DebugProbesKt.bin", + "kotlin-tooling-metadata.json", + "kotlin/**", + "META-INF/*.version" + ) + } + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } +} + +dependencies { + implementation(project(":sample")) + + implementation(compose.preview) + implementation(libs.androidx.activity.compose) + debugImplementation(compose.uiTooling) +} diff --git a/sample/src/androidMain/AndroidManifest.xml b/androidApp/src/main/AndroidManifest.xml similarity index 100% rename from sample/src/androidMain/AndroidManifest.xml rename to androidApp/src/main/AndroidManifest.xml diff --git a/sample/src/androidMain/kotlin/be/digitalia/compose/htmlconverter/sample/MainActivity.kt b/androidApp/src/main/kotlin/be/digitalia/compose/htmlconverter/sample/MainActivity.kt similarity index 100% rename from sample/src/androidMain/kotlin/be/digitalia/compose/htmlconverter/sample/MainActivity.kt rename to androidApp/src/main/kotlin/be/digitalia/compose/htmlconverter/sample/MainActivity.kt diff --git a/sample/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml b/androidApp/src/main/res/drawable-v24/ic_launcher_foreground.xml similarity index 100% rename from sample/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml rename to androidApp/src/main/res/drawable-v24/ic_launcher_foreground.xml diff --git a/sample/src/androidMain/res/drawable/ic_launcher_background.xml b/androidApp/src/main/res/drawable/ic_launcher_background.xml similarity index 100% rename from sample/src/androidMain/res/drawable/ic_launcher_background.xml rename to androidApp/src/main/res/drawable/ic_launcher_background.xml diff --git a/sample/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml b/androidApp/src/main/res/mipmap-anydpi-v26/ic_launcher.xml similarity index 100% rename from sample/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml rename to androidApp/src/main/res/mipmap-anydpi-v26/ic_launcher.xml diff --git a/sample/src/androidMain/res/mipmap-hdpi/ic_launcher.png b/androidApp/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from sample/src/androidMain/res/mipmap-hdpi/ic_launcher.png rename to androidApp/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/sample/src/androidMain/res/mipmap-mdpi/ic_launcher.png b/androidApp/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from sample/src/androidMain/res/mipmap-mdpi/ic_launcher.png rename to androidApp/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/sample/src/androidMain/res/mipmap-xhdpi/ic_launcher.png b/androidApp/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from sample/src/androidMain/res/mipmap-xhdpi/ic_launcher.png rename to androidApp/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/sample/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png b/androidApp/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from sample/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png rename to androidApp/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/sample/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png b/androidApp/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from sample/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png rename to androidApp/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/sample/src/androidMain/res/values/strings.xml b/androidApp/src/main/res/values/strings.xml similarity index 100% rename from sample/src/androidMain/res/values/strings.xml rename to androidApp/src/main/res/values/strings.xml diff --git a/build.gradle.kts b/build.gradle.kts index 8320432..09a70f8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - alias(libs.plugins.androidApplication) apply false + alias(libs.plugins.android.application) apply false + alias(libs.plugins.android.kotlin.multiplatform.library) apply false alias(libs.plugins.jetbrainsCompose) apply false alias(libs.plugins.compose.compiler) apply false alias(libs.plugins.kotlinMultiplatform) apply false diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index bebe391..0116ca6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,17 +1,18 @@ [versions] -androidGradlePlugin = "8.13.0" +androidGradlePlugin = "9.2.1" androidx-activity-compose = "1.11.0" -jetbrainsCompose = "1.8.0" -kotlin = "2.1.21" +jetbrainsCompose = "1.9.3" +kotlin = "2.2.21" ktxml = "1.0.0" -maven-publish = "0.34.0" +maven-publish = "0.36.0" [libraries] androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity-compose" } ktxml = { module = "org.kobjects.ktxml:core", version.ref = "ktxml" } [plugins] -androidApplication = { id = "com.android.application", version.ref = "androidGradlePlugin" } +android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" } +android-kotlin-multiplatform-library = { id = "com.android.kotlin.multiplatform.library", version.ref = "androidGradlePlugin" } compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "jetbrainsCompose" } kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index a4b76b9..d997cfc 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 37f853b..c61a118 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index f5feea6..739907d 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/2d6327017519d23b96af35865dc997fcb544fb40/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -86,8 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s -' "$PWD" ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -115,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -173,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -206,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/gradlew.bat b/gradlew.bat index 9d21a21..c4bdd3a 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -70,11 +70,10 @@ goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell diff --git a/sample/build.gradle.kts b/sample/build.gradle.kts index 9977ca0..31db8e2 100644 --- a/sample/build.gradle.kts +++ b/sample/build.gradle.kts @@ -3,13 +3,17 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { alias(libs.plugins.kotlinMultiplatform) - alias(libs.plugins.androidApplication) + alias(libs.plugins.android.kotlin.multiplatform.library) alias(libs.plugins.jetbrainsCompose) alias(libs.plugins.compose.compiler) } kotlin { - androidTarget { + android { + namespace = "be.digitalia.compose.htmlconverter.sample.shared" + compileSdk = 36 + minSdk = 21 + compilerOptions { jvmTarget.set(JvmTarget.JVM_11) } @@ -26,16 +30,10 @@ kotlin { } } - jvm("desktop") + jvm() sourceSets { - val androidMain by getting { - dependencies { - implementation(compose.preview) - implementation(libs.androidx.activity.compose) - } - } - val commonMain by getting { + commonMain { dependencies { implementation(project(":htmlconverter")) implementation(compose.runtime) @@ -45,7 +43,7 @@ kotlin { implementation(compose.components.uiToolingPreview) } } - val desktopMain by getting { + jvmMain { dependencies { implementation(compose.desktop.currentOs) } @@ -53,42 +51,6 @@ kotlin { } } -android { - namespace = "be.digitalia.compose.htmlconverter.sample" - compileSdk = 36 - - defaultConfig { - applicationId = "be.digitalia.compose.htmlconverter.sample" - minSdk = 21 - targetSdk = 36 - versionCode = 1 - versionName = "1.0.0" - } - buildTypes { - release { - isMinifyEnabled = true - isShrinkResources = true - } - packaging { - resources { - excludes += listOf( - "DebugProbesKt.bin", - "kotlin-tooling-metadata.json", - "kotlin/**", - "META-INF/*.version" - ) - } - } - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - } - dependencies { - debugImplementation(compose.uiTooling) - } -} - compose.desktop { application { mainClass = "MainKt" diff --git a/sample/src/desktopMain/kotlin/Platform.jvm.kt b/sample/src/jvmMain/kotlin/Platform.jvm.kt similarity index 100% rename from sample/src/desktopMain/kotlin/Platform.jvm.kt rename to sample/src/jvmMain/kotlin/Platform.jvm.kt diff --git a/sample/src/desktopMain/kotlin/main.kt b/sample/src/jvmMain/kotlin/main.kt similarity index 100% rename from sample/src/desktopMain/kotlin/main.kt rename to sample/src/jvmMain/kotlin/main.kt diff --git a/settings.gradle.kts b/settings.gradle.kts index ea4393f..52c62b9 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -14,4 +14,5 @@ dependencyResolutionManagement { rootProject.name = "HtmlConverterCompose" include(":htmlconverter") -include(":sample") \ No newline at end of file +include(":sample") +include(":androidApp")