-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
104 lines (87 loc) · 3.56 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
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
plugins {
java
`maven-publish`
kotlin("jvm") version "1.7.22"
id("org.jetbrains.dokka") version ("1.7.20")
}
group = "de.skyslycer"
version = "1.1.1"
repositories {
mavenCentral()
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://oss.sonatype.org/content/repositories/snapshots/")
maven("https://oss.sonatype.org/content/groups/public")
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
maven("https://repo.skyslycer.de/jitpack")
maven("https://repo.bytecode.space/repository/maven-public/")
maven("https://repo.codemc.io/repository/maven-snapshots/")
}
dependencies {
compileOnly("org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT")
compileOnly("me.clip:placeholderapi:2.11.2")
compileOnly("net.kyori:adventure-api:4.12.0")
compileOnly("net.kyori:adventure-text-minimessage:4.12.0")
compileOnly("net.kyori:adventure-platform-bukkit:4.2.0")
compileOnly("com.tchristofferson:ConfigUpdater:2.0-SNAPSHOT")
compileOnly("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
compileOnly("com.github.retrooper.packetevents:spigot:2.0.0-SNAPSHOT")
compileOnly("org.spongepowered:configurate-yaml:4.1.2")
dokkaHtmlPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:1.7.20")
}
tasks {
dokkaHtml {
moduleName.set("SkyLib")
}
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
withSourcesJar()
withJavadocJar()
}
publishing {
val publishData = PublishData(project)
publications.create<MavenPublication>("maven") {
from(components["java"])
groupId = project.group as String?
artifactId = project.name
version = publishData.getVersion()
}
repositories {
maven {
authentication {
credentials(PasswordCredentials::class) {
username = System.getenv("REPO_USERNAME")
password = System.getenv("REPO_PASSWORD")
}
}
name = "Skyslycer"
url = uri(publishData.getRepository())
}
}
}
class PublishData(private val project: Project) {
var type: Type = getReleaseType()
var hashLength: Int = 7
private fun getReleaseType(): Type {
val branch = getCheckedOutBranch()
return when {
branch.contentEquals("master") || branch.contentEquals("local") -> Type.RELEASE
branch.startsWith("dev") -> Type.DEV
else -> Type.SNAPSHOT
}
}
private fun getCheckedOutGitCommitHash(): String = System.getenv("GITHUB_SHA")?.substring(0, hashLength) ?: "local"
private fun getCheckedOutBranch(): String = System.getenv("GITHUB_REF")?.replace("refs/heads/", "") ?: "local"
fun getVersion(): String = getVersion(false)
fun getVersion(appendCommit: Boolean): String =
type.append(getVersionString(), appendCommit, getCheckedOutGitCommitHash())
private fun getVersionString(): String = (project.version as String).replace("-SNAPSHOT", "").replace("-DEV", "")
fun getRepository(): String = type.repo
enum class Type(private val append: String, val repo: String, private val addCommit: Boolean) {
RELEASE("", "https://repo.skyslycer.de/releases/", false),
DEV("-DEV", "https://repo.skyslycer.de/snapshots/", true),
SNAPSHOT("-SNAPSHOT", "https://repo.skyslycer.de/snapshots/", true);
fun append(name: String, appendCommit: Boolean, commitHash: String): String =
name.plus(append).plus(if (appendCommit && addCommit) "-".plus(commitHash) else "")
}
}