|
| 1 | +plugins { |
| 2 | + id 'fabric-loom' version '1.6-SNAPSHOT' |
| 3 | + id 'maven-publish' |
| 4 | + id 'com.github.johnrengelman.shadow' version '7.0.0' |
| 5 | +} |
| 6 | + |
| 7 | +version = "${project.mod_version}+mc${project.minecraft_version}" |
| 8 | +group = project.maven_group |
| 9 | + |
| 10 | +base { |
| 11 | + archivesName = project.archives_base_name |
| 12 | +} |
| 13 | + |
| 14 | +repositories { |
| 15 | + // Add repositories to retrieve artifacts from in here. |
| 16 | + // You should only use this when depending on other mods because |
| 17 | + // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. |
| 18 | + // See https://docs.gradle.org/current/userguide/declaring_repositories.html |
| 19 | + // for more information about repositories. |
| 20 | + maven { |
| 21 | + url "https://repo.hypixel.net/repository/Hypixel/" |
| 22 | + } |
| 23 | + mavenLocal() |
| 24 | +} |
| 25 | + |
| 26 | +dependencies { |
| 27 | + // To change the versions see the gradle.properties file |
| 28 | + minecraft "com.mojang:minecraft:${project.minecraft_version}" |
| 29 | + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" |
| 30 | + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" |
| 31 | + |
| 32 | + // Fabric API. This is technically optional, but you probably want it anyway. |
| 33 | + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" |
| 34 | + |
| 35 | + shadow "net.hypixel:mod-api:${project.mod_api_version}" |
| 36 | +} |
| 37 | + |
| 38 | +shadowJar { |
| 39 | + // Exclude all dependencies by default |
| 40 | + configurations = [project.configurations.shadow] |
| 41 | + |
| 42 | + // Rename the shaded JAR |
| 43 | + archiveClassifier = 'shaded' |
| 44 | +} |
| 45 | + |
| 46 | +remapJar { |
| 47 | + dependsOn(shadowJar) |
| 48 | + inputFile = tasks.shadowJar.archiveFile |
| 49 | +} |
| 50 | + |
| 51 | +processResources { |
| 52 | + inputs.property "version", project.version |
| 53 | + inputs.property "minecraft_version", project.minecraft_version |
| 54 | + inputs.property "loader_version", project.loader_version |
| 55 | + filteringCharset "UTF-8" |
| 56 | + |
| 57 | + filesMatching("fabric.mod.json") { |
| 58 | + expand "version": project.version, |
| 59 | + "minecraft_version": project.minecraft_version, |
| 60 | + "loader_version": project.loader_version |
| 61 | + } |
| 62 | +} |
| 63 | + |
| 64 | +def targetJavaVersion = 17 |
| 65 | +tasks.withType(JavaCompile).configureEach { |
| 66 | + // ensure that the encoding is set to UTF-8, no matter what the system default is |
| 67 | + // this fixes some edge cases with special characters not displaying correctly |
| 68 | + // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html |
| 69 | + // If Javadoc is generated, this must be specified in that task too. |
| 70 | + it.options.encoding = "UTF-8" |
| 71 | + if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { |
| 72 | + it.options.release.set(targetJavaVersion) |
| 73 | + } |
| 74 | +} |
| 75 | + |
| 76 | +java { |
| 77 | + def javaVersion = JavaVersion.toVersion(targetJavaVersion) |
| 78 | + if (JavaVersion.current() < javaVersion) { |
| 79 | + toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) |
| 80 | + } |
| 81 | + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task |
| 82 | + // if it is present. |
| 83 | + // If you remove this line, sources will not be generated. |
| 84 | + withSourcesJar() |
| 85 | +} |
| 86 | + |
| 87 | +jar { |
| 88 | + from("LICENSE") { |
| 89 | + rename { "${it}_${project.archivesBaseName}"} |
| 90 | + } |
| 91 | +} |
| 92 | + |
| 93 | +// configure the maven publication |
| 94 | +publishing { |
| 95 | + publications { |
| 96 | + mavenJava(MavenPublication) { |
| 97 | + from components.java |
| 98 | + } |
| 99 | + } |
| 100 | + |
| 101 | + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. |
| 102 | + repositories { |
| 103 | + // Add repositories to publish to here. |
| 104 | + // Notice: This block does NOT have the same function as the block in the top level. |
| 105 | + // The repositories here will be used for publishing your artifact, not for |
| 106 | + // retrieving dependencies. |
| 107 | + } |
| 108 | +} |
0 commit comments