Guest User

build.gradle

a guest
Dec 12th, 2023
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 9.78 KB | None | 0 0
  1. plugins {
  2.     id 'eclipse'
  3.     id 'idea'
  4.     id 'maven-publish'
  5.     id 'net.minecraftforge.gradle' version '[6.0,6.2)'
  6. }
  7.  
  8. version = "1.0"
  9. group = "net.miloszp22.tmbts"
  10.  
  11. base {
  12.     archivesName = "tmbts"
  13. }
  14. // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
  15. java.toolchain.languageVersion = JavaLanguageVersion.of(17)
  16.  
  17. println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
  18. minecraft {
  19.     // The mappings can be changed at any time and must be in the following format.
  20.     // Channel:   Version:
  21.     // official   MCVersion             Official field/method names from Mojang mapping files
  22.     // parchment  YYYY.MM.DD-MCVersion  Open community-sourced parameter names and javadocs layered on top of official
  23.     //
  24.     // You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
  25.     // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
  26.     //
  27.     // Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
  28.     // Additional setup is needed to use their mappings: https://github.com/ParchmentMC/Parchment/wiki/Getting-Started
  29.     //
  30.     // Use non-default mappings at your own risk. They may not always work.
  31.     // Simply re-run your setup task after changing the mappings to update your workspace.
  32.     mappings channel: mapping_channel, version: mapping_version
  33.  
  34.     // When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game.
  35.     // In most cases, it is not necessary to enable.
  36.     // enableEclipsePrepareRuns = true
  37.     // enableIdeaPrepareRuns = true
  38.  
  39.     // This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
  40.     // It is REQUIRED to be set to true for this template to function.
  41.     // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
  42.     copyIdeResources = true
  43.  
  44.     // When true, this property will add the folder name of all declared run configurations to generated IDE run configurations.
  45.     // The folder name can be set on a run configuration using the "folderName" property.
  46.     // By default, the folder name of a run configuration is the name of the Gradle project containing it.
  47.     // generateRunFolders = true
  48.  
  49.     // This property enables access transformers for use in development.
  50.     // They will be applied to the Minecraft artifact.
  51.     // The access transformer file can be anywhere in the project.
  52.     // However, it must be at "META-INF/accesstransformer.cfg" in the final mod jar to be loaded by Forge.
  53.     // This default location is a best practice to automatically put the file in the right place in the final jar.
  54.     // See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information.
  55.     // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
  56.  
  57.     // Default run configurations.
  58.     // These can be tweaked, removed, or duplicated as needed.
  59.     runs {
  60.         // applies to all the run configs below
  61.         configureEach {
  62.             workingDirectory project.file('run')
  63.  
  64.             // Recommended logging data for a userdev environment
  65.             // The markers can be added/remove as needed separated by commas.
  66.             // "SCAN": For mods scan.
  67.             // "REGISTRIES": For firing of registry events.
  68.             // "REGISTRYDUMP": For getting the contents of all registries.
  69.             property 'forge.logging.markers', 'REGISTRIES'
  70.  
  71.             // Recommended logging level for the console
  72.             // You can set various levels here.
  73.             // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
  74.             property 'forge.logging.console.level', 'debug'
  75.  
  76.             // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
  77.             property 'forge.enabledGameTestNamespaces', mod_id
  78.  
  79.             mods {
  80.                 "tmbts" {
  81.                     source sourceSets.main
  82.                 }
  83.             }
  84.         }
  85.  
  86.         client {
  87.             // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
  88.             property 'forge.enabledGameTestNamespaces', mod_id
  89.         }
  90.  
  91.         server {
  92.             property 'forge.enabledGameTestNamespaces', mod_id
  93.             args '--nogui'
  94.         }
  95.  
  96.         // This run config launches GameTestServer and runs all registered gametests, then exits.
  97.         // By default, the server will crash when no gametests are provided.
  98.         // The gametest system is also enabled by default for other run configs under the /test command.
  99.         gameTestServer {
  100.             property 'forge.enabledGameTestNamespaces', mod_id
  101.         }
  102.  
  103.         data {
  104.             // example of overriding the workingDirectory set in configureEach above
  105.             workingDirectory project.file('run-data')
  106.  
  107.             // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
  108.             args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
  109.         }
  110.     }
  111. }
  112.  
  113. // Include resources generated by data generators.
  114. sourceSets.main.resources { srcDir 'src/generated/resources' }
  115.  
  116. repositories {
  117.     // Put repositories for dependencies here
  118.     // ForgeGradle automatically adds the Forge maven and Maven Central for you
  119.  
  120.     // If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
  121.     // flatDir {
  122.     //     dir 'libs'
  123.     // }
  124. }
  125.  
  126. dependencies {
  127.     // Specify the version of Minecraft to use.
  128.     // Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact.
  129.     // The "userdev" classifier will be requested and setup by ForgeGradle.
  130.     // If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
  131.     // then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
  132.     minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
  133.     implementation fg.deobf("com.sparkjava:spark-core:2.9.4")
  134.     // Real mod deobf dependency examples - these get remapped to your current mappings
  135.     // compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
  136.     // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency
  137.     // implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency
  138.  
  139.     // Example mod dependency using a mod jar from ./libs with a flat dir repository
  140.     // This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
  141.     // The group id is ignored when searching -- in this case, it is "blank"
  142.     // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
  143.  
  144.     // For more info:
  145.     // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
  146.     // http://www.gradle.org/docs/current/userguide/dependency_management.html
  147. }
  148.  
  149. // This block of code expands all declared replace properties in the specified resource targets.
  150. // A missing property will result in an error. Properties are expanded using ${} Groovy notation.
  151. // When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
  152. // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
  153. tasks.named('processResources', ProcessResources).configure {
  154.     var replaceProperties = [
  155.             minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
  156.             forge_version: forge_version, forge_version_range: forge_version_range,
  157.             loader_version_range: loader_version_range,
  158.             mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
  159.             mod_authors: mod_authors, mod_description: mod_description,
  160.     ]
  161.     inputs.properties replaceProperties
  162.  
  163.     filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
  164.         expand replaceProperties + [project: project]
  165.     }
  166. }
  167.  
  168. // Example for how to get properties into the manifest for reading at runtime.
  169. tasks.named('jar', Jar).configure {
  170.     manifest {
  171.         attributes([
  172.                 'Specification-Title'     : mod_id,
  173.                 'Specification-Vendor'    : mod_authors,
  174.                 'Specification-Version'   : '1', // We are version 1 of ourselves
  175.                 'Implementation-Title'    : project.name,
  176.                 'Implementation-Version'  : project.jar.archiveVersion,
  177.                 'Implementation-Vendor'   : mod_authors,
  178.                 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  179.         ])
  180.     }
  181.  
  182.     // This is the preferred method to reobfuscate your jar file
  183.     finalizedBy 'reobfJar'
  184. }
  185.  
  186. // 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:
  187. // tasks.named('publish').configure {
  188. //     dependsOn 'reobfJar'
  189. // }
  190.  
  191. publishing {
  192.     publications {
  193.         register('mavenJava', MavenPublication) {
  194.             artifact jar
  195.         }
  196.     }
  197.     repositories {
  198.         maven {
  199.             url "file://${project.projectDir}/mcmodsrepo"
  200.         }
  201.     }
  202. }
  203.  
  204. tasks.withType(JavaCompile).configureEach {
  205.     options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
  206. }
  207.  
Add Comment
Please, Sign In to add comment