generated from xanderstuff/mc-kotlin-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
145 lines (124 loc) · 5.02 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import org.yaml.snakeyaml.DumperOptions
import org.yaml.snakeyaml.Yaml
import java.time.OffsetDateTime
import java.time.ZoneOffset
import java.time.format.DateTimeFormatter
// import pl.allegro.tech.build.axion.release.domain.hooks.HookContext
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.yaml:snakeyaml:2.0")
}
}
plugins {
kotlin("jvm") version "1.8.21"
id("com.github.johnrengelman.shadow") version "8.0.0"
id("pl.allegro.tech.build.axion-release") version "1.14.4"
// id("org.jlleitschuh.gradle.ktlint") version "11.2.0"
}
group = "io.github.xanderstuff"
version = scmVersion.version
val mcApiVersion: String by project
val repoRef: String by project
scmVersion {
versionIncrementer("incrementMinorIfNotOnRelease", mapOf("releaseBranchPattern" to "release/.+"))
hooks {
// FIXME - workaround for Kotlin DSL issue https://github.com/allegro/axion-release-plugin/issues/500
// pre(
// "fileUpdate",
// mapOf(
// "file" to "CHANGELOG.md",
// "pattern" to KotlinClosure2<String, HookContext, String>({ v, _ ->
// "\\[Unreleased\\]([\\s\\S]+?)\\n(?:^\\[Unreleased\\]: https:\\/\\/github\\.com\\/$repoRef\\/compare\\/[^\\n]*\$([\\s\\S]*))?\\z"
// }),
// "replacement" to KotlinClosure2<String, HookContext, String>({ v, c ->
// """
// \[Unreleased\]
//
// ## \[$v\] - ${currentDateString()}$1
// \[Unreleased\]: https:\/\/github\.com\/$repoRef\/compare\/v$v...HEAD
// \[$v\]: https:\/\/github\.com\/$repoRef\/${if (c.previousVersion == v) "releases/tag/v$v" else "compare/v${c.previousVersion}...v$v"}${'$'}2
// """.trimIndent()
// })
// )
// )
pre("commit")
}
}
fun currentDateString() = OffsetDateTime.now(ZoneOffset.UTC).toLocalDate().format(DateTimeFormatter.ISO_DATE)
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
repositories {
mavenCentral()
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://oss.sonatype.org/content/repositories/snapshots")
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://mvn.lumine.io/repository/maven-public/")
maven("https://repo.codemc.org/repository/maven-public/")
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
compileOnly("io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT")
compileOnly("io.lumine:Mythic-Dist:5.3.0-SNAPSHOT")
implementation("dev.jorel:commandapi-bukkit-shade:9.0.1")
// We'll probably need stdlib
// implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.21")
// implementation("org.jetbrains.kotlin:kotlin-stdlib-common:1.8.21")
implementation("org.jetbrains.kotlin:kotlin-scripting-jsr223:1.8.21")
implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.8.21")
implementation("org.jetbrains.kotlin:kotlin-script-util:1.8.21")
implementation("org.jetbrains.kotlin:kotlin-script-runtime:1.8.21")
// for @file:@DependsOn, @file:@Repository in scripts
// implementation("org.jetbrains.kotlin:kotlin-scripting-dependencies:1.8.21")
// for @file:@DependsOn, @file:@Repository, @file:@Import in scripts
implementation("org.jetbrains.kotlin:kotlin-main-kts:1.8.21")
}
tasks {
wrapper {
gradleVersion = "8.0.1"
distributionType = Wrapper.DistributionType.ALL
}
processResources {
val placeholders = mapOf(
"version" to version,
"apiVersion" to mcApiVersion,
"kotlinVersion" to project.properties["kotlinVersion"]
)
filesMatching("plugin.yml") {
expand(placeholders)
}
// create an "offline" copy/variant of the plugin.yml with `libraries` omitted
doLast {
val resourcesDir = sourceSets.main.get().output.resourcesDir
val yamlDumpOptions =
// make it pretty for the people
DumperOptions().also {
it.defaultFlowStyle = DumperOptions.FlowStyle.BLOCK
it.isPrettyFlow = true
}
val yaml = Yaml(yamlDumpOptions)
val pluginYml: Map<String, Any> = yaml.load(file("$resourcesDir/plugin.yml").inputStream())
yaml.dump(pluginYml.filterKeys { it != "libraries" }, file("$resourcesDir/offline-plugin.yml").writer())
}
}
jar {
exclude("offline-plugin.yml")
}
// offline jar should be ready to go with all dependencies
shadowJar {
//TODO: figure out if minimize() can safely be used, even partially
// (probably need to exclude std-lib, ect. so scripts can still use those dependencies)
// minimize()
archiveClassifier.set("offline")
exclude("plugin.yml")
rename("offline-plugin.yml", "plugin.yml")
}
build {
dependsOn(shadowJar)
}
}