|
| 1 | +import com.matthewprenger.cursegradle.CurseArtifact |
| 2 | +import com.matthewprenger.cursegradle.CurseProject |
| 3 | +import com.matthewprenger.cursegradle.CurseRelation |
| 4 | +import com.matthewprenger.cursegradle.Options |
| 5 | +import net.fabricmc.loom.task.RemapJarTask |
| 6 | + |
| 7 | +plugins { |
| 8 | + java |
| 9 | + `java-library` |
| 10 | + id("com.diffplug.spotless") version "6.1.2" |
| 11 | + id ("com.github.node-gradle.node") version "3.0.1" |
| 12 | + id ("com.github.johnrengelman.shadow") version "7.1.2" |
| 13 | + id ("fabric-loom") version "1.1-SNAPSHOT" |
| 14 | + id ("com.modrinth.minotaur") version "2.+" |
| 15 | + id ("com.matthewprenger.cursegradle") version "1.4.0" |
| 16 | +} |
| 17 | + |
| 18 | +group = "de.bluecolored.bluemap.fabric" |
| 19 | +version = System.getProperty("bluemap.version") ?: "?" // set by BlueMapCore |
| 20 | + |
| 21 | +val javaTarget = 17 |
| 22 | +java { |
| 23 | + sourceCompatibility = JavaVersion.toVersion(javaTarget) |
| 24 | + targetCompatibility = JavaVersion.toVersion(javaTarget) |
| 25 | + |
| 26 | + withSourcesJar() |
| 27 | +} |
| 28 | + |
| 29 | +repositories { |
| 30 | + mavenCentral() |
| 31 | + maven { |
| 32 | + setUrl("https://libraries.minecraft.net") |
| 33 | + } |
| 34 | + maven { |
| 35 | + setUrl("https://jitpack.io") |
| 36 | + } |
| 37 | + maven { |
| 38 | + setUrl("https://maven.fabricmc.net/") |
| 39 | + } |
| 40 | + maven { |
| 41 | + setUrl("https://oss.sonatype.org/content/repositories/snapshots") |
| 42 | + } |
| 43 | +} |
| 44 | + |
| 45 | +val shadowInclude: Configuration by configurations.creating |
| 46 | + |
| 47 | +configurations { |
| 48 | + implementation.get().extendsFrom(shadowInclude) |
| 49 | +} |
| 50 | + |
| 51 | +dependencies { |
| 52 | + shadowInclude ("de.bluecolored.bluemap.common:BlueMapCommon") { |
| 53 | + //exclude dependencies provided by fabric |
| 54 | + exclude (group = "com.google.guava", module = "guava") |
| 55 | + exclude (group = "com.google.code.gson", module = "gson") |
| 56 | + exclude (group = "org.apache.commons", module = "commons-lang3") |
| 57 | + exclude (group = "commons-io", module = "commons-io") |
| 58 | + exclude (group = "com.mojang", module = "brigadier") |
| 59 | + } |
| 60 | + |
| 61 | + minecraft ("com.mojang:minecraft:1.19.4") |
| 62 | + mappings ("net.fabricmc:yarn:1.19.4+build.1") |
| 63 | + modImplementation ("net.fabricmc:fabric-loader:0.14.17") |
| 64 | + modImplementation ("net.fabricmc.fabric-api:fabric-api:0.75.3+1.19.4") |
| 65 | + modImplementation("me.lucko:fabric-permissions-api:0.1-SNAPSHOT") |
| 66 | + |
| 67 | + testImplementation ("org.junit.jupiter:junit-jupiter:5.9.0") |
| 68 | + testRuntimeOnly ("org.junit.jupiter:junit-jupiter-engine:5.9.0") |
| 69 | +} |
| 70 | + |
| 71 | +spotless { |
| 72 | + java { |
| 73 | + target ("src/*/java/**/*.java") |
| 74 | + |
| 75 | + licenseHeaderFile("../../HEADER") |
| 76 | + indentWithSpaces() |
| 77 | + trimTrailingWhitespace() |
| 78 | + } |
| 79 | +} |
| 80 | + |
| 81 | +tasks.withType(JavaCompile::class).configureEach { |
| 82 | + options.apply { |
| 83 | + encoding = "utf-8" |
| 84 | + } |
| 85 | +} |
| 86 | + |
| 87 | +tasks.withType(AbstractArchiveTask::class).configureEach { |
| 88 | + isReproducibleFileOrder = true |
| 89 | + isPreserveFileTimestamps = false |
| 90 | +} |
| 91 | + |
| 92 | +tasks.test { |
| 93 | + useJUnitPlatform() |
| 94 | +} |
| 95 | + |
| 96 | +tasks.processResources { |
| 97 | + inputs.property ("version", project.version) |
| 98 | + |
| 99 | + filesMatching("fabric.mod.json") { |
| 100 | + expand ("version" to project.version) |
| 101 | + } |
| 102 | +} |
| 103 | + |
| 104 | +tasks.shadowJar { |
| 105 | + configurations = listOf(shadowInclude) |
| 106 | + |
| 107 | + //relocate ("com.flowpowered.math", "de.bluecolored.shadow.flowpowered.math") //DON"T relocate this, because the API depends on it |
| 108 | + relocate ("com.typesafe.config", "de.bluecolored.shadow.typesafe.config") |
| 109 | + relocate ("net.querz.nbt", "de.bluecolored.shadow.querz.nbt") |
| 110 | + relocate ("org.spongepowered.configurate", "de.bluecolored.shadow.configurate") |
| 111 | + relocate ("com.github.benmanes.caffeine", "de.bluecolored.shadow.benmanes.caffeine") |
| 112 | + relocate ("org.aopalliance", "de.bluecolored.shadow.aopalliance") |
| 113 | + relocate ("javax.inject", "de.bluecolored.shadow.javax.inject") |
| 114 | + relocate ("org.checkerframework", "de.bluecolored.shadow.checkerframework") |
| 115 | + relocate ("org.codehaus", "de.bluecolored.shadow.codehaus") |
| 116 | + relocate ("io.leangen.geantyref", "de.bluecolored.shadow.geantyref") |
| 117 | + |
| 118 | + relocate ("com.google.errorprone", "de.bluecolored.shadow.google.errorprone") |
| 119 | + relocate ("com.google.inject", "de.bluecolored.shadow.google.inject") |
| 120 | + |
| 121 | + relocate ("org.apache.commons.dbcp2", "de.bluecolored.shadow.apache.commons.dbcp2") |
| 122 | + relocate ("org.apache.commons.logging", "de.bluecolored.shadow.apache.commons.logging") |
| 123 | + relocate ("org.apache.commons.pool2", "de.bluecolored.shadow.apache.commons.pool2") |
| 124 | +} |
| 125 | + |
| 126 | +tasks.register("remappedShadowJar", type = RemapJarTask::class) { |
| 127 | + destinationDirectory.set(file("../../build/release")) |
| 128 | + archiveFileName.set("BlueMap-${project.version}-${project.name}.jar") |
| 129 | + dependsOn (tasks.shadowJar) |
| 130 | + inputFile.set(tasks.shadowJar.get().archiveFile) |
| 131 | + addNestedDependencies.set(true) |
| 132 | +} |
| 133 | + |
| 134 | +tasks.register("release") { |
| 135 | + dependsOn("remappedShadowJar") |
| 136 | +} |
| 137 | + |
| 138 | +modrinth { |
| 139 | + token.set(System.getenv("MODRINTH_TOKEN")) |
| 140 | + projectId.set("swbUV1cr") |
| 141 | + versionNumber.set("${project.version}-${project.name}") |
| 142 | + changelog.set("Releasenotes and Changelog:\nhttps://github.com/BlueMap-Minecraft/BlueMap/releases/tag/v${project.version}") |
| 143 | + uploadFile.set(tasks.findByName("remappedShadowJar")) |
| 144 | + gameVersions.addAll("1.19.4") |
| 145 | + dependencies { |
| 146 | + required.project("P7dR8mSH") // Fabric API |
| 147 | + } |
| 148 | +} |
| 149 | + |
| 150 | +curseforge { |
| 151 | + apiKey = System.getenv("CURSEFORGE_TOKEN") ?: "" |
| 152 | + project(closureOf<CurseProject> { |
| 153 | + id = "406463" |
| 154 | + changelogType = "markdown" |
| 155 | + changelog = "**Releasenotes and Changelog:**\n\nhttps://github.com/BlueMap-Minecraft/BlueMap/releases/tag/v${project.version}" |
| 156 | + releaseType = "release" |
| 157 | + |
| 158 | + addGameVersion("Fabric") |
| 159 | + |
| 160 | + addGameVersion("Java 18") |
| 161 | + addGameVersion("Java 17") |
| 162 | + |
| 163 | + addGameVersion("1.19.4") |
| 164 | + |
| 165 | + mainArtifact(tasks.findByName("remappedShadowJar"), closureOf<CurseArtifact> { |
| 166 | + relations(closureOf<CurseRelation> { |
| 167 | + requiredDependency("fabric-api") |
| 168 | + }) |
| 169 | + }) |
| 170 | + }) |
| 171 | + options(closureOf<Options> { |
| 172 | + javaVersionAutoDetect = false |
| 173 | + javaIntegration = false |
| 174 | + forgeGradleIntegration = false |
| 175 | + }) |
| 176 | +} |
| 177 | + |
| 178 | +tasks.register("publish") { |
| 179 | + dependsOn("modrinth") |
| 180 | + dependsOn("curseforge") |
| 181 | +} |
0 commit comments