diff --git a/.gitignore b/.gitignore index 8fe930ab..490c2bdf 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,4 @@ iosApp/iosApp.xcworkspace/* iosApp/iosApp.xcodeproj/* !iosApp/iosApp.xcodeproj/project.pbxproj shared/shared.podspec +/.kotlin diff --git a/android/build.gradle.kts b/android/build.gradle.kts index c1b43a1a..5397a437 100644 --- a/android/build.gradle.kts +++ b/android/build.gradle.kts @@ -1,37 +1,41 @@ plugins { - id("org.jetbrains.compose") - id("com.android.application") - kotlin("android") + alias(libs.plugins.compose) + alias(libs.plugins.compose.compiler) + alias(libs.plugins.android.application) + alias(libs.plugins.android.kotlin) } group = "com.aay" version = "1.0-SNAPSHOT" -repositories { - jcenter() -} - dependencies { implementation(project(":common")) - implementation("androidx.activity:activity-compose:1.5.0") + implementation(libs.compose.activity) } android { - compileSdkVersion(33) + compileSdk = 34 + defaultConfig { applicationId = "com.aay.android" - minSdkVersion(24) - targetSdkVersion(33) + minSdk = 24 versionCode = 1 versionName = "1.0-SNAPSHOT" } + compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } + buildTypes { - getByName("release") { + release { isMinifyEnabled = false } } + + kotlin.jvmToolchain(8) + + namespace = "com.aay.android" + } \ No newline at end of file diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index bc961be8..a65de848 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ - + ''} + spec.authors = '' + spec.license = '' + spec.summary = '' + spec.vendored_frameworks = 'build/cocoapods/framework/chart.framework' + spec.libraries = 'c++' + + + + if !Dir.exist?('build/cocoapods/framework/chart.framework') || Dir.empty?('build/cocoapods/framework/chart.framework') + raise " + + Kotlin framework 'chart' doesn't exist yet, so a proper Xcode project can't be generated. + 'pod install' should be executed after running ':generateDummyFramework' Gradle task: + + ./gradlew :chart:generateDummyFramework + + Alternatively, proper pod installation is performed during Gradle sync in the IDE (if Podfile location is set)" + end + + spec.xcconfig = { + 'ENABLE_USER_SCRIPT_SANDBOXING' => 'NO', + } + + spec.pod_target_xcconfig = { + 'KOTLIN_PROJECT_PATH' => ':chart', + 'PRODUCT_MODULE_NAME' => 'chart', + } + + spec.script_phases = [ + { + :name => 'Build chart', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then + echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" + exit 0 + fi + set -ev + REPO_ROOT="$PODS_TARGET_SRCROOT" + "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ + -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ + -Pkotlin.native.cocoapods.archs="$ARCHS" \ + -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" + SCRIPT + } + ] + spec.resources = ['build/compose/cocoapods/compose-resources'] +end \ No newline at end of file diff --git a/chart/src/androidMain/AndroidManifest.xml b/chart/src/androidMain/AndroidManifest.xml index cbe90a92..de749acb 100644 --- a/chart/src/androidMain/AndroidManifest.xml +++ b/chart/src/androidMain/AndroidManifest.xml @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 90c1b573..4a13e413 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -1,54 +1,53 @@ -import org.jetbrains.compose.compose - plugins { - kotlin("multiplatform") - id("org.jetbrains.compose") - id("com.android.library") + alias(libs.plugins.multiplatform) + alias(libs.plugins.compose) + alias(libs.plugins.compose.compiler) + alias(libs.plugins.android.library) } group = "com.aay" version = "1.0-SNAPSHOT" kotlin { - android() - jvm("desktop") { - jvmToolchain(11) - } + androidTarget() + + jvm("desktop") + sourceSets { - val commonMain by getting { - dependencies { - implementation(project(":chart")) - api(compose.runtime) - api(compose.foundation) - api(compose.material) - } + commonMain.dependencies { + implementation(project(":chart")) + api(compose.runtime) + api(compose.foundation) + api(compose.material) } - val androidMain by getting { - dependencies { - api("androidx.appcompat:appcompat:1.5.1") - api("androidx.core:core-ktx:1.9.0") - } + androidMain.dependencies { + api(libs.appCompat) + api(libs.compose.activity) } - val desktopMain by getting { - dependencies { - api(compose.preview) - } + sourceSets["desktopMain"].dependencies { + api(compose.preview) } } } android { - compileSdkVersion(34) + compileSdk = 34 + sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") + defaultConfig { - minSdkVersion(21) - targetSdkVersion(34) + minSdk = 21 } + compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } + + kotlin.jvmToolchain(8) + + namespace = "com.aay.common" } \ No newline at end of file diff --git a/common/src/androidMain/AndroidManifest.xml b/common/src/androidMain/AndroidManifest.xml index 18cb6c10..de749acb 100644 --- a/common/src/androidMain/AndroidManifest.xml +++ b/common/src/androidMain/AndroidManifest.xml @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/desktop/build.gradle.kts b/desktop/build.gradle.kts index 436591e0..53d016ed 100644 --- a/desktop/build.gradle.kts +++ b/desktop/build.gradle.kts @@ -1,8 +1,9 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat plugins { - kotlin("multiplatform") - id("org.jetbrains.compose") + alias(libs.plugins.multiplatform) + alias(libs.plugins.compose) + alias(libs.plugins.compose.compiler) } group = "com.aay" @@ -11,7 +12,6 @@ version = "1.0-SNAPSHOT" kotlin { jvm { - jvmToolchain(11) withJava() } @@ -33,14 +33,11 @@ kotlin { val target = "${targetOs}-${targetArch}" sourceSets { - val jvmMain by getting { - dependencies { - implementation(project(":common")) - implementation(compose.desktop.currentOs) - implementation("org.jetbrains.skiko:skiko-awt-runtime-$target:$version") - } + jvmMain.dependencies { + implementation(project(":common")) + implementation(compose.desktop.currentOs) + implementation("org.jetbrains.skiko:skiko-awt-runtime-$target:$version") } - val jvmTest by getting } } diff --git a/gradle.properties b/gradle.properties index fafb552c..06a49877 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ kotlin.code.style=official -kotlin.native.enableDependencyPropagation=false +#kotlin.native.enableDependencyPropagation=false android.useAndroidX=true -kotlin.version=1.9.0 -agp.version=7.4.1 -compose.version=1.4.3 org.jetbrains.compose.experimental.uikit.enabled=true xcodeproj=./iosApp -org.jetbrains.compose.experimental.jscanvas.enabled=true \ No newline at end of file +org.jetbrains.compose.experimental.jscanvas.enabled=true +android.defaults.buildfeatures.buildconfig=true +android.nonTransitiveRClass=false +android.nonFinalResIds=false \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..7979224b --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,23 @@ +[versions] +kotlin = "2.0.21" +agp = "8.8.0" +compose-plugin = "1.7.0" +compose-activity = "1.9.3" +appCompat = "1.5.1" +androidx-core = "1.9.0" +dokka="1.5.0" + +[plugins] +android-library = { id = "com.android.library", version.ref = "agp" } +android-kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +android-application = { id = "com.android.application", version.ref = "agp" } +multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } +compose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" } +compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } +nativeCocoapod = { id = "org.jetbrains.kotlin.native.cocoapods", version.ref = "kotlin" } +dokka={id="org.jetbrains.dokka", version.ref="dokka"} + +[libraries] +compose-activity = { module = "androidx.activity:activity-compose", version.ref = "compose-activity" } +appCompat = { module = "androidx.appcompat:appcompat", version.ref = "appCompat" } +androidx-core = { module = "androidx.core:core-ktx", version.ref = "androidx-core" } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e5832..d64cd491 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 ae04661e..df97d72b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c7873..1aa94a42 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,11 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +131,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +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, +# 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" \ @@ -205,6 +214,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index ac1b06f9..6689b85b 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/settings.gradle.kts b/settings.gradle.kts index 0aeecc8b..ce2a975b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -5,14 +5,6 @@ pluginManagement { mavenCentral() maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") } - - plugins { - kotlin("multiplatform").version(extra["kotlin.version"] as String) - kotlin("android").version(extra["kotlin.version"] as String) - id("com.android.application").version(extra["agp.version"] as String) - id("com.android.library").version(extra["agp.version"] as String) - id("org.jetbrains.compose").version(extra["compose.version"] as String) - } } rootProject.name = "AAY-chart"