Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retool to Essential Loom #1836

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 2 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# common
run
runServer
build
.gradle

Expand All @@ -16,9 +17,4 @@ bin
*.ipr
*.iws
*.iml
.idea

# don't want compiled jars in the repo
out
mcinterfaceforge1182
mcinterfaceforge1192
.idea
93 changes: 31 additions & 62 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,74 +1,43 @@
import java.nio.file.Paths
import kotlin.io.path.moveTo
import kotlin.io.path.ExperimentalPathApi


plugins {
java
kotlin("jvm") version "1.7.20"
}

repositories {
mavenCentral()
}

dependencies {
implementation(kotlin("stdlib-jdk8"))
}

subprojects {
apply(plugin = "java")
`java-library`
id("gg.essential.loom") apply (false)
}

var modVersion: String = project.property("global_version").toString()
allprojects {
group = "mts"
version = "22.16.0"

//var modVersion: String = providers.gradleProperty("global_version")

var mcCore = project(":mccore")
var mcInterfaceForge1122 = project(":mcinterfaceforge1122")
var mcInterfaceForge1165 = project(":mcinterfaceforge1165")

tasks.register("buildCore") {
dependsOn(mcCore.tasks.build)
doLast {
moveToOut(mcCore, "core")
repositories {
maven("https://dvs1.progwml6.com/files/maven/") // JEI repo
mavenCentral()
}
}

tasks.register("buildForge1122") {
doFirst { preBuild() }
doLast {
moveToOut(mcInterfaceForge1122, "1.12.2")
tasks {
withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(8)
options.compilerArgs.addAll(listOf("-Xlint:deprecation", "-Xlint:unchecked", "-Xlint:-options"))
}

withType<Jar> {
archiveBaseName.set("${rootProject.name}-${project.name}")
}

withType<AbstractArchiveTask> {
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}
}
dependsOn(mcInterfaceForge1122.tasks.build)
}

tasks.register("buildForge1165") {
doFirst { preBuild() }
doLast {
moveToOut(mcInterfaceForge1165, "1.16.5")
}
dependsOn(mcInterfaceForge1165.tasks.build)
}
subprojects {
apply(plugin = "org.gradle.java-library")

tasks.register("buildForgeAll") {
dependsOn(tasks.getByName("buildForge1122"))
dependsOn(tasks.getByName("buildForge1165"))
}
java {
withSourcesJar()

@OptIn(ExperimentalPathApi::class)
fun moveToOut(subProject: Project, versionStr: String) {
val jarName = "Immersive Vehicles-${subProject.version}.jar"
Paths.get("${subProject.projectDir.canonicalPath}/build/libs/$jarName")
.moveTo(Paths.get("${project.projectDir.canonicalPath}/out/$jarName"), true)
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
}

fun preBuild() {
// Could probably be better somehow, but I'm not sure how
project.projectDir.canonicalFile.walk()
.filter { it.name == "gradle.properties" || it.name == "mcmod.info" || it.name == "InterfaceLoader.java" }
.forEach { it.writeText(it.readText()
.replace(Regex("mod_version=(.+)"), "mod_version=$modVersion")
.replace(Regex("\"version\": \"[^\"]*\""), "\"version\": \"$modVersion\"")
.replace(Regex("MODVER = \"[^\"]*\";"), "MODVER = \"$modVersion\";")) }
}
29 changes: 29 additions & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
plugins {
id("io.github.goooler.shadow") version "8.1.7"
}

configurations.implementation {
extendsFrom(configurations.getByName("shadow"))
}

dependencies {
shadow("com.googlecode.soundlibs:jlayer:1.0.1.4")
shadow("org.jcraft:jorbis:0.0.17")

compileOnly("com.google.code.gson:gson:2.8.0") // 1.12.2: 2.8.0
compileOnly("io.netty:netty-all:4.1.9.Final") // 1.12.2: 4.1.9.Final
}

tasks {
jar {
archiveClassifier.set("thin")
duplicatesStrategy = DuplicatesStrategy.WARN
dependsOn(shadowJar)
}

shadowJar {
configurations = listOf(project.configurations.getByName("shadow"))
mergeServiceFiles()
archiveClassifier.set("fat")
}
}
Loading