1
0
mirror of https://github.com/chylex/Minecraft-Window-Title.git synced 2024-11-14 17:42:49 +01:00
Minecraft-Window-Title/build.gradle.kts
2024-10-19 19:36:25 +02:00

184 lines
4.0 KiB
Plaintext

import org.gradle.api.file.DuplicatesStrategy.EXCLUDE
import java.text.SimpleDateFormat
import java.util.Date
val modId: String by project
val modName: String by project
val modDescription: String by project
val modAuthor: String by project
val modVersion: String by project
val modLicense: String by project
val modSourcesURL: String by project
val modIssuesURL: String by project
val minecraftVersion: String by project
val mixinVersion: String by project
val minimumMinecraftVersion: String by project
val minimumForgeVersion: String by project
val minimumFabricVersion: String by project
val modNameStripped = modName.replace(" ", "")
val jarVersion = "$minecraftVersion+v$modVersion"
buildscript {
repositories {
maven("https://repo.spongepowered.org/maven")
}
dependencies {
classpath("org.spongepowered:vanillagradle:0.2.1-20231203.020957-71")
}
}
plugins {
`java-library`
idea
id("org.spongepowered.gradle.vanilla") version "0.2.1-20231203.020957-71"
}
idea {
module {
excludeDirs.add(file("gradle"))
excludeDirs.add(file("run"))
if (findProject(":Forge") == null) {
excludeDirs.add(file("Forge"))
}
if (findProject(":Fabric") == null) {
excludeDirs.add(file("Fabric"))
}
}
}
repositories {
maven("https://repo.spongepowered.org/maven")
mavenCentral()
}
dependencies {
implementation("org.spongepowered:mixin:$mixinVersion")
api("com.google.code.findbugs:jsr305:3.0.2")
}
base {
archivesName.set("$modNameStripped-Common")
}
minecraft {
version(minecraftVersion)
runs.clear()
}
allprojects {
group = "com.$modAuthor.$modId"
version = modVersion
apply(plugin = "java")
dependencies {
implementation("org.jetbrains:annotations:22.0.0")
}
extensions.getByType<JavaPluginExtension>().apply {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(17)
}
}
subprojects {
repositories {
maven("https://repo.spongepowered.org/maven")
}
dependencies {
implementation(rootProject)
}
base {
archivesName.set("$modNameStripped-${project.name}")
}
tasks.withType<JavaCompile> {
source({ rootProject.sourceSets.main.get().allSource })
}
tasks.processResources {
inputs.property("id", modId)
inputs.property("name", modName)
inputs.property("description", modDescription)
inputs.property("version", modVersion)
inputs.property("author", modAuthor)
inputs.property("license", modLicense)
inputs.property("sourcesURL", modSourcesURL)
inputs.property("issuesURL", modIssuesURL)
inputs.property("minimumMinecraftVersion", minimumMinecraftVersion)
inputs.property("minimumForgeVersion", minimumForgeVersion)
inputs.property("minimumFabricVersion", minimumFabricVersion)
from(rootProject.sourceSets.main.get().resources) {
expand(inputs.properties)
}
}
tasks.jar {
archiveVersion.set(jarVersion)
from(rootProject.file("LICENSE"))
manifest {
attributes(
"Specification-Title" to modId,
"Specification-Vendor" to modAuthor,
"Specification-Version" to "1",
"Implementation-Title" to "$modNameStripped-${project.name}",
"Implementation-Vendor" to modAuthor,
"Implementation-Version" to modVersion,
"Implementation-Timestamp" to SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(Date()),
"MixinConfigs" to "$modId.mixins.json"
)
}
}
tasks.test {
onlyIf { false }
}
}
tasks.register("setupIdea") {
group = "mod"
dependsOn(tasks.findByName("decompile"))
val forge = findProject(":Forge")
if (forge != null) {
dependsOn(forge.tasks.getByName("genIntellijRuns"))
}
val fabric = findProject(":Fabric")
if (fabric != null) {
dependsOn(fabric.tasks.getByName("genSources"))
}
}
val copyJars = tasks.register<Copy>("copyJars") {
group = "build"
duplicatesStrategy = EXCLUDE
for (subproject in subprojects) {
dependsOn(subproject.tasks.assemble)
from(subproject.base.libsDirectory.file("${subproject.base.archivesName.get()}-$jarVersion.jar"))
}
into(file("${project.buildDir}/dist"))
}
tasks.assemble {
finalizedBy(copyJars)
}