diff --git a/Common/build.gradle.kts b/Common/build.gradle.kts index 5e960869..d390f58b 100644 --- a/Common/build.gradle.kts +++ b/Common/build.gradle.kts @@ -1,3 +1,4 @@ +import com.infomaniak.multiplatform_swisstranfer.utils.Versions import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework @@ -7,15 +8,11 @@ plugins { alias(libs.plugins.androidLibrary) } -val sharedMinSdk: Int by rootProject.extra -val sharedCompileSdk: Int by rootProject.extra -val javaVersion: JavaVersion by rootProject.extra - kotlin { androidTarget { @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { - jvmTarget.set(JvmTarget.fromTarget(javaVersion.toString())) + jvmTarget.set(JvmTarget.fromTarget(Versions.javaVersion.toString())) } } @@ -37,6 +34,7 @@ kotlin { sourceSets { commonMain.dependencies { api(libs.kotlinx.coroutines.core) + api(libs.kotlinx.datetime) } commonTest.dependencies { implementation(libs.kotlin.test) @@ -46,12 +44,12 @@ kotlin { android { namespace = "com.infomaniak.multiplatform_swisstransfer.common" - compileSdk = sharedCompileSdk + compileSdk = Versions.compileSdk defaultConfig { - minSdk = sharedMinSdk + minSdk = Versions.minSdk } compileOptions { - sourceCompatibility = javaVersion - targetCompatibility = javaVersion + sourceCompatibility = Versions.javaVersion + targetCompatibility = Versions.javaVersion } } diff --git a/Core/build.gradle.kts b/Core/build.gradle.kts index 57cbd09f..39f26656 100644 --- a/Core/build.gradle.kts +++ b/Core/build.gradle.kts @@ -1,4 +1,6 @@ import co.touchlab.skie.configuration.DefaultArgumentInterop +import com.infomaniak.multiplatform_swisstranfer.gradle.PublishPlugin +import com.infomaniak.multiplatform_swisstranfer.utils.Versions import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework @@ -8,18 +10,17 @@ plugins { alias(libs.plugins.androidLibrary) alias(libs.plugins.skie) } - -val sharedMinSdk: Int by rootProject.extra -val sharedCompileSdk: Int by rootProject.extra -val javaVersion: JavaVersion by rootProject.extra -val skieMaxArgumentCount: Int by rootProject.extra +apply() kotlin { + withSourcesJar(publish = false) androidTarget { + withSourcesJar(publish = true) @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { - jvmTarget.set(JvmTarget.fromTarget(javaVersion.toString())) + jvmTarget.set(JvmTarget.fromTarget(Versions.javaVersion.toString())) } + publishLibraryVariants("release") } val xcframeworkName = "Core" @@ -55,7 +56,7 @@ skie { features { group { DefaultArgumentInterop.Enabled(true) - DefaultArgumentInterop.MaximumDefaultArgumentCount(skieMaxArgumentCount) + DefaultArgumentInterop.MaximumDefaultArgumentCount(Versions.skieMaxArgumentCount) } } build { @@ -65,12 +66,12 @@ skie { android { namespace = "com.infomaniak.multiplatform_swisstransfer" - compileSdk = sharedCompileSdk + compileSdk = Versions.compileSdk defaultConfig { - minSdk = sharedMinSdk + minSdk = Versions.minSdk } compileOptions { - sourceCompatibility = javaVersion - targetCompatibility = javaVersion + sourceCompatibility = Versions.javaVersion + targetCompatibility = Versions.javaVersion } } diff --git a/DB/build.gradle.kts b/DB/build.gradle.kts index f21161c3..0f395143 100644 --- a/DB/build.gradle.kts +++ b/DB/build.gradle.kts @@ -1,4 +1,7 @@ import co.touchlab.skie.configuration.DefaultArgumentInterop +import com.infomaniak.multiplatform_swisstranfer.gradle.PublishExtension.Companion.publishConfig +import com.infomaniak.multiplatform_swisstranfer.gradle.PublishPlugin +import com.infomaniak.multiplatform_swisstranfer.utils.Versions import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework @@ -9,18 +12,19 @@ plugins { alias(libs.plugins.realm) alias(libs.plugins.skie) } +apply() -val sharedMinSdk: Int by rootProject.extra -val sharedCompileSdk: Int by rootProject.extra -val javaVersion: JavaVersion by rootProject.extra -val skieMaxArgumentCount: Int by rootProject.extra +publishConfig { + mavenName = "database" +} kotlin { androidTarget { @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { - jvmTarget.set(JvmTarget.fromTarget(javaVersion.toString())) + jvmTarget.set(JvmTarget.fromTarget(Versions.javaVersion.toString())) } + publishLibraryVariants("release") } val xcframeworkName = "DB" @@ -55,7 +59,7 @@ skie { features { group { DefaultArgumentInterop.Enabled(true) - DefaultArgumentInterop.MaximumDefaultArgumentCount(skieMaxArgumentCount) + DefaultArgumentInterop.MaximumDefaultArgumentCount(Versions.skieMaxArgumentCount) } } build { @@ -65,12 +69,12 @@ skie { android { namespace = "com.infomaniak.multiplatform_swisstransfer.db" - compileSdk = sharedCompileSdk + compileSdk = Versions.compileSdk defaultConfig { - minSdk = sharedMinSdk + minSdk = Versions.minSdk } compileOptions { - sourceCompatibility = javaVersion - targetCompatibility = javaVersion + sourceCompatibility = Versions.javaVersion + targetCompatibility = Versions.javaVersion } } diff --git a/Network/build.gradle.kts b/Network/build.gradle.kts index cfcec717..658ff2a8 100644 --- a/Network/build.gradle.kts +++ b/Network/build.gradle.kts @@ -1,4 +1,6 @@ import co.touchlab.skie.configuration.DefaultArgumentInterop +import com.infomaniak.multiplatform_swisstranfer.gradle.PublishPlugin +import com.infomaniak.multiplatform_swisstranfer.utils.Versions import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework @@ -9,18 +11,15 @@ plugins { kotlin("plugin.serialization") version libs.versions.kotlin alias(libs.plugins.skie) } - -val sharedMinSdk: Int by rootProject.extra -val sharedCompileSdk: Int by rootProject.extra -val javaVersion: JavaVersion by rootProject.extra -val skieMaxArgumentCount: Int by rootProject.extra +apply() kotlin { androidTarget { @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { - jvmTarget.set(JvmTarget.fromTarget(javaVersion.toString())) + jvmTarget.set(JvmTarget.fromTarget(Versions.javaVersion.toString())) } + publishLibraryVariants("release") } val xcframeworkName = "Network" @@ -65,7 +64,7 @@ skie { features { group { DefaultArgumentInterop.Enabled(true) - DefaultArgumentInterop.MaximumDefaultArgumentCount(skieMaxArgumentCount) + DefaultArgumentInterop.MaximumDefaultArgumentCount(Versions.skieMaxArgumentCount) } } build { @@ -75,12 +74,12 @@ skie { android { namespace = "com.infomaniak.multiplatform_swisstransfer.network" - compileSdk = sharedCompileSdk + compileSdk = Versions.compileSdk defaultConfig { - minSdk = sharedMinSdk + minSdk = Versions.minSdk } compileOptions { - sourceCompatibility = javaVersion - targetCompatibility = javaVersion + sourceCompatibility = Versions.javaVersion + targetCompatibility = Versions.javaVersion } } diff --git a/Package.swift b/Package.swift new file mode 100644 index 00000000..15f9dc4f --- /dev/null +++ b/Package.swift @@ -0,0 +1,29 @@ +// swift-tools-version:5.10 +import PackageDescription + +let package = Package( + name: "SwissTransfer-Multiplatform", + platforms: [ + .iOS(.v14), + .macOS(.v11) + ], + products: [ + .library(name: "Core", targets: ["Shared"]), + .library(name: "DB", targets: ["DB"]), + .library(name: "Network", targets: ["Network"]) + ], + targets: [ + .binaryTarget( + name: "Core", + path: "Core.xcframework.zip" + ), + .binaryTarget( + name: "DB", + path: "DB.xcframework.zip" + ), + .binaryTarget( + name: "Network", + path: "Network.xcframework.zip" + ), + ] +) diff --git a/build.gradle.kts b/build.gradle.kts index df430257..520f27d5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,12 +1,3 @@ -buildscript { - extra.apply { - set("sharedMinSdk", 24) - set("sharedCompileSdk", 34) - set("javaVersion", JavaVersion.VERSION_17) - set("skieMaxArgumentCount", 7) - } -} - plugins { alias(libs.plugins.androidLibrary).apply(false) alias(libs.plugins.kotlinMultiplatform).apply(false) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 00000000..da3d5d3b --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,25 @@ +/* + * Infomaniak SwissTransfer - Multiplatform + * Copyright (C) 2024 Infomaniak Network SA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +plugins { + `kotlin-dsl` +} + +repositories { + mavenCentral() +} diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts new file mode 100644 index 00000000..1cada402 --- /dev/null +++ b/buildSrc/settings.gradle.kts @@ -0,0 +1,25 @@ +/* + * Infomaniak SwissTransfer - Multiplatform + * Copyright (C) 2024 Infomaniak Network SA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } +} diff --git a/buildSrc/src/main/kotlin/com/infomaniak/multiplatform_swisstranfer/gradle/PublishExtension.kt b/buildSrc/src/main/kotlin/com/infomaniak/multiplatform_swisstranfer/gradle/PublishExtension.kt new file mode 100644 index 00000000..82fa6031 --- /dev/null +++ b/buildSrc/src/main/kotlin/com/infomaniak/multiplatform_swisstranfer/gradle/PublishExtension.kt @@ -0,0 +1,30 @@ +/* + * Infomaniak SwissTransfer - Multiplatform + * Copyright (C) 2024 Infomaniak Network SA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.infomaniak.multiplatform_swisstranfer.gradle + +import org.gradle.api.Action + +open class PublishExtension { + var mavenName: String? = null + + companion object { + fun org.gradle.api.Project.`publishConfig`(configure: Action): Unit = + (this as org.gradle.api.plugins.ExtensionAware).extensions.configure("publishConfig", configure) + } +} diff --git a/buildSrc/src/main/kotlin/com/infomaniak/multiplatform_swisstranfer/gradle/PublishPlugin.kt b/buildSrc/src/main/kotlin/com/infomaniak/multiplatform_swisstranfer/gradle/PublishPlugin.kt new file mode 100644 index 00000000..0386aa12 --- /dev/null +++ b/buildSrc/src/main/kotlin/com/infomaniak/multiplatform_swisstranfer/gradle/PublishPlugin.kt @@ -0,0 +1,54 @@ +/* + * Infomaniak SwissTransfer - Multiplatform + * Copyright (C) 2024 Infomaniak Network SA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.infomaniak.multiplatform_swisstranfer.gradle + +import com.infomaniak.multiplatform_swisstranfer.utils.Versions +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.publish.maven.MavenPublication +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.create + +class PublishPlugin : Plugin { + + override fun apply(target: Project) { + target.plugins.apply("maven-publish") + + // Create the PublishExtension and add it to the project + val extension = target.extensions.create("publishConfig") + + target.group = "com.github.infomaniak.multiplatform_swisstransfer" + target.version = Versions.mavenVersionName + + target.afterEvaluate { + val mavenName = extension.mavenName ?: target.name.lowercase() + + target.extensions.configure { + publications { + create("android") { + from(components.findByName("release")) + groupId = "com.github.infomaniak.multiplatform_swisstransfer" + artifactId = mavenName + version = Versions.mavenVersionName + } + } + } + } + } +} diff --git a/buildSrc/src/main/kotlin/com/infomaniak/multiplatform_swisstranfer/utils/Versions.kt b/buildSrc/src/main/kotlin/com/infomaniak/multiplatform_swisstranfer/utils/Versions.kt new file mode 100644 index 00000000..5e96ddb6 --- /dev/null +++ b/buildSrc/src/main/kotlin/com/infomaniak/multiplatform_swisstranfer/utils/Versions.kt @@ -0,0 +1,31 @@ +/* + * Infomaniak SwissTransfer - Multiplatform + * Copyright (C) 2024 Infomaniak Network SA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.infomaniak.multiplatform_swisstranfer.utils + +import org.gradle.api.JavaVersion + +object Versions { + const val mavenVersionName = "0.0.1-snapshot" + + const val minSdk = 24 + const val compileSdk = 34 + const val skieMaxArgumentCount = 7 + + val javaVersion = JavaVersion.VERSION_17 +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9798a45b..9c20e480 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,8 @@ [versions] -agp = "8.4.1" +agp = "8.4.2" coroutines = "1.8.1" kotlin = "2.0.0" +kotlinxDatetime = "0.6.0" kotlinxSerializationJson = "1.7.0" ktor = "2.3.11" realm = "2.0.0" @@ -10,9 +11,13 @@ skie = "0.8.2" [libraries] kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" } kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" } +kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinxDatetime" } kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" } +ktor-client-content-negociation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" } ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" } ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" } +ktor-client-encoding = { module = "io.ktor:ktor-client-encoding", version.ref = "ktor" } +ktor-client-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" } ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" } realm-base = { module = "io.realm.kotlin:library-base", version.ref = "realm" } #Test