-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
78 lines (64 loc) · 2.24 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
import java.io.ByteArrayOutputStream
plugins {
java
}
val eaglefactionsApiVersion = findProperty("eaglefactions-api.version") as String
val spongeApiVersion = findProperty("sponge-api.version") as String
group = "io.github.aquerr"
version = "$eaglefactionsApiVersion-API-$spongeApiVersion"
repositories {
mavenCentral()
maven("https://repo.spongepowered.org/maven")
}
dependencies {
compileOnly("org.spongepowered:spongeapi:$spongeApiVersion")
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
tasks.withType(Jar::class).configureEach {
if(System.getenv("JENKINS_HOME") != null) {
archiveVersion.set(project.version.toString() + "_" + System.getenv("BUILD_NUMBER") + "-SNAPSHOT")
println("Version => " + project.version.toString())
} else {
archiveVersion.set(project.version.toString() + "-SNAPSHOT")
}
}
tasks.withType(JavaCompile::class).configureEach {
options.apply {
encoding = "utf-8" // Consistent source file encoding
}
}
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.register("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", "EagleFactionsAPI", jarFiles[0], lastCommitDescription)
}
}
}
}