-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
120 lines (99 loc) · 3.47 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
import java.io.ByteArrayOutputStream
plugins {
`java-library`
`maven-publish`
}
val eaglefactionsApiVersion = findProperty("eaglefactions-api.version") as String
val spongeApiVersion = findProperty("sponge-api.version") as String
val finalVersion = "$eaglefactionsApiVersion-API-$spongeApiVersion"
group = "io.github.aquerr"
version = finalVersion
repositories {
mavenCentral()
maven("https://repo.spongepowered.org/maven")
}
dependencies {
compileOnly("org.spongepowered:spongeapi:$spongeApiVersion")
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(JavaVersion.VERSION_21.majorVersion))
withSourcesJar()
withJavadocJar()
}
tasks.jar {
archiveBaseName.set("EagleFactionsAPI")
if(System.getenv("JENKINS_HOME") != null) {
project.version = finalVersion + "_" + System.getenv("BUILD_NUMBER") + "-SNAPSHOT"
println("Version => " + project.version.toString())
} else {
project.version = "$finalVersion-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)
}
}
}
}
publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])
pom {
name.set("EagleFactionsAPI")
artifactId = "eaglefactionsapi"
description.set(project.description)
url.set("https://github.com/Aquerr/EagleFactionsAPI")
licenses {
license {
name.set("MIT")
url.set("https://github.com/Aquerr/EagleFactionsAPI/blob/api-8/LICENSE")
}
}
developers {
developer {
id.set("Aquerr")
name.set("Bartłomiej Stępień")
url.set("https://github.com/Aquerr")
}
}
scm {
connection.set("scm:git:git://github.com/Aquerr/EagleFactionsAPI.git")
developerConnection.set("scm:git:ssh://github.com/Aquerr/EagleFactionsAPI.git")
url.set("https://github.com/Aquerr/EagleFactionsAPI")
}
}
}
}
}