-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.gradle.kts
94 lines (79 loc) · 2.48 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
plugins {
id("fabric-loom") version "1.9.+"
`maven-publish`
}
operator fun Project.get(prop: String) = extra[prop] as String
version = project["mod_version"]
group = project["maven_group"]
base.archivesName.set(project["archives_base_name"])
val api by sourceSets.registering {
compileClasspath += sourceSets.main.get().compileClasspath
}
dependencies {
// To change the versions see the gradle.properties file
minecraft("com.mojang:minecraft:${project.extra["minecraft_version"]}")
mappings("net.fabricmc:yarn:${project.extra["yarn_mappings"]}:v2")
modImplementation("net.fabricmc:fabric-loader:${project.extra["loader_version"]}")
include(implementation("net.lenni0451:Reflect:1.4.0")!!)
include(implementation("com.formdev:flatlaf:3.5.4")!!)
}
tasks.jar {
includeEmptyDirs = false
manifest {
attributes["Premain-Class"] = "io.github.gaming32.modloadingscreen.EarlyLoadingAgent"
}
}
val apiJar by tasks.registering(Jar::class) {
from(api.get().output)
archiveClassifier.set("api")
}
tasks.build {
dependsOn(apiJar)
}
tasks.processResources {
inputs.property("version", project.version)
filteringCharset = "UTF-8"
filesMatching("fabric.mod.json") {
expand("version" to project.version)
}
}
val targetJavaVersion = 8
tasks.withType<JavaCompile>().configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
options.encoding = "UTF-8"
if (JavaVersion.current().isJava10Compatible) {
options.release.set(targetJavaVersion)
}
}
java {
val javaVersion = JavaVersion.toVersion(targetJavaVersion)
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion.set(JavaLanguageVersion.of(targetJavaVersion))
}
withSourcesJar()
}
tasks.named<Jar>("sourcesJar") {
from(api.get().allSource)
}
tasks.jar {
from("LICENSE") {
rename { "${it}_${base.archivesName.get()}" }
}
}
// configure the maven publication
publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])
artifact(apiJar.get().archiveFile) {
classifier = "api"
}
}
}
repositories {
mavenLocal()
}
}