From f25d66680e97999062094d5e18abf61af474b568 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Fri, 3 May 2024 17:35:33 -0700 Subject: [PATCH] Wait, it's all kotlin? - Port to kotlin gradle --- build.gradle | 16 --- build.gradle.kts | 15 +++ buildSrc/build.gradle.kts | 2 +- common/build.gradle | 74 -------------- common/build.gradle.kts | 79 +++++++++++++++ fabric/build.gradle | 60 ----------- fabric/build.gradle.kts | 65 ++++++++++++ forge/build.gradle | 74 -------------- forge/build.gradle.kts | 79 +++++++++++++++ old.build.gradle | 205 -------------------------------------- settings.gradle | 26 ----- settings.gradle.kts | 25 +++++ 12 files changed, 264 insertions(+), 456 deletions(-) delete mode 100644 build.gradle create mode 100644 build.gradle.kts delete mode 100644 common/build.gradle create mode 100644 common/build.gradle.kts delete mode 100644 fabric/build.gradle create mode 100644 fabric/build.gradle.kts delete mode 100644 forge/build.gradle create mode 100644 forge/build.gradle.kts delete mode 100644 old.build.gradle delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 30891b8f7..000000000 --- a/build.gradle +++ /dev/null @@ -1,16 +0,0 @@ -plugins { - id 'idea' - id 'java' - id 'maven-publish' - id 'dev.architectury.loom' apply false -} - -println("Java: ${System.getProperty('java.version')}, JVM: ${System.getProperty('java.vm.version')} (${System.getProperty('java.vendor')}), Arch: ${System.getProperty('os.arch')}") - -idea { - // Tell IDEA to always download sources/javadoc artifacts from maven. - module { - downloadJavadoc = true - downloadSources = true - } -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 000000000..8704c07bc --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,15 @@ +plugins { + idea + java + id("dev.architectury.loom") apply false +} + +println("Java: ${System.getProperty("java.version")}, JVM: ${System.getProperty("java.vm.version")} (${System.getProperty("java.vendor")}), Arch: ${System.getProperty("os.arch")}") + +idea { + // Tell IDEA to always download sources/javadoc artifacts from maven. + module { + isDownloadJavadoc = true + isDownloadSources = true + } +} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 335241b39..885339096 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,6 +1,6 @@ plugins { id("java-gradle-plugin") - kotlin("jvm") version "1.9.20" + kotlin("jvm") version "1.9.23" `kotlin-dsl` } diff --git a/common/build.gradle b/common/build.gradle deleted file mode 100644 index c2f59a552..000000000 --- a/common/build.gradle +++ /dev/null @@ -1,74 +0,0 @@ -plugins { - id 'idea' - id 'java' - id 'maven-publish' - id 'dev.architectury.loom' - id 'flywheel.package-infos' - id 'flywheel.subproject' - id 'flywheel.jar-sets' - id 'flywheel.transitive-source-sets' -} - -transitiveSourceSets { - compileClasspath = sourceSets.main.compileClasspath - - create('api') { - rootCompile() - } - create('lib') { - rootCompile() - compile sourceSets.api - } - create('backend') { - rootCompile() - compile sourceSets.api, sourceSets.lib - } - sourceSet(sourceSets.main) { - compile sourceSets.api, sourceSets.lib, sourceSets.backend - } - sourceSet(sourceSets.test) { - implementation sourceSets.api, sourceSets.lib, sourceSets.backend - } -} - -defaultPackageInfos { - sources sourceSets.api, sourceSets.lib, sourceSets.backend, sourceSets.main -} - -// For sharing with other subprojects. -jarSets { - createJars('apiOnly', sourceSets.api).createOutgoingConfiguration('common') - createJars('lib').createOutgoingConfiguration('common') - createJars('backend').createOutgoingConfiguration('common') - createJars('impl', sourceSets.main).createOutgoingConfiguration('common') -} - -// For publishing -def apiLibJar = jarSets.createJars('api', sourceSets.api, sourceSets.lib) - -dependencies { - modCompileOnly "net.fabricmc:fabric-loader:${fabric_loader_version}" - - testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1' -} - -test { - useJUnitPlatform() -} - -publishing { - publications { - register('mavenIntermediary', MavenPublication) { - artifact apiLibJar.remapJar - artifact apiLibJar.remapSources - artifact apiLibJar.javadocJar - artifactId = "flywheel-common-intermediary-api-${artifact_minecraft_version}" - } - register('mavenMojmap', MavenPublication) { - artifact apiLibJar.jar - artifact apiLibJar.sources - artifact apiLibJar.javadocJar - artifactId = "flywheel-common-mojmap-api-${artifact_minecraft_version}" - } - } -} diff --git a/common/build.gradle.kts b/common/build.gradle.kts new file mode 100644 index 000000000..5b3dc91ed --- /dev/null +++ b/common/build.gradle.kts @@ -0,0 +1,79 @@ +plugins { + idea + java + `maven-publish` + id("dev.architectury.loom") + id("flywheel.package-infos") + id("flywheel.subproject") + id("flywheel.jar-sets") + id("flywheel.transitive-source-sets") +} + +val api = sourceSets.create("api") +val lib = sourceSets.create("lib") +val backend = sourceSets.create("backend") +val main = sourceSets.getByName("main") + +transitiveSourceSets { + compileClasspath = main.compileClasspath + + sourceSet(api) { + rootCompile() + } + sourceSet(lib) { + rootCompile() + compile(api) + } + sourceSet(backend) { + rootCompile() + compile(api, lib) + } + sourceSet(main) { + compile(api, lib, backend) + } + sourceSet(sourceSets.getByName("test")) { + implementation(api, lib, backend) + } +} + +defaultPackageInfos { + sources(api, lib, backend, main) +} + +// For sharing with other subprojects. +jarSets { + createJars("apiOnly", api).createOutgoingConfiguration("common") + createJars("lib").createOutgoingConfiguration("common") + createJars("backend").createOutgoingConfiguration("common") + createJars("impl", main).createOutgoingConfiguration("common") +} + +// For publishing +val apiLibJar = jarSets.createJars("api", api, lib) + +dependencies { + modCompileOnly("net.fabricmc:fabric-loader:${property("fabric_loader_version")}") + + testImplementation("org.junit.jupiter:junit-jupiter:5.8.1") +} + +tasks.test { + useJUnitPlatform() +} + +publishing { + publications { + register("mavenIntermediary") { + artifact(apiLibJar.remapJar) + artifact(apiLibJar.remapSources) + artifact(apiLibJar.javadocJar) + artifactId = "flywheel-common-intermediary-api-${property("artifact_minecraft_version")}" + } + register("mavenMojmap") { + artifact(apiLibJar.jar) + artifact(apiLibJar.sources) + artifact(apiLibJar.javadocJar) + artifactId = "flywheel-common-mojmap-api-${property("artifact_minecraft_version")}" + } + } +} diff --git a/fabric/build.gradle b/fabric/build.gradle deleted file mode 100644 index eda0a1e57..000000000 --- a/fabric/build.gradle +++ /dev/null @@ -1,60 +0,0 @@ -plugins { - id 'idea' - id 'java' - id 'maven-publish' - id 'dev.architectury.loom' - id 'flywheel.package-infos' - id 'flywheel.subproject' - id 'flywheel.platform' - id 'flywheel.jar-sets' - id 'flywheel.transitive-source-sets' -} - -transitiveSourceSets { - compileClasspath = sourceSets.main.compileClasspath - - create('api') { - rootCompile() - } - create('lib') { - rootCompile() - compile sourceSets.api - } - create('backend') { - rootCompile() - compile sourceSets.api, sourceSets.lib - } - sourceSet(sourceSets.main) { - implementation sourceSets.api, sourceSets.lib, sourceSets.backend - } - - createCompileConfigurations() -} - -platform { - commonProject = project(':common') - sources sourceSets.api, sourceSets.lib, sourceSets.backend, sourceSets.main - compileWithCommonSourceSets() - setupLoomMod() - setupLoomRuns() - setupFatJar() - publishMod() - publishRemap(apiArtifactId, jarSets.createJars('api', sourceSets.api, sourceSets.lib)) -} - -defaultPackageInfos { - sources sourceSets.api, sourceSets.lib, sourceSets.backend, sourceSets.main -} - -dependencies { - modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}" - modApi "net.fabricmc.fabric-api:fabric-api:${fabric_api_version}" - - modCompileOnly "maven.modrinth:sodium:${sodium_version}" - modCompileOnly "maven.modrinth:iris:${iris_version}" - - forApi project(path: ':common', configuration: 'commonApiOnly') - forLib project(path: ':common', configuration: 'commonLib') - forBackend project(path: ':common', configuration: 'commonBackend') - forMain project(path: ':common', configuration: 'commonImpl') -} diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts new file mode 100644 index 000000000..ba208fd19 --- /dev/null +++ b/fabric/build.gradle.kts @@ -0,0 +1,65 @@ +plugins { + idea + java + `maven-publish` + id("dev.architectury.loom") + id("flywheel.package-infos") + id("flywheel.subproject") + id("flywheel.platform") + id("flywheel.jar-sets") + id("flywheel.transitive-source-sets") +} + +val api = sourceSets.create("api") +val lib = sourceSets.create("lib") +val backend = sourceSets.create("backend") +val main = sourceSets.getByName("main") + +transitiveSourceSets { + compileClasspath = main.compileClasspath + + sourceSet(api) { + rootCompile() + } + sourceSet(lib) { + rootCompile() + compile(api) + } + sourceSet(backend) { + rootCompile() + compile(api, lib) + } + sourceSet(main) { + implementation(api, lib, backend) + } + + createCompileConfigurations() +} + +platform { + commonProject = project(":common") + sources(api, lib, backend, main) + compileWithCommonSourceSets() + setupLoomMod() + setupLoomRuns() + setupFatJar() + publishMod() + publishRemap(apiArtifactId, jarSets.createJars("api", api, lib)) +} + +defaultPackageInfos { + sources(api, lib, backend, main) +} + +dependencies { + modImplementation("net.fabricmc:fabric-loader:${property("fabric_loader_version")}") + modApi("net.fabricmc.fabric-api:fabric-api:${property("fabric_api_version")}") + + modCompileOnly("maven.modrinth:sodium:${property("sodium_version")}") + modCompileOnly("maven.modrinth:iris:${property("iris_version")}") + + "forApi"(project(path = ":common", configuration = "commonApiOnly")) + "forLib"(project(path = ":common", configuration = "commonLib")) + "forBackend"(project(path = ":common", configuration = "commonBackend")) + "forMain"(project(path = ":common", configuration = "commonImpl")) +} diff --git a/forge/build.gradle b/forge/build.gradle deleted file mode 100644 index 707960030..000000000 --- a/forge/build.gradle +++ /dev/null @@ -1,74 +0,0 @@ -plugins { - id 'idea' - id 'java' - id 'maven-publish' - id 'dev.architectury.loom' - id 'flywheel.package-infos' - id 'flywheel.subproject' - id 'flywheel.platform' - id 'flywheel.jar-sets' - id 'flywheel.transitive-source-sets' -} - -transitiveSourceSets { - compileClasspath = sourceSets.main.compileClasspath - - create('api') { - rootCompile() - } - create('lib') { - rootCompile() - compile sourceSets.api - } - create('backend') { - rootCompile() - compile sourceSets.api, sourceSets.lib - } - sourceSet(sourceSets.main) { - compile sourceSets.api, sourceSets.lib, sourceSets.backend - } - - createCompileConfigurations() -} - -platform { - commonProject = project(':common') - sources sourceSets.api, sourceSets.lib, sourceSets.backend, sourceSets.main - compileWithCommonSourceSets() - setupLoomMod() - setupLoomRuns() - setupFatJar() - publishMod() - publishRemap(apiArtifactId, jarSets.createJars('api', sourceSets.api, sourceSets.lib)) -} - -defaultPackageInfos { - sources sourceSets.api, sourceSets.lib, sourceSets.backend, sourceSets.main -} - -loom { - forge { - mixinConfig 'flywheel.backend.mixins.json' - mixinConfig 'flywheel.impl.mixins.json' - mixinConfig 'flywheel.impl.sodium.mixins.json' - } - - runs { - configureEach { - property 'forge.logging.markers', '' - property 'forge.logging.console.level', 'debug' - } - } -} - -dependencies { - forge "net.minecraftforge:forge:${minecraft_version}-${forge_version}" - - modCompileOnly "maven.modrinth:embeddium:${embeddium_version}" - modCompileOnly "maven.modrinth:oculus:${oculus_version}" - - forApi project(path: ':common', configuration: 'commonApiOnly') - forLib project(path: ':common', configuration: 'commonLib') - forBackend project(path: ':common', configuration: 'commonBackend') - forMain project(path: ':common', configuration: 'commonImpl') -} diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts new file mode 100644 index 000000000..158c307f5 --- /dev/null +++ b/forge/build.gradle.kts @@ -0,0 +1,79 @@ +plugins { + idea + java + `maven-publish` + id("dev.architectury.loom") + id("flywheel.package-infos") + id("flywheel.subproject") + id("flywheel.platform") + id("flywheel.jar-sets") + id("flywheel.transitive-source-sets") +} + +val api = sourceSets.create("api") +val lib = sourceSets.create("lib") +val backend = sourceSets.create("backend") +val main = sourceSets.getByName("main") + +transitiveSourceSets { + compileClasspath = main.compileClasspath + + sourceSet(api) { + rootCompile() + } + sourceSet(lib) { + rootCompile() + compile(api) + } + sourceSet(backend) { + rootCompile() + compile(api, lib) + } + sourceSet(main) { + compile(api, lib, backend) + } + + createCompileConfigurations() +} + +platform { + commonProject = project(":common") + sources(api, lib, backend, main) + compileWithCommonSourceSets() + setupLoomMod() + setupLoomRuns() + setupFatJar() + publishMod() + publishRemap(apiArtifactId, jarSets.createJars("api", api, lib)) +} + +defaultPackageInfos { + sources(api, lib, backend, main) +} + +loom { + forge { + mixinConfig("flywheel.backend.mixins.json") + mixinConfig("flywheel.impl.mixins.json") + mixinConfig("flywheel.impl.sodium.mixins.json") + } + + runs { + configureEach { + property("forge.logging.markers", "") + property("forge.logging.console.level", "debug") + } + } +} + +dependencies { + forge("net.minecraftforge:forge:${property("minecraft_version")}-${property("forge_version")}") + + modCompileOnly("maven.modrinth:embeddium:${property("embeddium_version")}") + modCompileOnly("maven.modrinth:oculus:${property("oculus_version")}") + + "forApi"(project(path = ":common", configuration = "commonApiOnly")) + "forLib"(project(path = ":common", configuration = "commonLib")) + "forBackend"(project(path = ":common", configuration = "commonBackend")) + "forMain"(project(path = ":common", configuration = "commonImpl")) +} diff --git a/old.build.gradle b/old.build.gradle deleted file mode 100644 index 6caf08ab3..000000000 --- a/old.build.gradle +++ /dev/null @@ -1,205 +0,0 @@ -plugins { - id 'eclipse' - id 'idea' - id 'maven-publish' - id 'net.minecraftforge.gradle' version "${forgegradle_version}" - id 'org.parchmentmc.librarian.forgegradle' version "${librarian_version}" - id 'org.spongepowered.mixin' version "${mixingradle_version}" -} - -boolean dev = System.getenv('RELEASE') == null || System.getenv('RELEASE').equalsIgnoreCase('false'); - -ext.buildNumber = System.getenv('BUILD_NUMBER') - -group = 'com.jozufozu.flywheel' -archivesBaseName = "flywheel-forge-${artifact_minecraft_version}" -version = mod_version + (dev && buildNumber != null ? "-${buildNumber}" : '') - -java.toolchain.languageVersion = JavaLanguageVersion.of(17) - -println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" -minecraft { - mappings channel: 'parchment', version: "${parchment_version}-${minecraft_version}" - - copyIdeResources = true - - runs { - configureEach { - workingDirectory project.file('run') - - property 'forge.logging.markers', '' - property 'forge.logging.console.level', 'debug' - - property 'mixin.env.remapRefMap', 'true' - property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" - - mods { - flywheel { - source sourceSets.main - } - } - } - - client { - property 'flw.dumpShaderSource', 'true' - property 'flw.debugMemorySafety', 'true' - } - - server { - args '--nogui' - } - } -} - -repositories { - maven { - url 'https://www.cursemaven.com' - content { - includeGroup "curse.maven" - } - } - maven { - name 'tterrag maven' - url 'https://maven.tterrag.com/' - } - maven { - name = "Modrinth" - url = "https://api.modrinth.com/maven" - content { - includeGroup "maven.modrinth" - } - } - mavenCentral() -} - -dependencies { - testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1' - minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" - - compileOnly fg.deobf("maven.modrinth:embeddium:0.3.9+mc1.20.1") - compileOnly fg.deobf("maven.modrinth:oculus:1.20.1-1.6.15a") - // implementation fg.deobf("maven.modrinth:starlight-forge:1.1.2+1.20") - - // https://discord.com/channels/313125603924639766/725850371834118214/910619168821354497 - // Prevent Mixin annotation processor from getting into IntelliJ's annotation processor settings - // This allows 'Settings > Build, Execution, and Deployment > Build Tools > Gradle > Build and run using' set to IntelliJ to work correctly - // if (System.getProperty('idea.sync.active') != 'true') { - annotationProcessor "org.spongepowered:mixin:${mixin_version}:processor" - // } -} - -test { - useJUnitPlatform() -} - -mixin { - add sourceSets.main, 'flywheel.refmap.json' - - config 'flywheel.backend.mixins.json' - config 'flywheel.impl.mixins.json' - config 'flywheel.impl.sodium.mixins.json' - - debug.verbose = true - debug.export = true -} - -idea { - // Tell IDEA to always download sources/javadoc artifacts from maven. - module { - downloadJavadoc = true - downloadSources = true - } -} - -// Workaround for SpongePowered/MixinGradle#38 -afterEvaluate { - tasks.configureReobfTaskForReobfJar.mustRunAfter(tasks.compileJava) -} - -tasks.withType(JavaCompile).configureEach { - options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation -} - -javadoc { - source = [sourceSets.main.allJava] - // prevent java 8's strict doclint for javadocs from failing builds - options.addStringOption('Xdoclint:none', '-quiet') -} - -compileJava { - options.compilerArgs = ['-Xdiags:verbose'] -} - -tasks.named('processResources', ProcessResources).configure { - var replaceProperties = [ - minecraft_version : minecraft_version, - minecraft_version_range: minecraft_version_range, - forge_version : forge_version, - forge_version_range : forge_version_range, - loader_version_range : loader_version_range, - mod_version : mod_version - ] - inputs.properties replaceProperties - - filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) { - expand replaceProperties + [project: project] - } -} - -apply from: rootProject.file('gradle/package-infos.gradle') - -void addLicense(jarTask) { - jarTask.from('LICENSE.md') { - rename '(.*)\\.(.*)', '$1_' + archivesBaseName + '.$2' - } -} - -void addManifest(jarTask) { - jarTask.manifest { - attributes([ - 'Specification-Title' : 'flywheel', - // 'Specification-Vendor': 'flywheel authors', - 'Specification-Version' : '1', // We are version 1 of ourselves - 'Implementation-Title' : project.jar.archiveBaseName, - 'Implementation-Version' : project.jar.archiveVersion, - // 'Implementation-Vendor': 'flywheel authors', - 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), - ]) - } -} - -tasks.named('jar', Jar).configure { - archiveClassifier = '' - - finalizedBy 'reobfJar' - addManifest(it) - addLicense(it) -} - -java { - withSourcesJar() - withJavadocJar() -} - -publishing { - publications { - register('mavenJava', MavenPublication) { - artifact jar - artifact sourcesJar - artifact javadocJar - - artifactId = archivesBaseName - - fg.component(it) - } - } - repositories { - maven { - url "file://${project.projectDir}/mcmodsrepo" - } - - if (project.hasProperty('mavendir')) { - maven { url mavendir } - } - } -} diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index bbbca7a35..000000000 --- a/settings.gradle +++ /dev/null @@ -1,26 +0,0 @@ -pluginManagement { - repositories { - gradlePluginPortal() - mavenCentral() - maven { - name = 'MinecraftForge' - url = 'https://maven.minecraftforge.net/' - } - maven { - name = 'Architectury' - url = 'https://maven.architectury.dev/' - } - maven { url = 'https://repo.spongepowered.org/repository/maven-public' } - maven { url = 'https://maven.parchmentmc.org' } - } - - plugins { - id 'dev.architectury.loom' version arch_loom_version - } -} - -rootProject.name = 'Flywheel' - -include('common') -include('fabric') -include('forge') diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 000000000..cf8fd7a12 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,25 @@ +pluginManagement { + repositories { + gradlePluginPortal() + mavenCentral() + maven("https://maven.minecraftforge.net/") { + name = "MinecraftForge" + } + maven("https://maven.architectury.dev/") { + name = "Architectury" + } + maven("https://repo.spongepowered.org/repository/maven-public") + maven("https://maven.parchmentmc.org") + } + + plugins { + val arch_loom_version: String by settings + id("dev.architectury.loom") version arch_loom_version + } +} + +rootProject.name = "Flywheel" + +include("common") +include("fabric") +include("forge")