|
| 1 | +plugins { |
| 2 | + id 'java' |
| 3 | + id 'java-library' |
| 4 | + id 'maven-publish' |
| 5 | + id 'com.gradleup.shadow' version '9.0.2' |
| 6 | + id 'xyz.wagyourtail.unimined' version '1.4.1' |
| 7 | + id 'net.kyori.blossom' version '2.1.0' |
| 8 | +} |
| 9 | + |
| 10 | +apply from: 'gradle/scripts/helpers.gradle' |
| 11 | + |
| 12 | +// Early Assertions |
| 13 | +assertProperty 'mod_version' |
| 14 | +assertProperty 'root_package' |
| 15 | +assertProperty 'mod_id' |
| 16 | +assertProperty 'mod_name' |
| 17 | + |
| 18 | +assertSubProperties 'use_access_transformer', 'access_transformer_locations' |
| 19 | +assertSubProperties 'is_coremod', 'coremod_includes_mod', 'coremod_plugin_class_name' |
| 20 | +assertSubProperties 'use_asset_mover', 'asset_mover_version' |
| 21 | + |
| 22 | +setDefaultProperty 'generate_sources_jar', true, false |
| 23 | +setDefaultProperty 'generate_javadocs_jar', true, false |
| 24 | +setDefaultProperty 'minecraft_username', true, 'Developer' |
| 25 | +setDefaultProperty 'extra_jvm_args', false, '' |
| 26 | + |
| 27 | +version = propertyString('mod_version') |
| 28 | +group = propertyString('root_package') |
| 29 | + |
| 30 | +base { |
| 31 | + archivesName.set(propertyString('mod_id')) |
| 32 | +} |
| 33 | + |
| 34 | + |
| 35 | +java { |
| 36 | + toolchain { |
| 37 | + languageVersion.set(JavaLanguageVersion.of(21)) |
| 38 | + } |
| 39 | + if (propertyBool('generate_sources_jar')) { |
| 40 | + withSourcesJar() |
| 41 | + } |
| 42 | + if (propertyBool('generate_javadocs_jar')) { |
| 43 | + withJavadocJar() |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +configurations { |
| 48 | + embed |
| 49 | + contain |
| 50 | + implementation.extendsFrom(embed) |
| 51 | + implementation.extendsFrom(contain) |
| 52 | + modCompileOnly |
| 53 | + compileOnly.extendsFrom(modCompileOnly) |
| 54 | + modRuntimeOnly |
| 55 | + runtimeOnly.extendsFrom(modRuntimeOnly) |
| 56 | +} |
| 57 | + |
| 58 | +unimined.minecraft { |
| 59 | + version "1.12.2" |
| 60 | + |
| 61 | + mappings { |
| 62 | + mcp("stable", "39-1.12") |
| 63 | + } |
| 64 | + |
| 65 | + cleanroom { |
| 66 | + if (propertyBool('use_access_transformer')) { |
| 67 | + accessTransformer "${rootProject.projectDir}/src/main/resources/" + propertyString('access_transformer_locations') |
| 68 | + } |
| 69 | + loader "0.3.13-alpha" |
| 70 | + runs.auth.username = minecraft_username |
| 71 | + runs.all { |
| 72 | + var map = getSystemProperties() |
| 73 | + map.put("cleanroom.dev.mixin", "${mod_id}.default.mixin.json,${mod_id}.mod.mixin.json") |
| 74 | + def extraArgs = propertyString('extra_jvm_args') |
| 75 | + if (extraArgs != null && !extraArgs.trim().isEmpty()) { |
| 76 | + jvmArgs += extraArgs.split("\\s+").toList() |
| 77 | + } |
| 78 | + if (propertyBool('enable_foundation_debug')) { |
| 79 | + map.put("foundation.dump", "true") |
| 80 | + map.put("foundation.verbose", "true") |
| 81 | + } |
| 82 | + return |
| 83 | + } |
| 84 | + } |
| 85 | + |
| 86 | + defaultRemapJar = false |
| 87 | + |
| 88 | + if (propertyBool('enable_shadow')) { |
| 89 | + remap(tasks.shadowJar) { |
| 90 | + mixinRemap { |
| 91 | + enableBaseMixin() |
| 92 | + enableMixinExtra() |
| 93 | + disableRefmap() |
| 94 | + } |
| 95 | + } |
| 96 | + } else { |
| 97 | + remap(tasks.jar) { |
| 98 | + mixinRemap { |
| 99 | + enableBaseMixin() |
| 100 | + enableMixinExtra() |
| 101 | + disableRefmap() |
| 102 | + } |
| 103 | + } |
| 104 | + } |
| 105 | + |
| 106 | + mods { |
| 107 | + remap(configurations.modCompileOnly) |
| 108 | + } |
| 109 | +} |
| 110 | + |
| 111 | +dependencies { |
| 112 | + if (propertyBool('use_asset_mover')) { |
| 113 | + implementation "com.cleanroommc:assetmover:${propertyString('asset_mover_version')}" |
| 114 | + } |
| 115 | + if (propertyBool('enable_junit_testing')) { |
| 116 | + testImplementation 'org.junit.jupiter:junit-jupiter:5.7.1' |
| 117 | + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' |
| 118 | + } |
| 119 | +} |
| 120 | + |
| 121 | +apply from: 'gradle/scripts/dependencies.gradle' |
| 122 | + |
| 123 | +processResources { |
| 124 | + |
| 125 | + inputs.property 'mod_id', propertyString('mod_id') |
| 126 | + inputs.property 'mod_name', propertyString('mod_name') |
| 127 | + inputs.property 'mod_version', propertyString('mod_version') |
| 128 | + inputs.property 'mod_description', propertyString('mod_description') |
| 129 | + inputs.property 'mod_authors', "${propertyStringList('mod_authors', ',').join(', ')}" |
| 130 | + inputs.property 'mod_credits', propertyString('mod_credits') |
| 131 | + inputs.property 'mod_url', propertyString('mod_url') |
| 132 | + inputs.property 'mod_update_json', propertyString('mod_update_json') |
| 133 | + inputs.property 'mod_logo_path', propertyString('mod_logo_path') |
| 134 | + |
| 135 | + def filterList = ['mcmod.info', 'pack.mcmeta'] |
| 136 | + |
| 137 | + filesMatching(filterList) { fcd -> |
| 138 | + fcd.expand( |
| 139 | + 'mod_id': propertyString('mod_id'), |
| 140 | + 'mod_name': propertyString('mod_name'), |
| 141 | + 'mod_version': propertyString('mod_version'), |
| 142 | + 'mod_description': propertyString('mod_description'), |
| 143 | + 'mod_authors': "${propertyStringList('mod_authors', ',').join(', ')}", |
| 144 | + 'mod_credits': propertyString('mod_credits'), |
| 145 | + 'mod_url': propertyString('mod_url'), |
| 146 | + 'mod_update_json': propertyString('mod_update_json'), |
| 147 | + 'mod_logo_path': propertyString('mod_logo_path'), |
| 148 | + ) |
| 149 | + } |
| 150 | + |
| 151 | + rename '(.+_at.cfg)', 'META-INF/$1' |
| 152 | +} |
| 153 | + |
| 154 | +sourceSets { |
| 155 | + main { |
| 156 | + blossom { |
| 157 | + javaSources { |
| 158 | + property('mod_id', propertyString('mod_id')) |
| 159 | + property('mod_name', propertyString('mod_name')) |
| 160 | + property('mod_version', propertyString('mod_version')) |
| 161 | + property('package', "${root_package}.${mod_id}") |
| 162 | + } |
| 163 | + } |
| 164 | + } |
| 165 | +} |
| 166 | + |
| 167 | +if (!propertyBool('enable_shadow')) { |
| 168 | + shadowJar.enabled = false |
| 169 | +} |
| 170 | + |
| 171 | +jar { |
| 172 | + duplicatesStrategy = DuplicatesStrategy.EXCLUDE |
| 173 | + if (configurations.contain.size() > 0) { |
| 174 | + into('/') { |
| 175 | + from configurations.contain |
| 176 | + } |
| 177 | + } |
| 178 | + doFirst { |
| 179 | + manifest { |
| 180 | + def attribute_map = [:] |
| 181 | + attribute_map['ModType'] = "CRL" |
| 182 | + attribute_map['MixinConfigs'] = "${mod_id}.default.mixin.json,${mod_id}.mod.mixin.json" |
| 183 | + if (configurations.contain.size() > 0) { |
| 184 | + attribute_map['ContainedDeps'] = configurations.contain.collect { it.name }.join(' ') |
| 185 | + attribute_map['NonModDeps'] = true |
| 186 | + } |
| 187 | + if (propertyBool('is_coremod')) { |
| 188 | + attribute_map['FMLCorePlugin'] = propertyString('coremod_plugin_class_name') |
| 189 | + if (propertyBool('coremod_includes_mod')) { |
| 190 | + attribute_map['FMLCorePluginContainsFMLMod'] = true |
| 191 | + } |
| 192 | + } |
| 193 | + if (propertyBool('use_access_transformer')) { |
| 194 | + attribute_map['FMLAT'] = propertyString('access_transformer_locations') |
| 195 | + } |
| 196 | + attributes(attribute_map) |
| 197 | + } |
| 198 | + } |
| 199 | + if (propertyBool('enable_shadow')) { |
| 200 | + finalizedBy(tasks.named("remapShadowJar")) |
| 201 | + } else { |
| 202 | + finalizedBy(tasks.named("remapJar")) |
| 203 | + } |
| 204 | +} |
| 205 | + |
| 206 | + |
| 207 | +shadowJar { |
| 208 | + configurations = [project.configurations.shadow] |
| 209 | + archiveClassifier = "shadow" |
| 210 | +} |
| 211 | + |
| 212 | +remapJar { |
| 213 | + doFirst { |
| 214 | + logging.captureStandardOutput LogLevel.INFO |
| 215 | + } |
| 216 | + doLast { |
| 217 | + logging.captureStandardOutput LogLevel.QUIET |
| 218 | + } |
| 219 | +} |
| 220 | + |
| 221 | +compileTestJava { |
| 222 | + sourceCompatibility = targetCompatibility = JavaVersion.VERSION_21 |
| 223 | +} |
| 224 | + |
| 225 | +test { |
| 226 | + useJUnitPlatform() |
| 227 | + javaLauncher.set(javaToolchains.launcherFor { |
| 228 | + languageVersion = JavaLanguageVersion.of(21) |
| 229 | + }) |
| 230 | + if (propertyBool('show_testing_output')) { |
| 231 | + testLogging { |
| 232 | + showStandardStreams = true |
| 233 | + } |
| 234 | + } |
| 235 | +} |
| 236 | + |
| 237 | +tasks.withType(JavaCompile).configureEach { |
| 238 | + options.encoding = 'UTF-8' |
| 239 | +} |
| 240 | + |
| 241 | +apply from: 'gradle/scripts/publishing.gradle' |
| 242 | +apply from: 'gradle/scripts/extra.gradle' |
0 commit comments