1
1
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2
+ import org.jreleaser.model.Active
2
3
import java.io.ByteArrayOutputStream
3
4
import java.nio.file.Files
4
5
import java.nio.file.Paths
5
6
import kotlin.io.path.isRegularFile
6
7
import kotlin.jvm.optionals.getOrNull
7
8
8
- // Note Kotlin version needs to be updated in both the buildscript and plugins.
9
- // Dependencies will follow the buildscript
10
-
9
+ // This is used to get the version from the git tag
10
+ // The version is expected to be in the format X.Y.Z
11
+ // JReleaser will use this version to create the release
11
12
fun getVersionName (): String {
12
13
val stdout = ByteArrayOutputStream ()
13
14
exec {
14
15
commandLine = listOf (" git" , " describe" , " --tags" , " --abbrev=0" )
15
16
standardOutput = stdout
16
17
}
17
- return stdout.toString().trim()
18
+ val versionStr = stdout.toString().trim().removePrefix(" v" ).removePrefix(" V" )
19
+ val parts = versionStr.split(' .' )
20
+ val normalizedStr = when (parts.size) {
21
+ 0 -> throw IllegalArgumentException (" Version string is empty" )
22
+ 1 -> " ${parts[0 ]} .0.0"
23
+ 2 -> " ${parts[0 ]} .${parts[1 ]} .0"
24
+ else -> versionStr
25
+ }
26
+ return normalizedStr
18
27
}
19
28
20
29
group = " org.biokotlin"
@@ -25,20 +34,8 @@ This build script is need to use the early access
25
34
*/
26
35
buildscript {
27
36
val kotlinVersion by extra(" 1.9.24" )
28
-
29
- repositories {
30
- mavenCentral()
31
- gradlePluginPortal()
32
- }
33
-
34
- dependencies {
35
- classpath(" org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion " )
36
- classpath(kotlin(" serialization" , version = kotlinVersion))
37
- classpath(" org.jetbrains.dokka:dokka-gradle-plugin:1.9.20" )
38
- }
39
37
}
40
38
41
-
42
39
plugins {
43
40
val kotlinVersion = " 1.9.24"
44
41
java
@@ -56,22 +53,17 @@ plugins {
56
53
`java- library`
57
54
`maven- publish`
58
55
signing
59
- id(" io.github.gradle-nexus.publish-plugin" ) version " 1.3.0"
60
- }
61
- apply {
62
- plugin(" kotlinx-serialization" )
63
- plugin(" org.jetbrains.dokka" )
56
+ id(" org.jreleaser" ) version " 1.18.0"
64
57
}
65
58
66
-
67
59
repositories {
68
60
mavenCentral()
69
61
gradlePluginPortal()
70
62
maven(" https://maven.imagej.net/content/groups/public/" )
71
63
maven(" https://jitpack.io" )
72
- maven(" https://dl.bintray.com /kotlin/kotlin- eap" )
73
- maven(" https://kotlin.bintray.com /kotlinx" )
74
- maven( " https://oss.sonatype.org/content/repositories/snapshots/ " )
64
+ maven(" https://maven.pkg.jetbrains.space /kotlin/p/ kotlin/ eap" )
65
+ maven(" https://maven.pkg.jetbrains.space/kotlin/p /kotlinx" )
66
+
75
67
}
76
68
77
69
dependencies {
@@ -121,13 +113,14 @@ dependencies {
121
113
testImplementation(" io.kotest:kotest-$it -jvm:$kotestVersion " )
122
114
}
123
115
124
- // consider adding Kotlintest
125
116
}
126
- // This is used for code generation for DataFrame Schema, however, it does not work
127
- // https://github.com/Kotlin/dataframe/tree/eb9ec4fb90f906f6a98e69b9c5a0369009d34bbb/plugins/gradle/codegen
128
- // kotlin.sourceSets.getByName("main").kotlin.srcDir("build/generated/ksp/main/kotlin/")
117
+
118
+ // This is used for code generation for DataFrame Schema, however, it does not work
119
+ // https://github.com/Kotlin/dataframe/tree/eb9ec4fb90f906f6a98e69b9c5a0369009d34bbb/plugins/gradle/codegen
120
+ // kotlin.sourceSets.getByName("main").kotlin.srcDir("build/generated/ksp/main/kotlin/")
129
121
130
122
java {
123
+ // withJavadocJar()
131
124
withSourcesJar()
132
125
}
133
126
@@ -408,6 +401,7 @@ publishing {
408
401
409
402
pom {
410
403
name.set(" BioKotlin" )
404
+ artifactId = " biokotlin"
411
405
description.set(" BioKotlin aims to be a high-performance bioinformatics library that brings the power and speed of compiled programming languages to scripting and big data environments." )
412
406
url.set(" http://www.biokotlin.org/" )
413
407
licenses {
@@ -467,27 +461,51 @@ publishing {
467
461
}
468
462
}
469
463
}
464
+
465
+ repositories {
466
+ maven {
467
+ url = layout.buildDirectory.dir(" staging-deploy" ).get().asFile.toURI()
468
+ }
469
+ }
470
470
}
471
471
472
472
signing {
473
473
useInMemoryPgpKeys(System .getenv(" GPG_SIGNING_KEY" ), System .getenv(" GPG_SIGNING_PASSWORD" ))
474
474
sign(publishing.publications[" maven" ])
475
475
}
476
476
477
- tasks.javadoc {
478
- dependsOn(" dokkaJavadoc" )
479
- if (JavaVersion .current().isJava9Compatible) {
480
- (options as StandardJavadocDocletOptions ).addBooleanOption(" html5" , true )
477
+ jreleaser {
478
+ signing {
479
+ active.set(Active .ALWAYS )
480
+ armored.set(true )
481
+ setMode(" MEMORY" )
481
482
}
482
- }
483
-
484
- nexusPublishing {
485
- repositories {
486
- sonatype()
483
+ deploy {
484
+ active.set(Active .ALWAYS )
485
+ release {
486
+ github {
487
+ skipRelease = true
488
+ skipTag = true
489
+ }
490
+ }
491
+ maven {
492
+ active.set(Active .ALWAYS )
493
+ mavenCentral {
494
+ signing {
495
+ active.set(Active .ALWAYS )
496
+ armored.set(true )
497
+ setMode(" MEMORY" )
498
+ }
499
+ create(" sonatype" ) {
500
+ active.set(Active .ALWAYS )
501
+ url.set(" https://central.sonatype.com/api/v1/publisher" )
502
+ stagingRepository(" build/staging-deploy" )
503
+ }
504
+ }
505
+ }
487
506
}
488
507
}
489
508
490
- tasks.publish {
491
- dependsOn(dokkaJar)
492
- mustRunAfter(dokkaJar)
493
- }
509
+ tasks.named(" publish" ) {
510
+ dependsOn(" dokkaJar" , " sourcesJar" )
511
+ }
0 commit comments