-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle.kts
77 lines (63 loc) · 1.88 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
import java.io.ByteArrayOutputStream
plugins {
`java-library`
`maven-publish`
}
val versionObj = Version("0", "8", "1", false)
group = "com.dfsek"
version = versionObj
repositories {
mavenCentral()
maven { url = uri("https://repo.codemc.org/repository/maven-public") }
}
dependencies {
implementation("org.jetbrains:annotations:24.0.1")
api("org.ow2.asm:asm:9.5")
testImplementation("com.scireum:parsii:4.0")
testImplementation("net.objecthunter:exp4j:0.4.8")
testImplementation("junit:junit:4.13.2")
}
val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
}
}
repositories {
val mavenUrl = "https://repo.codemc.io/repository/maven-releases/"
maven(mavenUrl) {
val mavenUsername: String? by project
val mavenPassword: String? by project
if (mavenUsername != null && mavenPassword != null) {
credentials {
username = mavenUsername
password = mavenPassword
}
}
}
}
}
/**
* Version class that does version stuff.
*/
@Suppress("MemberVisibilityCanBePrivate")
class Version(val major: String, val minor: String, val revision: String, val preRelease: Boolean = false) {
override fun toString(): String {
return if (!preRelease)
"$major.$minor.$revision"
else //Only use git hash if it's a prerelease.
"$major.$minor.$revision+${getGitHash()}"
}
}
fun getGitHash(): String {
val stdout = ByteArrayOutputStream()
exec {
commandLine = mutableListOf("git", "rev-parse", "--short", "HEAD")
standardOutput = stdout
}
return stdout.toString().trim()
}