Some useful functions and building
This commit is contained in:
parent
a06fc002e8
commit
8d04b5d410
48
embed/build.gradle.kts
Normal file
48
embed/build.gradle.kts
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import ru.landgrafhomyak.kotlin.kmp_gradle_build_helper.defineXomrkGiteaMavenRepo
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
fun readTextFile(relPath: String) = rootDir.resolve(relPath).readText().trim()
|
||||||
|
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath("ru.landgrafhomyak.kotlin:kotlin-mpp-gradle-build-helper:v${readTextFile("../library-version.txt")}k${readTextFile("../kotlin-version.txt")}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform") version "2.0.20"
|
||||||
|
`maven-publish`
|
||||||
|
}
|
||||||
|
|
||||||
|
fun readTextFile(relPath: String) = rootDir.resolve(relPath).readText().trim()
|
||||||
|
|
||||||
|
val targetKotlinVersion = readTextFile("../kotlin-version.txt")
|
||||||
|
|
||||||
|
group = "ru.landgrafhomyak.kotlin"
|
||||||
|
version = "v${readTextFile("../library-version.txt")}k${targetKotlinVersion}"
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
jvmToolchain(8)
|
||||||
|
jvm()
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
jvmMain {
|
||||||
|
dependencies {
|
||||||
|
implementation("${group}:kotlin-mpp-gradle-build-helper:${targetKotlinVersion}")
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${targetKotlinVersion}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
repositories {
|
||||||
|
defineXomrkGiteaMavenRepo()
|
||||||
|
}
|
||||||
|
}
|
1
embed/gradle.properties
Normal file
1
embed/gradle.properties
Normal file
@ -0,0 +1 @@
|
|||||||
|
kotlin.code.style=official
|
2
embed/settings.gradle.kts
Normal file
2
embed/settings.gradle.kts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
rootProject.name = "kotlin-mpp-gradle-build"
|
||||||
|
|
50
impl/build.gradle.kts
Normal file
50
impl/build.gradle.kts
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
plugins {
|
||||||
|
kotlin("multiplatform") version "2.0.20"
|
||||||
|
`maven-publish`
|
||||||
|
}
|
||||||
|
|
||||||
|
fun readTextFile(relPath:String) = rootDir.resolve(relPath).readText().trim()
|
||||||
|
|
||||||
|
val targetKotlinVersion = readTextFile("../kotlin-version.txt")
|
||||||
|
|
||||||
|
group = "ru.landgrafhomyak.kotlin"
|
||||||
|
version = "v${readTextFile("../library-version.txt")}k${targetKotlinVersion}"
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
explicitApi()
|
||||||
|
jvmToolchain(8)
|
||||||
|
jvm()
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
jvmMain {
|
||||||
|
dependencies {
|
||||||
|
compileOnly("dev.gradleplugins:gradle-api:7.5.1")
|
||||||
|
compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin:${targetKotlinVersion}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
// other settings of publication
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "XomrkMaven"
|
||||||
|
url = uri("https://git.landgrafhomyak.ru/api/packages/xomrk/maven")
|
||||||
|
|
||||||
|
credentials(HttpHeaderCredentials::class) {
|
||||||
|
name = "Authorization"
|
||||||
|
value = "token ${System.getenv("XOMRK_MAVEN_REPO_DEPLOY_TOKEN")}"
|
||||||
|
}
|
||||||
|
|
||||||
|
authentication {
|
||||||
|
create<HttpHeaderAuthentication>("header")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1
impl/gradle.properties
Normal file
1
impl/gradle.properties
Normal file
@ -0,0 +1 @@
|
|||||||
|
kotlin.code.style=official
|
2
impl/settings.gradle.kts
Normal file
2
impl/settings.gradle.kts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
rootProject.name = "kotlin-mpp-gradle-build-helper"
|
||||||
|
|
@ -0,0 +1,27 @@
|
|||||||
|
package ru.landgrafhomyak.kotlin.kmp_gradle_build_helper
|
||||||
|
|
||||||
|
import java.net.URI
|
||||||
|
import org.gradle.api.artifacts.dsl.RepositoryHandler
|
||||||
|
import org.gradle.api.credentials.HttpHeaderCredentials
|
||||||
|
import org.gradle.authentication.http.HttpHeaderAuthentication
|
||||||
|
|
||||||
|
public fun RepositoryHandler.defineXomrkGiteaMavenRepo(
|
||||||
|
user: String = "xomrk",
|
||||||
|
token: String? = System.getenv("XOMRK_GITEA_MAVEN_REPO_DEPLOY_TOKEN")
|
||||||
|
) {
|
||||||
|
maven { b ->
|
||||||
|
b.name = "XomrkMaven"
|
||||||
|
b.url = URI("https://git.landgrafhomyak.ru/api/packages/${user}/maven")
|
||||||
|
|
||||||
|
if (token != null) {
|
||||||
|
b.credentials(HttpHeaderCredentials::class.java) { c ->
|
||||||
|
c.name = "Authorization"
|
||||||
|
c.value = "token ${token}"
|
||||||
|
}
|
||||||
|
|
||||||
|
b.authentication { a ->
|
||||||
|
a.create("header", HttpHeaderAuthentication::class.java)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package ru.landgrafhomyak.kotlin.kmp_gradle_build_helper
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||||
|
|
||||||
|
@OptIn(ExperimentalWasmDsl::class)
|
||||||
|
public fun KotlinMultiplatformExtension.defineAllTargets() {
|
||||||
|
jvm {
|
||||||
|
}
|
||||||
|
js(IR) {
|
||||||
|
browser()
|
||||||
|
nodejs()
|
||||||
|
}
|
||||||
|
wasmWasi { wasm ->
|
||||||
|
wasm.nodejs()
|
||||||
|
}
|
||||||
|
wasmJs { wasm ->
|
||||||
|
wasm.nodejs()
|
||||||
|
wasm.browser()
|
||||||
|
wasm.d8()
|
||||||
|
}
|
||||||
|
|
||||||
|
macosArm64()
|
||||||
|
macosX64()
|
||||||
|
linuxArm64()
|
||||||
|
linuxX64()
|
||||||
|
mingwX64()
|
||||||
|
androidNativeArm32()
|
||||||
|
androidNativeArm64()
|
||||||
|
androidNativeX64()
|
||||||
|
androidNativeX86()
|
||||||
|
iosArm64()
|
||||||
|
iosSimulatorArm64()
|
||||||
|
iosX64()
|
||||||
|
tvosX64()
|
||||||
|
tvosArm64()
|
||||||
|
tvosSimulatorArm64()
|
||||||
|
watchosX64()
|
||||||
|
watchosArm32()
|
||||||
|
watchosArm64()
|
||||||
|
watchosDeviceArm64()
|
||||||
|
watchosSimulatorArm64()
|
||||||
|
}
|
1
kotlin-version.txt
Normal file
1
kotlin-version.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
2.0.20
|
1
library-version.txt
Normal file
1
library-version.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
0.1
|
Loading…
Reference in New Issue
Block a user