-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle.kts
140 lines (121 loc) · 4.47 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
135
136
137
138
139
140
import org.gradle.accessors.dm.LibrariesForLibs
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.util.*
// 不要修改或内联此属性,否则 subporjcts 处将无法正常使用。
val lib: LibrariesForLibs = libs
plugins {
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.dokka) apply false
alias(libs.plugins.noarg) apply false
alias(libs.plugins.allopen) apply false
alias(libs.plugins.gradle.plugin.publish) apply false
alias(libs.plugins.com.mybatis.flex.kotlin) apply false
`maven-publish`
`kotlin-dsl`
signing
}
// 在 subprojets 处,不要使用属性 libs ,而是改为在此文件中定义的属性 lib。
subprojects {
apply(plugin = lib.plugins.kotlin.jvm.get().pluginId)
apply(plugin = lib.plugins.dokka.get().pluginId)
apply(plugin = "maven-publish")
apply(plugin = "signing")
apply(plugin = "org.gradle.kotlin.kotlin-dsl")
group = providers.gradleProperty("group").get()
dependencies {
implementation(kotlin("reflect"))
testCompileOnly(lib.junit.jupiter.api)
testRuntimeOnly(lib.junit.jupiter.engine)
implementation(lib.dokka)
}
tasks.getByName<Test>("test") {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
compilerOptions {
freeCompilerArgs.addAll(
"-Xsam-conversions=indy",
)
}
}
// Stub secrets to let the project sync and build without the publication values set up
ext["signing.keyId"] = null
ext["signing.password"] = null
ext["signing.secretKeyRingFile"] = null
ext["ossrhUsername"] = null
ext["ossrhPassword"] = null
// Grabbing secrets from local.properties file or from environment variables, which could be used on CI
val secretPropsFile: File = project.rootProject.file("local.properties")
if (secretPropsFile.exists()) {
secretPropsFile.reader().use {
Properties().apply {
load(it)
}
}.forEach { (name, value) ->
ext[name.toString()] = value
}
} else {
ext["signing.keyId"] = System.getenv("SIGNING_KEY_ID")
ext["signing.password"] = System.getenv("SIGNING_PASSWORD")
ext["signing.secretKeyRingFile"] = System.getenv("SIGNING_SECRET_KEY_RING_FILE")
ext["ossrhUsername"] = System.getenv("OSSRH_USERNAME")
ext["ossrhPassword"] = System.getenv("OSSRH_PASSWORD")
}
val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
}
val sourceJar by tasks.registering(Jar::class) {
from(sourceSets["main"].allSource)
archiveClassifier.set("sources")
}
fun getExtraString(name: String) = ext[name]?.toString()
publishing {
// Configure maven central repository
repositories {
maven {
name = "sonatype"
setUrl("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = getExtraString("ossrhUsername")
password = getExtraString("ossrhPassword")
}
}
}
// Configure all publications
publications.withType<MavenPublication> {
// Stub javadoc.jar artifact
artifact(javadocJar)
artifact(sourceJar)
// Provide artifacts information requited by Maven Central
pom {
url.set("https://github.com/KAMO030/MyBatis-Flex-Kotlin")
licenses {
license {
name.set("Apache License 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0")
}
}
developers {
developer {
id.set("KAMO030")
name.set("KAMOsama")
email.set("[email protected]")
}
developer {
id.set("CloudPlayer")
name.set("CloudPlayer")
email.set("[email protected]")
}
}
scm {
url.set("https://github.com/KAMO030/MyBatis-Flex-Kotlin.git")
}
}
}
}
// Signing artifacts. Signing.* extra properties values will be used
signing {
sign(publishing.publications)
}
}