|
| 1 | +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar |
| 2 | + |
| 3 | +plugins { |
| 4 | + id 'com.gradleup.shadow' version '9.4.1' |
| 5 | + id 'java' |
| 6 | + id 'maven-publish' |
| 7 | + id 'xyz.wagyourtail.unimined' version '1.4.2-SNAPSHOT' |
| 8 | +} |
| 9 | + |
| 10 | +group 'me.earth' |
| 11 | +version "$minecraft_version-${project(':api').project_version}" |
| 12 | + |
| 13 | +base { |
| 14 | + archivesName = 'mc-runtime-test' |
| 15 | +} |
| 16 | + |
| 17 | +sourceSets { |
| 18 | + fabric |
| 19 | + neoforge |
| 20 | + lexforge |
| 21 | +} |
| 22 | + |
| 23 | +repositories { |
| 24 | + mavenCentral() |
| 25 | + maven { |
| 26 | + url = "https://maven.neoforged.net/releases" |
| 27 | + } |
| 28 | + maven { |
| 29 | + url = "https://maven.fabricmc.net/" |
| 30 | + } |
| 31 | + maven { |
| 32 | + url = "https://files.minecraftforge.net/maven" |
| 33 | + } |
| 34 | + maven { |
| 35 | + name = "sponge" |
| 36 | + url = "https://repo.spongepowered.org/maven" |
| 37 | + } |
| 38 | + maven { |
| 39 | + url = "https://maven.wagyourtail.xyz/releases" |
| 40 | + } |
| 41 | + |
| 42 | + maven { |
| 43 | + name = '3arthMaven' |
| 44 | + url = 'https://3arthqu4ke.github.io/maven' |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | +unimined.minecraft { |
| 49 | + version project.minecraft_version |
| 50 | + |
| 51 | + mappings { |
| 52 | + mojmap() |
| 53 | + // intermediary() |
| 54 | + // yarn(1) |
| 55 | + |
| 56 | + devFallbackNamespace "mojmap" |
| 57 | + |
| 58 | + /*stub.withMappings("intermediary", ["yarn"]) { |
| 59 | + c("net/minecraft/class_1927", []) { |
| 60 | + m("method_55109", "()Lnet/minecraft/class_243;", ["getPos"]) |
| 61 | + } |
| 62 | + }*/ |
| 63 | + } |
| 64 | + |
| 65 | + defaultRemapJar = false |
| 66 | +} |
| 67 | + |
| 68 | +unimined.minecraft(sourceSets.fabric) { |
| 69 | + combineWith(sourceSets.main) |
| 70 | + |
| 71 | + fabric { |
| 72 | + loader project.fabric_version |
| 73 | + } |
| 74 | + |
| 75 | + defaultRemapJar = true |
| 76 | +} |
| 77 | + |
| 78 | +unimined.minecraft(sourceSets.neoforge) { |
| 79 | + combineWith(sourceSets.main) |
| 80 | + |
| 81 | + neoForged { |
| 82 | + loader project.neoforge_version |
| 83 | + mixinConfig 'mc_runtime_test.mixins.json' |
| 84 | + } |
| 85 | + |
| 86 | + minecraftRemapper.config { |
| 87 | + // neoforge adds 1 conflict, where 2 interfaces have a method with the same name on yarn/mojmap, |
| 88 | + // but the method has different names in the intermediary mappings. |
| 89 | + // this is a conflict because they have a class that extends both interfaces. |
| 90 | + // this shouldn't be a problem as long as named mappings don't make the name of those 2 methods different. |
| 91 | + ignoreConflicts(true) |
| 92 | + } |
| 93 | + |
| 94 | + defaultRemapJar = true |
| 95 | +} |
| 96 | + |
| 97 | +unimined.minecraft(sourceSets.lexforge) { |
| 98 | + combineWith(sourceSets.main) |
| 99 | + |
| 100 | + minecraftForge { |
| 101 | + loader project.lexforge_version |
| 102 | + mixinConfig 'mc_runtime_test.mixins.json' |
| 103 | + } |
| 104 | + |
| 105 | + minecraftRemapper.config { |
| 106 | + ignoreConflicts(true) |
| 107 | + } |
| 108 | + |
| 109 | + defaultRemapJar = true |
| 110 | +} |
| 111 | + |
| 112 | +configurations { |
| 113 | + mainImplementation |
| 114 | + lwjglAgent.extendsFrom runtimeOnly |
| 115 | + jarLibs |
| 116 | + implementation.extendsFrom jarLibs |
| 117 | +} |
| 118 | + |
| 119 | +for (String platform_capitalized : ['Fabric', 'Neoforge', 'Lexforge']) { |
| 120 | + def platform = platform_capitalized.toLowerCase() |
| 121 | + def remapJarTask = tasks.named("remap${platform_capitalized}Jar", AbstractArchiveTask).get() |
| 122 | + def shadowTask = tasks.register("${platform}ShadowJar", ShadowJar) { |
| 123 | + dependsOn(remapJarTask) |
| 124 | + it.group = 'build' |
| 125 | + it.archiveClassifier = "${platform}-release" |
| 126 | + from { zipTree(remapJarTask.archiveFile.get().asFile) } |
| 127 | + it.configurations.add(project.configurations.jarLibs) |
| 128 | + exclude "**/module-info.class" |
| 129 | + } |
| 130 | + tasks.named('build') { finalizedBy(shadowTask) } |
| 131 | +} |
| 132 | + |
| 133 | +dependencies { |
| 134 | + compileOnly 'org.spongepowered:mixin:0.8.5-SNAPSHOT' |
| 135 | + compileOnly 'me.earth.headlessmc:headlessmc:1.8.1' |
| 136 | + lwjglAgent 'me.earth.headlessmc:headlessmc-lwjgl:1.8.1' |
| 137 | + // yes, I actually want this at runtime to use assertions! |
| 138 | + jarLibs 'org.junit.jupiter:junit-jupiter-api:5.10.1' |
| 139 | + jarLibs project(':api') |
| 140 | +} |
| 141 | + |
| 142 | +afterEvaluate { |
| 143 | + fabricRunClient { |
| 144 | + standardInput = System.in |
| 145 | + if (rootProject.property('hmc.lwjgl').toBoolean()) { |
| 146 | + jvmArgs += ["-javaagent:${configurations.lwjglAgent.files.iterator().next()}"] |
| 147 | + systemProperties['joml.nounsafe'] = 'true' |
| 148 | + systemProperties['fabric.systemLibraries'] = "${configurations.lwjglAgent.files.iterator().next()}" |
| 149 | + } |
| 150 | + } |
| 151 | +} |
| 152 | + |
| 153 | +processFabricResources { |
| 154 | + inputs.property "version", project.version |
| 155 | + |
| 156 | + filesMatching("fabric.mod.json") { |
| 157 | + expand "version": project.version |
| 158 | + } |
| 159 | +} |
| 160 | + |
| 161 | +processNeoforgeResources { |
| 162 | + inputs.property "version", project.version |
| 163 | + |
| 164 | + filesMatching("META-INF/neoforge.mods.toml") { |
| 165 | + expand "version": project.version |
| 166 | + } |
| 167 | +} |
| 168 | + |
| 169 | +processLexforgeResources { |
| 170 | + inputs.property "version", project.version |
| 171 | + |
| 172 | + filesMatching("META-INF/mods.toml") { |
| 173 | + expand "version": project.version |
| 174 | + } |
| 175 | +} |
| 176 | + |
| 177 | +// Forge Runs seem to have problems running from the build/classes folder |
| 178 | +// So instead we just run from the built jar |
| 179 | +afterEvaluate { |
| 180 | + lexforgeRunClient { |
| 181 | + dependsOn(lexforgeJar) |
| 182 | + classpath = classpath.filter { |
| 183 | + !it.toString().contains('mc-runtime-test/build/classes/java/'.replace('/', File.separator)) |
| 184 | + && !it.toString().contains('mc-runtime-test/build/resources/'.replace('/', File.separator)) |
| 185 | + } |
| 186 | + |
| 187 | + classpath += files("${projectDir}/build/libs/mc-runtime-test-${version}-lexforge-dev.jar".replace('/', File.separator)) |
| 188 | + } |
| 189 | + |
| 190 | + neoforgeRunClient { |
| 191 | + dependsOn(neoforgeJar) |
| 192 | + classpath = classpath.filter { |
| 193 | + !it.toString().contains('mc-runtime-test/build/classes/java/'.replace('/', File.separator)) |
| 194 | + && !it.toString().contains('mc-runtime-test/build/resources/'.replace('/', File.separator)) |
| 195 | + } |
| 196 | + |
| 197 | + classpath += files("${projectDir}/build/libs/mc-runtime-test-${version}-neoforge-dev.jar".replace('/', File.separator)) |
| 198 | + } |
| 199 | +} |
| 200 | + |
| 201 | +tasks.withType(org.gradle.jvm.tasks.Jar).configureEach { |
| 202 | + from("LICENSE") { |
| 203 | + duplicatesStrategy = DuplicatesStrategy.INCLUDE |
| 204 | + rename { "${it}_${project.archivesBaseName}" } |
| 205 | + } |
| 206 | + |
| 207 | + manifest { |
| 208 | + attributes( |
| 209 | + 'Implementation-Title': 'MC-Runtime-Test', |
| 210 | + 'MixinConfigs': "mc_runtime_test.mixins.json", |
| 211 | + 'Implementation-Version': project.version, |
| 212 | + ) |
| 213 | + } |
| 214 | +} |
| 215 | + |
| 216 | +afterEvaluate { |
| 217 | + publishing { |
| 218 | + publications { |
| 219 | + "${name.toLowerCase()}"(MavenPublication) { |
| 220 | + ((MavenPublication) it).groupId "${group}" |
| 221 | + ((MavenPublication) it).artifactId "${base.archivesName.get().toLowerCase()}" |
| 222 | + ((MavenPublication) it).version "${version}" |
| 223 | + from components.java |
| 224 | + for (String platform: ['Fabric', 'Lexforge', 'Neoforge']) { |
| 225 | + String platform_lower = platform.toLowerCase() |
| 226 | + artifact tasks.named("${platform_lower}Jar").get() |
| 227 | + artifact tasks.named("remap${platform}Jar").get() |
| 228 | + artifact tasks.named("${platform_lower}ShadowJar").get() |
| 229 | + } |
| 230 | + } |
| 231 | + } |
| 232 | + |
| 233 | + repositories { |
| 234 | + if (System.getenv('DEPLOY_TO_GITHUB_PACKAGES_URL') == null) { |
| 235 | + maven { |
| 236 | + name = 'BuildDirMaven' |
| 237 | + url = rootProject.projectDir.toPath().parent.resolve('build').resolve('maven') |
| 238 | + } |
| 239 | + } else { |
| 240 | + maven { |
| 241 | + name = 'GithubPagesMaven' |
| 242 | + url = System.getenv('DEPLOY_TO_GITHUB_PACKAGES_URL') |
| 243 | + credentials { |
| 244 | + username = System.getenv('GITHUB_USER') |
| 245 | + password = System.getenv('GITHUB_TOKEN') |
| 246 | + } |
| 247 | + } |
| 248 | + } |
| 249 | + } |
| 250 | + } |
| 251 | +} |
0 commit comments