1
1
import com.github.breadmoirai.githubreleaseplugin.GithubReleaseExtension
2
2
import net.pearx.multigradle.util.MultiGradleExtension
3
3
import net.pearx.multigradle.util.kotlinMpp
4
+ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
4
5
5
6
val projectChangelog: String by project
6
7
val projectDescription: String by project
@@ -13,13 +14,14 @@ val pearxRepoPassword: String? by project
13
14
val sonatypeOssUsername: String? by project
14
15
val sonatypeOssPassword: String? by project
15
16
val githubAccessToken: String? by project
17
+ val sonarcloudToken: String? by project
16
18
val devBuildNumber: String? by project
17
19
18
-
19
20
plugins {
20
21
id(" net.pearx.multigradle.simple.project" )
21
22
kotlin(" multiplatform" ) apply (false )
22
23
id(" com.github.breadmoirai.github-release" )
24
+ id(" org.sonarqube" )
23
25
`maven- publish`
24
26
signing
25
27
}
@@ -125,6 +127,10 @@ configure<PublishingExtension> {
125
127
}
126
128
127
129
tasks {
130
+ withType<KotlinCompile > {
131
+ kotlinOptions.freeCompilerArgs + = " -Xopt-in=kotlin.ExperimentalUnsignedTypes"
132
+ }
133
+
128
134
val publishDevelop by registering {
129
135
group = " publishing"
130
136
dependsOn(withType<PublishToMavenRepository >().matching { it.repository.name.endsWith(" -develop" ) })
@@ -147,8 +153,31 @@ configure<SigningExtension> {
147
153
configure<GithubReleaseExtension > {
148
154
setToken(githubAccessToken)
149
155
setOwner(" pearxteam" )
150
- setRepo(" kpastebin " )
156
+ setRepo(project.name )
151
157
setTargetCommitish(" master" )
152
158
setBody(projectChangelog)
153
159
// setReleaseAssets((publishing.publications["maven"] as MavenPublication).artifacts.map { it.file })
160
+ }
161
+
162
+ fun findSourceDirectories (endsWith : String ): FileCollection {
163
+ return files(kotlin.sourceSets.filter { it.name.endsWith(endsWith) }.map { it.kotlin.sourceDirectories }).filter { it.isDirectory }
164
+ }
165
+
166
+ if (sonarcloudToken != null ) {
167
+ tasks.check {
168
+ finalizedBy(" sonarqube" )
169
+ }
170
+ sonarqube {
171
+ properties {
172
+ property(" sonar.host.url" , " https://sonarcloud.io" )
173
+ property(" sonar.login" , sonarcloudToken!! )
174
+ property(" sonar.projectKey" , " pearxteam_${project.name} " )
175
+ property(" sonar.organization" , " pearxteam" )
176
+ property(" sonar.sourceEncoding" , " UTF-8" )
177
+ property(" sonar.sources" , findSourceDirectories(" Main" ).joinToString())
178
+ property(" sonar.tests" , findSourceDirectories(" Test" ).joinToString())
179
+ property(" sonar.coverage.jacoco.xmlReportPaths" , " $buildDir /reports/jacoco/jacocoJvmTestReport/jacocoJvmTestReport.xml" )
180
+ property(" sonar.junit.reportPaths" , " $buildDir /test-results/jvmTest/*.xml" )
181
+ }
182
+ }
154
183
}
0 commit comments