1- plugins {
2- kotlin(" multiplatform" ) version " 1.5.0"
3-
4- id(" org.jlleitschuh.gradle.ktlint" ) version " 10.0.0"
5- id(" com.adarshr.test-logger" ) version " 3.0.0"
6- id(" net.rdrei.android.buildtimetracker" ) version " 0.11.0"
1+ import blue.starry.scriptextender.EnvReference
72
3+ plugins {
4+ kotlin(" multiplatform" ) version " 1.6.10"
85 `maven- publish`
96 signing
107 id(" io.codearte.nexus-staging" ) version " 0.30.0"
11-
12- id(" org.jetbrains.dokka" ) version " 1.4.32"
13- }
14-
15- object Versions {
16- const val KotlinxSerializationJson = " 1.2.1"
17-
18- const val JUnit = " 5.7.1"
19- const val KotlinLogging = " 2.0.6"
20- const val Logback = " 1.2.3"
21- const val Jansi = " 2.3.2"
22- }
23-
24- object Libraries {
25- const val KotlinxSerializationJson = " org.jetbrains.kotlinx:kotlinx-serialization-json:${Versions .KotlinxSerializationJson } "
26- const val KotlinLogging = " io.github.microutils:kotlin-logging:${Versions .KotlinLogging } "
27-
28- const val JUnitJupiter = " org.junit.jupiter:junit-jupiter:${Versions .JUnit } "
29- const val LogbackCore = " ch.qos.logback:logback-core:${Versions .Logback } "
30- const val LogbackClassic = " ch.qos.logback:logback-classic:${Versions .Logback } "
31- const val Jansi = " org.fusesource.jansi:jansi:${Versions .Jansi } "
32-
33- val ExperimentalAnnotations = setOf (
34- " kotlin.Experimental" ,
35- " kotlin.contracts.ExperimentalContracts"
36- )
8+ id(" org.jetbrains.dokka" ) version " 1.6.10"
9+ id(" blue.starry.scriptextender" ) version " 0.0.2"
3710}
3811
3912object Publications {
@@ -58,18 +31,18 @@ object Publications {
5831}
5932
6033object Env {
61- const val Version = " VERSION"
34+ val Version = EnvReference ( " VERSION" )
6235
63- const val OSSRHProfileId = " OSSRH_PROFILE_ID"
64- const val OSSRHUsername = " OSSRH_USERNAME"
65- const val OSSRHPassword = " OSSRH_PASSWORD"
36+ val OSSRHProfileId = EnvReference ( " OSSRH_PROFILE_ID" )
37+ val OSSRHUsername = EnvReference ( " OSSRH_USERNAME" )
38+ val OSSRHPassword = EnvReference ( " OSSRH_PASSWORD" )
6639
67- const val GitHubUsername = " GITHUB_USERNAME"
68- const val GitHubPassword = " GITHUB_PASSWORD"
40+ val GitHubUsername = EnvReference ( " GITHUB_USERNAME" )
41+ val GitHubPassword = EnvReference ( " GITHUB_PASSWORD" )
6942
70- const val SigningKeyId = " SIGNING_KEYID"
71- const val SigningKey = " SIGNING_KEY"
72- const val SigningPassword = " SIGNING_PASSWORD"
43+ val SigningKeyId = EnvReference ( " SIGNING_KEYID" )
44+ val SigningKey = EnvReference ( " SIGNING_KEY" )
45+ val SigningPassword = EnvReference ( " SIGNING_PASSWORD" )
7346}
7447
7548/*
@@ -104,8 +77,8 @@ kotlin {
10477 dependencies {
10578 implementation(kotlin(" reflect" ))
10679
107- api(Libraries . KotlinxSerializationJson )
108- api(Libraries . KotlinLogging )
80+ api(" org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2 " )
81+ api(" io.github.microutils:kotlin-logging:2.1.21 " )
10982 }
11083 }
11184 commonTest {
@@ -121,12 +94,7 @@ kotlin {
12194 dependencies {
12295 implementation(kotlin(" test" ))
12396
124- implementation(kotlin(" test-junit5" ))
125- implementation(Libraries .JUnitJupiter )
126-
127- implementation(Libraries .LogbackCore )
128- implementation(Libraries .LogbackClassic )
129- implementation(Libraries .Jansi )
97+ implementation(" ch.qos.logback:logback-classic:1.3.0-alpha12" )
13098 }
13199 }
132100
@@ -142,59 +110,24 @@ kotlin {
142110 targets.all {
143111 compilations.all {
144112 kotlinOptions {
145- apiVersion = " 1.5 "
146- languageVersion = " 1.5 "
113+ apiVersion = " 1.6 "
114+ languageVersion = " 1.6 "
147115 allWarningsAsErrors = true
148116 verbose = true
149117 }
150118 }
151119 }
152120
153121 sourceSets.all {
154- languageSettings.progressiveMode = true
155-
156- Libraries .ExperimentalAnnotations .forEach {
157- languageSettings.useExperimentalAnnotation(it)
158- }
159- }
160- }
161-
162- /*
163- * Tests
164- */
165-
166- ktlint {
167- verbose.set(true )
168- outputToConsole.set(true )
169- reporters {
170- reporter(org.jlleitschuh.gradle.ktlint.reporter.ReporterType .CHECKSTYLE )
171- }
172- ignoreFailures.set(true )
173- }
122+ languageSettings {
123+ progressiveMode = true
174124
175- buildtimetracker {
176- reporters {
177- register(" summary" ) {
178- options[" ordered" ] = " true"
179- options[" barstyle" ] = " ascii"
180- options[" shortenTaskNames" ] = " false"
125+ optIn(" kotlin.Experimental" )
126+ optIn(" kotlin.contracts.ExperimentalContracts" )
181127 }
182128 }
183129}
184130
185- tasks.withType<Test > {
186- useJUnitPlatform()
187-
188- testLogging {
189- showStandardStreams = true
190- events(" passed" , " failed" )
191- }
192-
193- testlogger {
194- theme = com.adarshr.gradle.testlogger.theme.ThemeType .MOCHA_PARALLEL
195- }
196- }
197-
198131/*
199132 * Publishing
200133 */
@@ -212,16 +145,16 @@ publishing {
212145 maven {
213146 name = " Sonatype"
214147 url = uri(
215- if (System .getenv( Env .Version ) .orEmpty().endsWith(" -SNAPSHOT" )) {
148+ if (Env .Version .valueOrNull .orEmpty().endsWith(" -SNAPSHOT" )) {
216149 Publications .MavenCentralSnapshotRepositoryUrl
217150 } else {
218151 Publications .MavenCentralStagingRepositoryUrl
219152 }
220153 )
221154
222155 credentials {
223- username = System .getenv( Env .OSSRHUsername )
224- password = System .getenv( Env .OSSRHPassword )
156+ username = Env .OSSRHUsername .valueOrNull
157+ password = Env .OSSRHPassword .valueOrNull
225158 }
226159 }
227160
@@ -230,8 +163,8 @@ publishing {
230163 url = uri(Publications .GitHubPackagesRepositoryUrl )
231164
232165 credentials {
233- username = System .getenv( Env .GitHubUsername )
234- password = System .getenv( Env .GitHubPassword )
166+ username = Env .GitHubUsername .valueOrNull
167+ password = Env .GitHubPassword .valueOrNull
235168 }
236169 }
237170 }
@@ -246,7 +179,7 @@ publishing {
246179 " ${rootProject.name} -$name "
247180 }
248181 }
249- version = System .getenv( Env .Version )
182+ version = Env .Version .valueOrNull
250183
251184 pom {
252185 name.set(artifactId)
@@ -283,19 +216,19 @@ signing {
283216 setRequired { gradle.taskGraph.hasTask(" publish" ) }
284217 sign(publishing.publications)
285218
286- if (System .getenv( Env .SigningKey ) != null ) {
219+ if (Env .SigningKey .isPresent ) {
287220 @Suppress(" UnstableApiUsage" )
288221 useInMemoryPgpKeys(
289- System .getenv( Env .SigningKeyId ) ,
290- System .getenv( Env .SigningKey ) ,
291- System .getenv( Env .SigningPassword )
222+ Env .SigningKeyId .value ,
223+ Env .SigningKey .value ,
224+ Env .SigningPassword .value
292225 )
293226 }
294227}
295228
296229nexusStaging {
297230 packageGroup = Publications .OSSRHProfileGroupId
298- stagingProfileId = System .getenv( Env .OSSRHProfileId )
299- username = System .getenv( Env .OSSRHUsername )
300- password = System .getenv( Env .OSSRHPassword )
231+ stagingProfileId = Env .OSSRHProfileId .valueOrNull
232+ username = Env .OSSRHUsername .valueOrNull
233+ password = Env .OSSRHPassword .valueOrNull
301234}
0 commit comments