Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Init all modules dependencies and config maven publish #3

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions Common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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()))
}
}

Expand All @@ -37,6 +34,7 @@ kotlin {
sourceSets {
commonMain.dependencies {
api(libs.kotlinx.coroutines.core)
api(libs.kotlinx.datetime)
}
commonTest.dependencies {
implementation(libs.kotlin.test)
Expand All @@ -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
}
}
23 changes: 12 additions & 11 deletions Core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<PublishPlugin>()

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"
Expand Down Expand Up @@ -55,7 +56,7 @@ skie {
features {
group {
DefaultArgumentInterop.Enabled(true)
DefaultArgumentInterop.MaximumDefaultArgumentCount(skieMaxArgumentCount)
DefaultArgumentInterop.MaximumDefaultArgumentCount(Versions.skieMaxArgumentCount)
}
}
build {
Expand All @@ -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
}
}
24 changes: 14 additions & 10 deletions DB/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -9,18 +12,19 @@ plugins {
alias(libs.plugins.realm)
alias(libs.plugins.skie)
}
apply<PublishPlugin>()

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"
Expand Down Expand Up @@ -55,7 +59,7 @@ skie {
features {
group {
DefaultArgumentInterop.Enabled(true)
DefaultArgumentInterop.MaximumDefaultArgumentCount(skieMaxArgumentCount)
DefaultArgumentInterop.MaximumDefaultArgumentCount(Versions.skieMaxArgumentCount)
}
}
build {
Expand All @@ -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
}
}
21 changes: 10 additions & 11 deletions Network/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<PublishPlugin>()

kotlin {
androidTarget {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
jvmTarget.set(JvmTarget.fromTarget(javaVersion.toString()))
jvmTarget.set(JvmTarget.fromTarget(Versions.javaVersion.toString()))
}
publishLibraryVariants("release")
}

val xcframeworkName = "Network"
Expand Down Expand Up @@ -65,7 +64,7 @@ skie {
features {
group {
DefaultArgumentInterop.Enabled(true)
DefaultArgumentInterop.MaximumDefaultArgumentCount(skieMaxArgumentCount)
DefaultArgumentInterop.MaximumDefaultArgumentCount(Versions.skieMaxArgumentCount)
}
}
build {
Expand All @@ -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
}
}
29 changes: 29 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -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"
),
]
)
9 changes: 0 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
25 changes: 25 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
}
25 changes: 25 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

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<PublishExtension>): Unit =
(this as org.gradle.api.plugins.ExtensionAware).extensions.configure("publishConfig", configure)
}
}
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

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<Project> {

override fun apply(target: Project) {
target.plugins.apply("maven-publish")

// Create the PublishExtension and add it to the project
val extension = target.extensions.create<PublishExtension>("publishConfig")

target.group = "com.github.infomaniak.multiplatform_swisstransfer"
target.version = Versions.mavenVersionName

target.afterEvaluate {
val mavenName = extension.mavenName ?: target.name.lowercase()

target.extensions.configure<org.gradle.api.publish.PublishingExtension> {
publications {
create<MavenPublication>("android") {
from(components.findByName("release"))
groupId = "com.github.infomaniak.multiplatform_swisstransfer"
artifactId = mavenName
version = Versions.mavenVersionName
}
}
}
}
}
}
Loading
Loading