|
| 1 | +plugins { |
| 2 | + id("fabric-loom") version "1.15-SNAPSHOT" |
| 3 | + id("maven-publish") |
| 4 | + id("me.modmuss50.mod-publish-plugin") version "1.1.0" |
| 5 | +} |
| 6 | + |
| 7 | +version = "${project.property("mod_version")}+${stonecutter.current.version}" |
| 8 | +group = project.property("maven_group")!! |
| 9 | + |
| 10 | +base { |
| 11 | + archivesName.set(project.property("archives_base_name") as String) |
| 12 | +} |
| 13 | + |
| 14 | +loom { |
| 15 | + splitEnvironmentSourceSets() |
| 16 | + |
| 17 | + mods { |
| 18 | + create("redstonetools", Action { |
| 19 | + sourceSet(sourceSets.main.get()) |
| 20 | + sourceSet("client") |
| 21 | + }) |
| 22 | + } |
| 23 | +} |
| 24 | + |
| 25 | +stonecutter { |
| 26 | + swaps["mouse_clicked_params"] = if (current.parsed < "1.21.10") "double mouseX, double mouseY, int button" else "Click click, boolean doubleClick" // mouseClicked |
| 27 | + swaps["mouse_clicked_args"] = if (current.parsed < "1.21.10") "mouseX, mouseY, button" else "click, doubleClick" |
| 28 | + swaps["on_mouse_clicked_args"] = if (current.parsed < "1.21.10") "(int) mouseX, (int) mouseY, button" else "click, doubleClick" // onMouseClicked |
| 29 | + swaps["dragged_released_params"] = if (current.parsed < "1.21.10") "double mouseX, double mouseY, int button" else "Click click" // mouseDragged, mouseReleased |
| 30 | + swaps["dragged_released_args"] = if (current.parsed < "1.21.10") "mouseX, mouseY, button" else "click" |
| 31 | + swaps["on_released_args"] = if (current.parsed < "1.21.10") "(int) mouseX, (int) mouseY, button" else "click" // onMouseReleased |
| 32 | + swaps["keyinput_params"] = if (current.parsed < "1.21.10") "int keyCode, int scanCode, int modifiers" else "KeyInput input" // keyPressed, keyReleased |
| 33 | + swaps["keyinput_args"] = if (current.parsed < "1.21.10") "keyCode, scanCode, modifiers" else "input" |
| 34 | + swaps["charinput_params"] = if (current.parsed < "1.21.10") "char chr, int modifiers" else "CharInput input" // charTyped |
| 35 | + swaps["charinput_args"] = if (current.parsed < "1.21.10") "chr, modifiers" else "input" |
| 36 | + swaps["click_and_inputs_imports"] = if (current.parsed < "1.21.10") "" else |
| 37 | + "//\nimport net.minecraft.client.gui.Click;\nimport net.minecraft.client.input.KeyInput;\nimport net.minecraft.client.input.CharInput;" |
| 38 | + |
| 39 | +} |
| 40 | + |
| 41 | +repositories { |
| 42 | + exclusiveContent { |
| 43 | + forRepository { |
| 44 | + maven { |
| 45 | + name = "Modrinth" |
| 46 | + url = uri("https://api.modrinth.com/maven") |
| 47 | + } |
| 48 | + } |
| 49 | + filter { |
| 50 | + includeGroup("maven.modrinth") |
| 51 | + } |
| 52 | + } |
| 53 | + maven { |
| 54 | + name = "WorldEdit Maven" |
| 55 | + url = uri("https://maven.enginehub.org/repo/") |
| 56 | + } |
| 57 | +} |
| 58 | + |
| 59 | +dependencies { |
| 60 | + minecraft("com.mojang:minecraft:${project.property("minecraft_version")}") |
| 61 | + mappings("net.fabricmc:yarn:${project.property("yarn_mappings")}:v2") |
| 62 | + modImplementation("net.fabricmc:fabric-loader:${project.property("loader_version")}") |
| 63 | + modImplementation("net.fabricmc.fabric-api:fabric-api:${project.property("fabric_version")}") |
| 64 | + modImplementation("com.sk89q.worldedit:worldedit-fabric-mc${project.property("worldedit_version")}") |
| 65 | + modApi("maven.modrinth:malilib:${project.property("malilib_version")}") |
| 66 | +} |
| 67 | + |
| 68 | +loom { |
| 69 | + decompilerOptions.named("vineflower") { |
| 70 | + options.put("mark-corresponding-synthetics", "1") |
| 71 | + } |
| 72 | + |
| 73 | + runConfigs.configureEach { |
| 74 | + ideConfigGenerated(true) |
| 75 | + runDir = "../../run" |
| 76 | + } |
| 77 | +} |
| 78 | + |
| 79 | +tasks.processResources { |
| 80 | + val properties = mapOf( |
| 81 | + "version" to project.version, |
| 82 | + "minecraft_version" to project.property("minecraft_version"), |
| 83 | + "minecraft_version_out" to project.property("minecraft_version_out"), |
| 84 | + "malilib_version" to project.property("minecraft_version_out"), |
| 85 | + "loader_version" to project.property("loader_version") |
| 86 | + ) |
| 87 | + properties.forEach { inputs.property(it.key, it.value) } |
| 88 | + filteringCharset = "UTF-8" |
| 89 | + |
| 90 | + filesMatching("fabric.mod.json") { |
| 91 | + expand(properties) |
| 92 | + } |
| 93 | +} |
| 94 | + |
| 95 | +tasks.register<DefaultTask>("collectFile") { |
| 96 | + group = "build" |
| 97 | + mustRunAfter("build") |
| 98 | + |
| 99 | + doLast { |
| 100 | + copy { |
| 101 | + from( |
| 102 | + file( |
| 103 | + "build/libs/${project.property("archives_base_name")}-${project.property("mod_version")}+${project.property("minecraft_version")}.jar" |
| 104 | + ) |
| 105 | + ) |
| 106 | + into(rootProject.file("build/libs")) |
| 107 | + } |
| 108 | + } |
| 109 | +} |
| 110 | + |
| 111 | +tasks.register<DefaultTask>("buildAndCollect") { |
| 112 | + group = "build" |
| 113 | + dependsOn(tasks.named("build"), tasks.named("collectFile")) |
| 114 | +} |
| 115 | + |
| 116 | +tasks.withType<JavaCompile>().configureEach { |
| 117 | + options.encoding = "UTF-8" |
| 118 | + options.release = 21 |
| 119 | +} |
| 120 | + |
| 121 | +java { |
| 122 | + toolchain.languageVersion = JavaLanguageVersion.of(21) |
| 123 | + withSourcesJar() |
| 124 | +} |
| 125 | + |
| 126 | +tasks.jar { |
| 127 | + from("LICENSE") { |
| 128 | + rename { "${it}_${project.property("archives_base_name")}" } |
| 129 | + } |
| 130 | +} |
| 131 | + |
| 132 | +publishing { |
| 133 | + publications { |
| 134 | + create<MavenPublication>("mavenJava") { |
| 135 | + artifactId = project.property("archives_base_name") as String |
| 136 | + from(components["java"]) |
| 137 | + } |
| 138 | + } |
| 139 | + repositories { |
| 140 | + } |
| 141 | +} |
| 142 | + |
| 143 | +publishMods { |
| 144 | + file.set(tasks.remapJar.get().archiveFile) |
| 145 | + type.set(STABLE) |
| 146 | + modLoaders.add("fabric") |
| 147 | + |
| 148 | + changelog.set("") |
| 149 | + displayName.set(project.property("mod_version") as String) |
| 150 | + |
| 151 | + if (providers.environmentVariable("RELEASE_MODRINTH").orNull?.toBoolean() ?: false) { |
| 152 | + modrinth { |
| 153 | + accessToken.set(providers.environmentVariable("MODRINTH_TOKEN")) |
| 154 | + projectId.set("9ySQVrz2") |
| 155 | + minecraftVersions.add(project.property("minecraft_version") as String) |
| 156 | + |
| 157 | + requires("fabric-api") |
| 158 | + requires("malilib") |
| 159 | + optional("worldedit") |
| 160 | + } |
| 161 | + } |
| 162 | + |
| 163 | + if (providers.environmentVariable("RELEASE_GITHUB").orNull?.toBoolean() ?: false) { |
| 164 | + github { |
| 165 | + accessToken.set(providers.environmentVariable("GITHUB_TOKEN")) |
| 166 | + parent(rootProject.tasks.named("publishGithub")) |
| 167 | + } |
| 168 | + } |
| 169 | +} |
0 commit comments