build.gradle (3218B)
1 plugins { 2 id 'fabric-loom' version '1.0-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 // Fabric API. This is technically optional, but you probably want it anyway. 24 modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" 25 26 // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. 27 // You may need to force-disable transitiveness on them. 28 } 29 30 processResources { 31 inputs.property "version", project.version 32 filteringCharset "UTF-8" 33 34 filesMatching("fabric.mod.json") { 35 expand "version": project.version 36 } 37 } 38 39 def targetJavaVersion = 17 40 tasks.withType(JavaCompile).configureEach { 41 // ensure that the encoding is set to UTF-8, no matter what the system default is 42 // this fixes some edge cases with special characters not displaying correctly 43 // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html 44 // If Javadoc is generated, this must be specified in that task too. 45 it.options.encoding = "UTF-8" 46 if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { 47 it.options.release = targetJavaVersion 48 } 49 } 50 51 java { 52 def javaVersion = JavaVersion.toVersion(targetJavaVersion) 53 if (JavaVersion.current() < javaVersion) { 54 toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) 55 } 56 archivesBaseName = project.archives_base_name 57 // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task 58 // if it is present. 59 // If you remove this line, sources will not be generated. 60 withSourcesJar() 61 } 62 63 jar { 64 from("LICENSE") { 65 rename { "${it}_${project.archivesBaseName}" } 66 } 67 } 68 69 // configure the maven publication 70 publishing { 71 publications { 72 mavenJava(MavenPublication) { 73 // add all the jars that should be included when publishing to maven 74 artifact(remapJar) { 75 builtBy remapJar 76 } 77 artifact(sourcesJar) { 78 builtBy remapSourcesJar 79 } 80 } 81 } 82 83 // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. 84 repositories { 85 // Add repositories to publish to here. 86 // Notice: This block does NOT have the same function as the block in the top level. 87 // The repositories here will be used for publishing your artifact, not for 88 // retrieving dependencies. 89 } 90 }