Repository navigation
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
127 lines (102 loc) · 3.5 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
127 lines (102 loc) · 3.5 KB
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
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import com.vanniktech.maven.publish.SonatypeHost
import com.vanniktech.maven.publish.KotlinJvm
import com.vanniktech.maven.publish.JavadocJar
plugins {
// Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin.
kotlin("jvm") version "2.3.20"
id("org.jetbrains.dokka") version "2.2.0"
// Apply the java-library plugin for API and implementation separation.
`java-library`
// maven publishing
id("com.vanniktech.maven.publish") version "0.29.0"
}
// from: https://discuss.kotlinlang.org/t/use-git-hash-as-version-number-in-build-gradle-kts/19818/8
fun String.runCommand(
workingDir: File = File("."),
timeoutAmount: Long = 60,
timeoutUnit: TimeUnit = TimeUnit.SECONDS
): String = ProcessBuilder(split("\\s(?=(?:[^'\"`]*(['\"`])[^'\"`]*\\1)*[^'\"`]*$)".toRegex()))
.directory(workingDir)
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.PIPE)
.start()
.apply { waitFor(timeoutAmount, timeoutUnit) }
.run {
val error = errorStream.bufferedReader().readText().trim()
if (error.isNotEmpty()) {
return@run ""
}
inputStream.bufferedReader().readText().trim()
}
val branch = "git rev-parse --abbrev-ref HEAD".runCommand(workingDir = rootDir)
val tag = "git tag -l --points-at HEAD".runCommand(workingDir = rootDir)
val commitId = "git rev-parse HEAD".runCommand(workingDir = rootDir)
val finalVersion = System.getenv("version") ?: tag.drop(1) ?: "2.0.0"
val finalGroup = System.getenv("group") ?: "net.tcgdex"
val artifact = System.getenv("artifact") ?: "sdk"
group = finalGroup
version = finalVersion
repositories {
mavenCentral()
}
dependencies {
// Use the Kotlin JDK 8 standard library.
implementation(kotlin("stdlib-jdk8"))
// Gson
implementation("com.google.code.gson:gson:2.13.2")
testImplementation(kotlin("test"))
}
tasks.test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
}
}
java {
targetCompatibility = JavaVersion.VERSION_1_8
}
mavenPublishing {
configure(KotlinJvm(
javadocJar = JavadocJar.Dokka("dokkaJavadoc"),
sourcesJar = true,
))
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
signAllPublications()
coordinates(finalGroup, artifact, finalVersion)
pom {
name.set("TCGdex SDK")
description.set("Communicate with the Open Source TCGdex API in Kotlin/Java using the SDK")
url.set("https://github.com/tcgdex/java-sdk")
inceptionYear.set("2022")
licenses {
license {
name.set("MIT License")
url.set("https://github.com/tcgdex/java-sdk/blob/master/LICENSE.md")
distribution.set("repo")
}
}
developers {
developer {
id.set("avior")
name.set("Avior")
email.set("contact@dze.io")
url.set("https://github.com/Aviortheking")
}
}
scm {
url.set("https://github.com/tcgdex/java-sdk")
connection.set("scm:git:git://github.com/tcgdex/java-sdk.git")
developerConnection.set("scm:git:ssh://git@github.com/tcgdex/java-sdk.git")
}
issueManagement {
system.set("GitHub Issues")
url.set("https://github.com/tcgdex/java-sdk/issues")
}
}
}