Advertisement
CerbonXD

build.gradle

Jan 16th, 2023
2,031
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 7.43 KB | None | 0 0
  1. plugins {
  2.     id 'eclipse'
  3.     id 'maven-publish'
  4.     id 'net.minecraftforge.gradle' version '5.1.+'
  5.     id 'org.parchmentmc.librarian.forgegradle' version '1.+'
  6. }
  7.  
  8. version = '0.0.1-1.19.3'
  9. group = 'com.cerbon.not_enough_blocks_mod' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
  10. archivesBaseName = 'not_enough_blocks_mod'
  11.  
  12. // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
  13. java.toolchain.languageVersion = JavaLanguageVersion.of(17)
  14.  
  15. println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
  16. minecraft {
  17.     // The mappings can be changed at any time and must be in the following format.
  18.     // Channel:   Version:
  19.     // official   MCVersion             Official field/method names from Mojang mapping files
  20.     // parchment  YYYY.MM.DD-MCVersion  Open community-sourced parameter names and javadocs layered on top of official
  21.     //
  22.     // You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
  23.     // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
  24.     //
  25.     // Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
  26.     // Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started
  27.     //
  28.     // Use non-default mappings at your own risk. They may not always work.
  29.     // Simply re-run your setup task after changing the mappings to update your workspace.
  30. //    mappings channel: 'official', version: '1.19.3'
  31.     mappings channel: 'parchment', version: '2022.12.18-1.19.3'
  32.  
  33.     accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.
  34.  
  35.     // Default run configurations.
  36.     // These can be tweaked, removed, or duplicated as needed.
  37.     runs {
  38.         client {
  39.             workingDirectory project.file('run')
  40.  
  41.             // Recommended logging data for a userdev environment
  42.             // The markers can be added/remove as needed separated by commas.
  43.             // "SCAN": For mods scan.
  44.             // "REGISTRIES": For firing of registry events.
  45.             // "REGISTRYDUMP": For getting the contents of all registries.
  46.             property 'forge.logging.markers', 'REGISTRIES'
  47.  
  48.             // Recommended logging level for the console
  49.             // You can set various levels here.
  50.             // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
  51.             property 'forge.logging.console.level', 'debug'
  52.  
  53.             // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
  54.             property 'forge.enabledGameTestNamespaces', 'not_enough_blocks_mod'
  55.  
  56.             mods {
  57.                 not_enough_blocks_mod {
  58.                     source sourceSets.main
  59.                 }
  60.             }
  61.         }
  62.  
  63.         server {
  64.             workingDirectory project.file('run')
  65.  
  66.             property 'forge.logging.markers', 'REGISTRIES'
  67.  
  68.             property 'forge.logging.console.level', 'debug'
  69.  
  70.             property 'forge.enabledGameTestNamespaces', 'not_enough_blocks_mod'
  71.  
  72.             mods {
  73.                 not_enough_blocks_mod {
  74.                     source sourceSets.main
  75.                 }
  76.             }
  77.         }
  78.  
  79.         // This run config launches GameTestServer and runs all registered gametests, then exits.
  80.         // By default, the server will crash when no gametests are provided.
  81.         // The gametest system is also enabled by default for other run configs under the /test command.
  82.         gameTestServer {
  83.             workingDirectory project.file('run')
  84.  
  85.             property 'forge.logging.markers', 'REGISTRIES'
  86.  
  87.             property 'forge.logging.console.level', 'debug'
  88.  
  89.             property 'forge.enabledGameTestNamespaces', 'not_enough_blocks_mod'
  90.  
  91.             mods {
  92.                 not_enough_blocks_mod {
  93.                     source sourceSets.main
  94.                 }
  95.             }
  96.         }
  97.  
  98.         data {
  99.             workingDirectory project.file('run')
  100.  
  101.             property 'forge.logging.markers', 'REGISTRIES'
  102.  
  103.             property 'forge.logging.console.level', 'debug'
  104.  
  105.             // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
  106.             args '--mod', 'not_enough_blocks_mod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
  107.  
  108.             mods {
  109.                 not_enough_blocks_mod {
  110.                     source sourceSets.main
  111.                 }
  112.             }
  113.         }
  114.     }
  115. }
  116.  
  117. // Include resources generated by data generators.
  118. sourceSets.main.resources { srcDir 'src/generated/resources' }
  119.  
  120. repositories {
  121.     // Put repositories for dependencies here
  122.     // ForgeGradle automatically adds the Forge maven and Maven Central for you
  123.  
  124.     // If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
  125.     // flatDir {
  126.     //     dir 'libs'
  127.     // }
  128. }
  129.  
  130. dependencies {
  131.     // Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed
  132.     // that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied.
  133.     // The userdev artifact is a special name and will get all sorts of transformations applied to it.
  134.     minecraft 'net.minecraftforge:forge:1.19.3-44.1.0'
  135.  
  136.     // Real mod deobf dependency examples - these get remapped to your current mappings
  137.     // implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency
  138.  
  139.     // Examples using mod jars from ./libs
  140.     // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
  141.  
  142.     // For more info...
  143.     // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
  144.     // http://www.gradle.org/docs/current/userguide/dependency_management.html
  145. }
  146.  
  147. // Example for how to get properties into the manifest for reading at runtime.
  148. jar {
  149.     manifest {
  150.         attributes([
  151.                 "Specification-Title"     : "not_enough_blocks_mod",
  152.                 "Specification-Vendor"    : "not_enough_blocks_modsareus",
  153.                 "Specification-Version"   : "1", // We are version 1 of ourselves
  154.                 "Implementation-Title"    : project.name,
  155.                 "Implementation-Version"  : project.jar.archiveVersion,
  156.                 "Implementation-Vendor"   : "not_enough_blocks_modsareus",
  157.                 "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  158.         ])
  159.     }
  160. }
  161.  
  162. // Example configuration to allow publishing using the maven-publish plugin
  163. // This is the preferred method to reobfuscate your jar file
  164. jar.finalizedBy('reobfJar')
  165. // However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
  166. // publish.dependsOn('reobfJar')
  167.  
  168. publishing {
  169.     publications {
  170.         mavenJava(MavenPublication) {
  171.             artifact jar
  172.         }
  173.     }
  174.     repositories {
  175.         maven {
  176.             url "file://${project.projectDir}/mcmodsrepo"
  177.         }
  178.     }
  179. }
  180.  
  181. tasks.withType(JavaCompile).configureEach {
  182.     options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
  183. }
  184.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement