-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle.kts
134 lines (123 loc) · 4.05 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
plugins {
id("java")
id("io.github.goooler.shadow") version "8.1.7"
id("maven-publish")
signing // Add ./gradlew signArchives
id("xyz.jpenilla.run-paper") version "2.3.1"
id("org.sonarqube") version "5.0.0.4638"
}
group="fr.formiko.mc.voidworldgenerator"
version="1.3.2"
description="Generate empty world."
val mainMinecraftVersion = "1.21.4"
val supportedMinecraftVersions = "1.20 - 1.21.4"
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://jitpack.io")
}
dependencies {
compileOnly("io.papermc.paper:paper-api:$mainMinecraftVersion-R0.1-SNAPSHOT")
implementation("org.bstats:bstats-bukkit:3.1.0")
}
java {
// Configure the java toolchain. This allows gradle to auto-provision JDK 21 on systems that only have JDK 8 installed for example.
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
withJavadocJar()
withSourcesJar()
}
tasks {
shadowJar {
relocate("org.bstats","${project.group}.bstats")
archiveFileName.set("${project.name}-${project.version}.jar")
}
assemble {
dependsOn(shadowJar)
}
processResources {
val props = mapOf(
"name" to project.name,
"version" to project.version,
"description" to project.description,
"apiVersion" to "1.20",
"group" to project.group
)
inputs.properties(props)
filesMatching("plugin.yml") {
expand(props)
}
}
runServer {
// Configure the Minecraft version for our task.
// This is the only required configuration besides applying the plugin.
// Your plugin's jar (or shadowJar if present) will be used automatically.
minecraftVersion(mainMinecraftVersion)
}
}
afterEvaluate {
tasks.withType(PublishToMavenRepository::class.java) {
dependsOn(tasks.assemble)
}
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
artifactId = project.name.lowercase()
pom {
packaging = "jar"
url.set("https://github.com/HydrolienF/${project.name}")
inceptionYear.set("2024")
description = project.description
licenses {
license {
name.set("MIT license")
url.set("https://github.com/HydrolienF/${project.name}/blob/master/LICENSE.md")
}
}
developers {
developer {
id.set("hydrolienf")
name.set("HydrolienF")
email.set("hydrolien.f@gmail.com")
}
}
scm {
connection.set("scm:git:git@github.com:HydrolienF/${project.name}.git")
developerConnection.set("scm:git:ssh:git@github.com:HydrolienF/${project.name}.git")
url.set("https://github.com/HydrolienF/${project.name}")
}
}
}
}
repositories {
maven {
url = layout.buildDirectory.dir("staging-deploy").get().asFile.toURI()
}
}
}
// Custom signing task using gpg -ab
val signWithGpg = tasks.register("signWithGpg") {
dependsOn("publishMavenJavaPublicationToMavenRepository")
group = "signing"
description = "Sign the publication using gpg -ab"
val filesToSign = fileTree("${buildDir}/staging-deploy/${project.group.toString().lowercase().replace('.', '/')}/${project.name.lowercase()}/${project.version}") {
include("**/*.jar", "**/*.module", "**/*.pom")
}
doFirst {
filesToSign.forEach { file ->
val command = listOf("gpg", "-ab", "--output", "${file.absolutePath}.asc", file.absolutePath)
println("Executing command: ${command.joinToString(" ")}")
exec {
commandLine = command
}
}
}
}
tasks.register<Zip>("zipStagingDeploy") {
dependsOn("signWithGpg")
dependsOn("publishMavenJavaPublicationToMavenRepository")
from(layout.buildDirectory.dir("staging-deploy"))
archiveFileName.set("staging-deploy-${project.name}-${project.version}.zip")
destinationDirectory.set(layout.buildDirectory)
}