generated from pearxteam/multigradle-library-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
185 lines (169 loc) · 6.04 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
import com.github.breadmoirai.githubreleaseplugin.GithubReleaseExtension
import net.pearx.multigradle.util.MultiGradleExtension
import net.pearx.multigradle.util.kotlinMpp
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
val projectChangelog: String by project
val projectDescription: String by project
val ktorVersion: String by project
val coroutinesVersion: String by project
val pearxRepoUsername: String? by project
val pearxRepoPassword: String? by project
val sonatypeOssUsername: String? by project
val sonatypeOssPassword: String? by project
val githubAccessToken: String? by project
val sonarcloudToken: String? by project
val devBuildNumber: String? by project
plugins {
id("net.pearx.multigradle.simple.project")
kotlin("multiplatform") apply (false)
id("com.github.breadmoirai.github-release")
id("org.sonarqube")
`maven-publish`
signing
}
group = "net.pearx.kpastebin"
description = projectDescription
configure<MultiGradleExtension> {
if (devBuildNumber != null) {
projectVersion = "$projectVersion-dev-$devBuildNumber"
}
}
kotlinMpp {
explicitApi()
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.ktor:ktor-client-core:$ktorVersion")
}
}
val commonTest by getting {
dependencies {
implementation("io.ktor:ktor-client-mock:$ktorVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
}
}
}
}
configure<PublishingExtension> {
publications.withType<MavenPublication> {
pom {
name.set(artifactId)
description.set(projectDescription)
url.set("https://github.com/pearxteam/kpastebin")
licenses {
license {
name.set("Mozilla Public License, Version 2.0")
url.set("https://mozilla.org/MPL/2.0/")
distribution.set("repo")
}
}
organization {
name.set("PearX Team")
url.set("https://pearx.net/")
}
developers {
developer {
id.set("mrapplexz")
name.set("mrapplexz")
email.set("[email protected]")
url.set("https://pearx.net/members/mrapplexz")
organization.set("PearX Team")
organizationUrl.set("https://pearx.net/")
roles.set(listOf("developer"))
timezone.set("Asia/Yekaterinburg")
}
}
scm {
url.set("https://github.com/pearxteam/kpastebin")
connection.set("scm:git:git://github.com/pearxteam/kpastebin")
developerConnection.set("scm:git:git://github.com/pearxteam/kpastebin")
}
issueManagement {
system.set("GitHub")
url.set("https://github.com/pearxteam/kpastebin/issues")
}
ciManagement {
system.set("GitHub")
url.set("https://github.com/pearxteam/kpastebin/actions")
}
}
}
repositories {
maven {
credentials {
username = pearxRepoUsername
password = pearxRepoPassword
}
name = "pearx-repo-develop"
url = uri("https://repo.pearx.net/maven2/develop/")
}
maven {
credentials {
username = pearxRepoUsername
password = pearxRepoPassword
}
name = "pearx-repo-release"
url = uri("https://repo.pearx.net/maven2/release/")
}
maven {
credentials {
username = sonatypeOssUsername
password = sonatypeOssPassword
}
name = "sonatype-oss-release"
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
}
}
}
tasks {
withType<KotlinCompile> {
kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.ExperimentalUnsignedTypes"
}
val publishDevelop by registering {
group = "publishing"
dependsOn(check)
dependsOn(withType<PublishToMavenRepository>().matching { it.repository.name.endsWith("-develop") })
}
val publishRelease by registering {
group = "publishing"
dependsOn(check)
dependsOn(withType<PublishToMavenRepository>().matching { it.repository.name.endsWith("-release") })
}
val release by registering {
group = "publishing"
dependsOn(publishRelease)
dependsOn(named("githubRelease"))
}
}
configure<SigningExtension> {
sign(publishing.publications)
}
configure<GithubReleaseExtension> {
setToken(githubAccessToken)
setOwner("pearxteam")
setRepo(project.name)
setTargetCommitish("master")
setBody(projectChangelog)
//setReleaseAssets((publishing.publications["maven"] as MavenPublication).artifacts.map { it.file })
}
fun findSourceDirectories(endsWith: String): FileCollection {
return files(kotlin.sourceSets.filter { it.name.endsWith(endsWith) }.map { it.kotlin.sourceDirectories }).filter { it.isDirectory }
}
if (sonarcloudToken != null) {
tasks.check {
finalizedBy("sonarqube")
}
sonarqube {
properties {
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.login", sonarcloudToken!!)
property("sonar.projectKey", "pearxteam_${project.name}")
property("sonar.organization", "pearxteam")
property("sonar.sourceEncoding", "UTF-8")
property("sonar.sources", findSourceDirectories("Main").joinToString())
property("sonar.tests", findSourceDirectories("Test").joinToString())
property("sonar.coverage.jacoco.xmlReportPaths", "$buildDir/reports/jacoco/jacocoJvmTestReport/jacocoJvmTestReport.xml")
property("sonar.junit.reportPaths", "$buildDir/test-results/jvmTest/*.xml")
}
}
}