forked from PaperMC/Paperclip
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
150 lines (124 loc) · 4.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
146
147
148
149
150
import kotlin.system.exitProcess
plugins {
java
application
`maven-publish`
}
subprojects {
apply(plugin = "java")
tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
}
}
val mainClass = "org.leavesmc.leavesclip.Main"
tasks.jar {
val java6Jar = project(":java6").tasks.named("jar")
val java17Jar = project(":java21").tasks.named("shadowJar")
dependsOn(java6Jar, java17Jar)
from(zipTree(java6Jar.map { it.outputs.files.singleFile }))
from(zipTree(java17Jar.map { it.outputs.files.singleFile }))
manifest {
attributes(
"Main-Class" to mainClass
)
}
doFirst {
val clipVerFile = File("leavesclip-version")
if (!clipVerFile.exists()) {
if(!clipVerFile.createNewFile()){
println("failed to create file: leavesclip-version")
exitProcess(1)
}
}
clipVerFile.writeText(project.version.toString())
}
from(file("leavesclip-version")) {
into("META-INF")
}
from(file("LEAVESCLIP_LICENSE")) {
into("META-INF/license")
rename { "leavesclip-LICENSE.txt" }
}
rename { name ->
if (name.endsWith("-LICENSE.txt")) {
"META-INF/license/$name"
} else {
name
}
}
}
val sourcesJar by tasks.registering(Jar::class) {
val java6Sources = project(":java6").tasks.named("sourcesJar")
val java17Sources = project(":java21").tasks.named("sourcesJar")
dependsOn(java6Sources, java17Sources)
from(zipTree(java6Sources.map { it.outputs.files.singleFile }))
from(zipTree(java17Sources.map { it.outputs.files.singleFile }))
archiveClassifier.set("sources")
}
val isSnapshot = project.version.toString().endsWith("-SNAPSHOT")
publishing {
publications {
register<MavenPublication>("maven") {
groupId = project.group.toString()
artifactId = project.name
version = project.version.toString()
from(components["java"])
artifact(sourcesJar)
withoutBuildIdentifier()
pom {
val repoPath = "LeavesMC/Leavesclip"
val repoUrl = "https://github.com/$repoPath"
name.set("Leavesclip")
description.set(project.description)
url.set(repoUrl)
packaging = "jar"
licenses {
license {
name.set("MIT")
url.set("$repoUrl/blob/main/LEAVESCLIP_LICENSE")
distribution.set("repo")
}
}
issueManagement {
system.set("GitHub")
url.set("$repoUrl/issues")
}
developers {
developer {
id.set("DemonWav")
name.set("Kyle Wood")
email.set("[email protected]")
url.set("https://github.com/DemonWav")
}
developer {
id.set("MC_XiaoHei")
name.set("MC_XiaoHei")
email.set("[email protected]")
url.set("https://github.com/MC_XiaoHei")
}
}
scm {
url.set(repoUrl)
connection.set("scm:git:$repoUrl.git")
developerConnection.set("scm:git:[email protected]:$repoPath.git")
}
}
}
repositories {
val url = if (isSnapshot) {
"https://repo.leavesmc.org/snapshots/"
} else {
"https://repo.leavesmc.org/releases/"
}
maven(url) {
credentials(PasswordCredentials::class)
name = "leavesmc"
}
}
}
}
tasks.register("printVersion") {
doFirst {
println(version)
}
}