-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle.kts
111 lines (93 loc) · 3.23 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
plugins {
id("com.github.johnrengelman.shadow") version "8.1.1"
id("io.papermc.paperweight.userdev") version "1.5.11"
id("me.champeau.jmh") version "0.7.2"
`maven-publish`
java
}
allprojects {
apply(plugin = "java")
apply(plugin = "maven-publish")
apply(plugin = "com.github.johnrengelman.shadow")
group = "com.github.Outspending"
version = "0.0.1"
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
// The file for publication.
val reobfBuildFile = project.layout.buildDirectory.file("libs/${project.name}-${project.version}.jar")
// Check if a project has the reobfJar task.
fun Project.usesReobfuscatedJar() : Boolean {
return try {
tasks.named("reobfJar")
true
} catch (ignored: UnknownTaskException) {
false
}
}
// needs to be in after evaluate, otherwise the project's reobfJar task (if it exists)
// won't be there.
afterEvaluate {
// publish NMS apis, and the main project API
// this is required because consumers require getting the POM
// files from this project's dependencies, even if they"re completely
// shaded and included in this file.
//
// not optimal because this leads to more network calls when downloading
// the api for the first time. ideally we only publish the main api.
publishing {
publications {
create<MavenPublication>("maven") {
groupId = "com.github.Outspending"
artifactId = project.name
if (usesReobfuscatedJar()) artifact(reobfBuildFile)
from(components["java"])
}
}
}
// Throws an error if we don"t explicitly say we're using the output
// of reobfJar in the final build.
tasks.named("publishMavenPublicationToMavenLocal") {
if (usesReobfuscatedJar()) {
dependsOn(tasks.reobfJar)
}
}
// Don't use the task if it doesn't exist on this project
if (usesReobfuscatedJar()) {
tasks.reobfJar {
outputJar.set(reobfBuildFile)
}
}
// Run reobfJar on applicable projects
tasks.assemble {
if (usesReobfuscatedJar()) dependsOn(tasks.reobfJar)
}
}
repositories {
mavenCentral()
maven {
name = "papermc-repo"
url = uri("https://repo.papermc.io/repository/maven-public/")
}
maven {
name = "sonatype"
url = uri("https://oss.sonatype.org/content/groups/public/")
}
}
}
val nmsVersions = listOf("1.19_R2", "1.19_R3", "1.20_R1", "1.20_R2", "1.20_R3")
dependencies {
paperweight.paperDevBundle("1.20-R0.1-SNAPSHOT")
// NMS Implementations
implementation(project(":NMS:Wrapper"))
for (version in nmsVersions) {
implementation(project(path = ":NMS:${version}", configuration = "reobf"))
}
// JMH Implementations
jmh("org.openjdk.jmh:jmh-core:0.9")
jmh("org.openjdk.jmh:jmh-generator-annprocess:0.9")
}
tasks.wrapper {
gradleVersion = "8.1.1"
distributionType = Wrapper.DistributionType.ALL
}