|
| 1 | +buildscript { |
| 2 | + repositories { |
| 3 | + // These repositories are only for Gradle plugins, put any other repositories in the repository block further below |
| 4 | + maven { url = 'https://maven.minecraftforge.net' } |
| 5 | + mavenCentral() |
| 6 | + } |
| 7 | + dependencies { |
| 8 | + classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true |
| 9 | + } |
| 10 | +} |
| 11 | + |
| 12 | +plugins { |
| 13 | + id "java" |
| 14 | + id "java-library" |
| 15 | + id "com.diffplug.spotless" version "6.1.2" |
| 16 | + id "com.github.node-gradle.node" version "3.0.1" |
| 17 | + id "com.github.johnrengelman.shadow" version "7.1.2" |
| 18 | +} |
| 19 | + |
| 20 | +apply plugin: "net.minecraftforge.gradle" |
| 21 | + |
| 22 | +group = "de.bluecolored.bluemap.forge" |
| 23 | +version = System.getProperty("bluemap.version") ?: "?" // set by BlueMapCore |
| 24 | +archivesBaseName = 'bluemap' |
| 25 | + |
| 26 | +def javaTarget = 17 |
| 27 | +java { |
| 28 | + sourceCompatibility = JavaVersion.toVersion(javaTarget) |
| 29 | + targetCompatibility = JavaVersion.toVersion(javaTarget) |
| 30 | +} |
| 31 | + |
| 32 | +minecraft { |
| 33 | + mappings channel: 'official', version: '1.19.1' |
| 34 | + |
| 35 | + runs { |
| 36 | + server { |
| 37 | + workingDirectory project.file('run') |
| 38 | + property 'forge.logging.markers', 'REGISTRIES' |
| 39 | + property 'forge.logging.console.level', 'debug' |
| 40 | + |
| 41 | + mods { |
| 42 | + bluemap { |
| 43 | + source sourceSets.main |
| 44 | + } |
| 45 | + } |
| 46 | + } |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +sourceSets.main.resources { srcDir 'src/generated/resources' } |
| 51 | + |
| 52 | +repositories { |
| 53 | + mavenCentral() |
| 54 | + maven { |
| 55 | + setUrl("https://libraries.minecraft.net") |
| 56 | + } |
| 57 | + maven { |
| 58 | + setUrl("https://jitpack.io") |
| 59 | + } |
| 60 | +} |
| 61 | + |
| 62 | +configurations { |
| 63 | + implementation.extendsFrom(shadowInclude) |
| 64 | +} |
| 65 | + |
| 66 | +dependencies { |
| 67 | + minecraft 'net.minecraftforge:forge:1.19.1-42.0.1' |
| 68 | + |
| 69 | + shadowInclude ("de.bluecolored.bluemap.common:BlueMapCommon") { |
| 70 | + //exclude dependencies provided by forge |
| 71 | + exclude (group: "com.google.guava", module: "guava") |
| 72 | + exclude (group: "com.google.code.gson", module: "gson") |
| 73 | + exclude (group: "org.apache.commons", module: "commons-lang3") |
| 74 | + exclude (group: "commons-io", module: "commons-io") |
| 75 | + exclude (group: "com.mojang", module: "brigadier") |
| 76 | + } |
| 77 | + |
| 78 | + testImplementation ("org.junit.jupiter:junit-jupiter:5.8.2") |
| 79 | + testRuntimeOnly ("org.junit.jupiter:junit-jupiter-engine:5.8.2") |
| 80 | +} |
| 81 | + |
| 82 | +spotless { |
| 83 | + java { |
| 84 | + target ("src/*/java/**/*.java") |
| 85 | + |
| 86 | + licenseHeaderFile("../../HEADER") |
| 87 | + indentWithSpaces() |
| 88 | + trimTrailingWhitespace() |
| 89 | + } |
| 90 | +} |
| 91 | + |
| 92 | +jar { |
| 93 | + manifest { |
| 94 | + attributes([ |
| 95 | + "Specification-Title" : "bluemap", |
| 96 | + "Specification-Vendor" : "bluemap", |
| 97 | + "Specification-Version" : "1", // We are version 1 of ourselves |
| 98 | + "Implementation-Title" : project.name, |
| 99 | + "Implementation-Version" : project.jar.archiveVersion, |
| 100 | + "Implementation-Vendor" : "bluemap", |
| 101 | + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") |
| 102 | + ]) |
| 103 | + } |
| 104 | +} |
| 105 | + |
| 106 | +jar.finalizedBy('reobfJar') |
| 107 | + |
| 108 | +tasks.withType(JavaCompile).configureEach { |
| 109 | + options.encoding = "utf-8" |
| 110 | +} |
| 111 | + |
| 112 | +tasks.withType(AbstractArchiveTask).configureEach { |
| 113 | + setReproducibleFileOrder(true) |
| 114 | + setPreserveFileTimestamps(false) |
| 115 | +} |
| 116 | + |
| 117 | +test { |
| 118 | + useJUnitPlatform() |
| 119 | +} |
| 120 | + |
| 121 | +shadowJar { |
| 122 | + def version = System.getProperty("bluemap.version") ?: "" // set by BlueMapCore |
| 123 | + destinationDirectory.set(file("../../build/release")) |
| 124 | + archiveFileName.set("BlueMap-${project.version}-${project.name}.jar") |
| 125 | + |
| 126 | + configurations = [project.configurations.shadowInclude] |
| 127 | + |
| 128 | + //relocate ("com.flowpowered.math", "de.bluecolored.shadow.flowpowered.math") //DON"T relocate this, because the API depends on it |
| 129 | + relocate ("com.typesafe.config", "de.bluecolored.shadow.typesafe.config") |
| 130 | + relocate ("net.querz.nbt", "de.bluecolored.shadow.querz.nbt") |
| 131 | + relocate ("org.spongepowered.configurate", "de.bluecolored.shadow.configurate") |
| 132 | + relocate ("com.github.benmanes.caffeine", "de.bluecolored.shadow.benmanes.caffeine") |
| 133 | + relocate ("org.aopalliance", "de.bluecolored.shadow.aopalliance") |
| 134 | + relocate ("javax.inject", "de.bluecolored.shadow.javax.inject") |
| 135 | + relocate ("org.checkerframework", "de.bluecolored.shadow.checkerframework") |
| 136 | + relocate ("org.codehaus", "de.bluecolored.shadow.codehaus") |
| 137 | + relocate ("io.leangen.geantyref", "de.bluecolored.shadow.geantyref") |
| 138 | + |
| 139 | + relocate ("com.google.errorprone", "de.bluecolored.shadow.google.errorprone") |
| 140 | + relocate ("com.google.inject", "de.bluecolored.shadow.google.inject") |
| 141 | + |
| 142 | + relocate ("org.apache.commons.dbcp2", "de.bluecolored.shadow.apache.commons.dbcp2") |
| 143 | + relocate ("org.apache.commons.logging", "de.bluecolored.shadow.apache.commons.logging") |
| 144 | + relocate ("org.apache.commons.pool2", "de.bluecolored.shadow.apache.commons.pool2") |
| 145 | +} |
| 146 | + |
| 147 | +processResources { |
| 148 | + from(sourceSets.main.resources.srcDirs) { |
| 149 | + include 'mcmod.info','META-INF/mods.toml' |
| 150 | + duplicatesStrategy = DuplicatesStrategy.WARN |
| 151 | + |
| 152 | + expand ( |
| 153 | + version: project.version |
| 154 | + ) |
| 155 | + } |
| 156 | +} |
| 157 | + |
| 158 | +afterEvaluate { |
| 159 | + reobf { |
| 160 | + shadowJar { |
| 161 | + mappings = createMcpToSrg.output |
| 162 | + } |
| 163 | + } |
| 164 | +} |
| 165 | + |
| 166 | +task release { |
| 167 | + dependsOn(build) |
| 168 | +} |
0 commit comments