-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.gradle.kts
191 lines (162 loc) · 5.72 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import net.minecraftforge.gradle.userdev.UserDevExtension
import org.spongepowered.gradle.plugin.config.PluginLoaders
import org.spongepowered.plugin.metadata.model.PluginDependency
import java.io.ByteArrayOutputStream
buildscript {
repositories {
maven { url = uri("https://maven.minecraftforge.net") }
mavenCentral()
}
dependencies {
classpath(group = "net.minecraftforge.gradle", name = "ForgeGradle", version = "5.1.+") {
isChanging = true
}
}
}
val chestRefillId = findProperty("chestrefill.id") as String
val chestRefillName = findProperty("chestrefill.name") as String
val chestRefillVersion = findProperty("chestrefill.version") as String
val minecraftVersion = findProperty("minecraft.version") as String
val forgeVersion = findProperty("forge.version") as String
val spongeApiVersion = findProperty("sponge-api.version") as String
plugins {
idea
java
`maven-publish`
id("org.spongepowered.gradle.plugin") version "2.1.1"
id("org.spongepowered.gradle.ore") version "2.1.1" // for Ore publishing
id("com.github.johnrengelman.shadow") version "7.1.2"
}
group = "io.github.aquerr"
version = "$chestRefillVersion-API-$spongeApiVersion"
apply(plugin = "net.minecraftforge.gradle")
description = "Plugin for restoring contents of a container after the specified time."
repositories {
mavenCentral()
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType(JavaCompile::class).configureEach {
options.apply {
encoding = "utf-8" // Consistent source file encoding
}
}
// Make sure all tasks which produce archives (jar, sources jar, javadoc jar, etc) produce more consistent output
tasks.withType(AbstractArchiveTask::class).configureEach {
isReproducibleFileOrder = true
isPreserveFileTimestamps = false
}
dependencies {
"minecraft"("net.minecraftforge:forge:${forgeVersion}")
api("org.spongepowered:spongeapi:${spongeApiVersion}")
shadow("org.bstats:bstats-sponge:3.0.2")
}
tasks {
jar {
finalizedBy("shadowJar")
if(System.getenv("JENKINS_HOME") != null) {
project.version = project.version.toString() + "_" + System.getenv("BUILD_NUMBER")
println("File name => " + archiveBaseName.get())
} else {
project.version = project.version.toString() + "-SNAPSHOT"
}
}
shadowJar {
finalizedBy("reobfJar")
archiveClassifier.set("")
relocate("org.bstats", "io.github.aquerr.chestrefill.lib.bstats")
configurations = listOf(project.configurations.shadow.get())
}
}
configure<UserDevExtension> {
mappings("official", minecraftVersion)
}
sponge {
apiVersion(spongeApiVersion)
license("MIT")
loader {
name(PluginLoaders.JAVA_PLAIN)
version("1.0")
}
plugin(chestRefillId) {
displayName(chestRefillName)
version(chestRefillVersion)
entrypoint("io.github.aquerr.chestrefill.ChestRefill")
description("Rebuilds destroyed blocks after specified time.")
links {
homepage("https://github.com/Aquerr/ChestRefill")
source("https://github.com/Aquerr/ChestRefill")
issues("https://github.com/Aquerr/ChestRefill/issues")
}
contributor("Aquerr") {
description("Lead Developer")
}
dependency("spongeapi") {
loadOrder(PluginDependency.LoadOrder.AFTER)
optional(false)
}
}
}
val getGitCommitDesc by tasks.registering(Exec::class) {
commandLine("git", "log", "-1", "--pretty=%B")
standardOutput = ByteArrayOutputStream()
doLast {
project.extra["gitCommitDesc"] = standardOutput.toString()
}
}
tasks.register("printEnvironment") {
doLast {
System.getenv().forEach { key, value ->
println("$key -> $value")
}
}
}
tasks.create("publishBuildOnDiscord") {
dependsOn(getGitCommitDesc)
group = "Publishing"
description = "Task for publishing the jar file to discord's jenkins channel"
doLast {
val jarFiles: List<String> = groovy.ant.FileNameFinder().getFileNames(project.buildDir.path, "**/*.jar")
if(jarFiles.size > 0) {
println("Found jar files: " + jarFiles)
var lastCommitDescription = project.extra["gitCommitDesc"]
if(lastCommitDescription == null || lastCommitDescription == "") {
lastCommitDescription = "No changelog provided"
}
exec {
commandLine("java", "-jar", ".." + File.separator + "jenkinsdiscordbot-1.0.jar", "ChestRefill", jarFiles[0], lastCommitDescription)
}
}
}
}
oreDeployment {
// The default publication here is automatically configured by SpongeGradle
// using the first-created plugin's ID as the project ID
// A version body is optional, to provide additional information about the release
/*
defaultPublication {
// Read the version body from the file whose path is provided to the changelog gradle property
versionBody.set(providers.gradleProperty("changelog").map { file(it).readText(Charsets.UTF_8) }.orElse(""))
}*/
}
publishing {
repositories {
maven {
name = "GithubPackages"
url = uri("https://maven.pkg.github.com/Aquerr/ChestRefill")
credentials {
username = System.getenv("GITHUB_PUBLISHING_USERNAME")
password = System.getenv("GITHUB_PUBLISHING_TOKEN")
}
}
}
publications {
register<MavenPublication>(chestRefillId) {
artifactId = chestRefillId
description = project.description
from(components["java"])
}
}
}