forked from MightyPirates/TIS-3D
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
145 lines (122 loc) · 4.26 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
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import net.fabricmc.loom.api.LoomGradleExtensionAPI
import net.fabricmc.loom.task.RemapJarTask
import org.gradle.configurationcache.extensions.capitalized
plugins {
java
alias(libs.plugins.architectury)
alias(libs.plugins.loom) apply false
alias(libs.plugins.shadow) apply false
alias(libs.plugins.spotless)
}
val modId: String by project
val modVersion: String by project
val mavenGroup: String by project
val enabledPlatforms: String by project
val minecraftVersion: String = libs.versions.minecraft.get()
fun getGitRef(): String {
return providers.exec {
commandLine("git", "rev-parse", "--short", "HEAD")
isIgnoreExitValue = true
}.standardOutput.asText.get().trim()
}
subprojects {
apply(plugin = "java")
apply(plugin = rootProject.libs.plugins.architectury.get().pluginId)
apply(plugin = rootProject.libs.plugins.loom.get().pluginId)
version = "${modVersion}+${getGitRef()}"
group = mavenGroup
base.archivesName.set("${modId}-MC${minecraftVersion}-${project.name}")
architectury {
minecraft = minecraftVersion
}
configure<LoomGradleExtensionAPI> {
silentMojangMappingsLicense()
}
repositories {
exclusiveContent {
forRepository { maven("https://maven.parchmentmc.org") }
filter { includeGroupByRegex("org\\.parchmentmc.*") }
}
exclusiveContent {
forRepository { maven("https://api.modrinth.com/maven") }
filter { includeGroup("maven.modrinth") }
}
}
dependencies {
"minecraft"(rootProject.libs.minecraft)
val loom = project.extensions.getByName<LoomGradleExtensionAPI>("loom")
"mappings"(loom.layered {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${rootProject.libs.versions.parchment.minecraft.get()}:${rootProject.libs.versions.parchment.mappings.get()}@zip")
})
"compileOnly"("com.google.code.findbugs:jsr305:3.0.2")
}
tasks {
jar {
from("LICENSE") {
rename { "${it}_${modId}" }
}
}
withType<JavaCompile>().configureEach {
options.encoding = "utf-8"
options.release.set(17)
}
}
idea {
module {
for (exclude in arrayOf("out", "logs")) {
excludeDirs.add(file(exclude))
}
}
}
}
for (platform in enabledPlatforms.split(',')) {
project(":$platform") {
apply(plugin = rootProject.libs.plugins.shadow.get().pluginId)
architectury {
platformSetupLoomIde()
loader(platform)
}
val common: Configuration by configurations.creating
val shadowCommon: Configuration by configurations.creating
configurations {
compileClasspath.get().extendsFrom(common)
runtimeClasspath.get().extendsFrom(common)
getByName("development${platform.capitalized()}").extendsFrom(common)
}
dependencies {
common(project(path = ":common", configuration = "namedElements")) { isTransitive = false }
shadowCommon(project(path = ":common", configuration = "transformProduction${platform.capitalized()}")) { isTransitive = false }
}
tasks {
withType<ShadowJar> {
exclude("architectury.common.json")
configurations = listOf(shadowCommon)
archiveClassifier.set("dev-shadow")
}
withType<RemapJarTask> {
val shadowJarTask = getByName<ShadowJar>("shadowJar")
inputFile.set(shadowJarTask.archiveFile)
dependsOn(shadowJarTask)
archiveClassifier.set(null as String?)
}
jar {
archiveClassifier.set("dev")
}
}
(components["java"] as AdhocComponentWithVariants)
.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) {
skip()
}
}
}
spotless {
java {
target("*/src/*/java/li/cil/**/*.java")
endWithNewline()
trimTrailingWhitespace()
removeUnusedImports()
indentWithSpaces()
}
}