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