-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
134 lines (130 loc) · 4.69 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import com.android.build.gradle.LibraryExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget
import java.util.Properties
plugins {
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.libAndroid) apply false
}
val normalSettings = allprojects {
group = "me.heizi.kotlinx"
version = rootProject.libs.versions.khell.get()
repositories {
mavenCentral {
url = uri("https://maven-central.storage-download.googleapis.com/maven2/")
}
google()
}
}
val settings = subprojects { afterEvaluate {
if (isMultiplatform)
if(configKotlinMultiplatform())
androidDefaultConfig()
} }
fun Project.configKotlinMultiplatform():Boolean {
apply(plugin = "org.jetbrains.kotlin.multiplatform")
var isAndroid = false
configure<KotlinMultiplatformExtension> {
jvmToolchain(17)
targets.all {
compilations.all {
kotlinOptions {
freeCompilerArgs += "-Xcontext-receivers"
}
}
if (this is KotlinAndroidTarget) {
println("is Android project!")
isAndroid = true
compilations.all {
kotlinOptions.jvmTarget = "11"
}
sourceSets.findByName("androidInstrumentedTest")?.dependencies {
implementation(libs.androidx.runner)
implementation(libs.androidx.test.junit)
implementation(kotlin("test"))
}
publishLibraryVariants("release")
}
}
}
return isAndroid
}
fun Project.androidDefaultConfig() {
apply(plugin = "com.android.library")
configure<LibraryExtension> {
compileSdk = 33
@Suppress("DEPRECATION")
defaultConfig {
targetSdk = 33
minSdk = 21
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
buildToolsVersion = "33.0.2"
// disable lint class version check
lint {
abortOnError = false
baseline = file("lint-baseline.xml")
}
if (!name.endsWith("-log"))
namespace = "me.heizi.kotlinx.${name.replace("-",".")}"
}
}
val publishing = subprojects {
apply(plugin = "maven-publish")
configure<PublishingExtension> {
publications {
repositories {
maven {
name = "test"
url = uri("file://${rootProject.projectDir}/build/maven-repo/")
}
localRepo?.let {
maven {
url = uri(it)
}
}
if(!System.getenv("GITHUB_ACTOR").isNullOrEmpty() && !System.getenv("GITHUB_TOKEN").isNullOrEmpty()) maven {
name = "github"
url = uri("https://maven.pkg.github.com/ElisaMin/Khell")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
val pom = { it: MavenPublication ->
with(it) {
pom {
name = "Khell"
description = "packaging the JVM 's Process class to Kotlin Style to supports coroutines"
url = "https://github.com/ElisaMin/Khell"
developers {
developer {
id = "ElisaMin"
name = "ElisaMin"
email = "[email protected]"
}
}
scm {
connection = "scm:git:git://github.com/ElisaMin/Khell.git"
developerConnection = "scm:git:ssh://github.com/ElisaMin/Khell.git"
url = "https://github.com/ElisaMin/Khell"
}
}
}
}
filterIsInstance<MavenPublication>().forEach(pom)
}
}
}
val Project.isMultiplatform get() = pluginManager.hasPlugin("org.jetbrains.kotlin.multiplatform")
val Project.localRepo get() = file("local.properties").takeIf { it.exists() }?.inputStream()?.use {
Properties().apply {
load(it)
}["local"] as String?
}