Advertisement
Cardinal_System

Untitled

Oct 16th, 2021
2,766
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 8.16 KB | None | 0 0
  1. buildscript {
  2.     repositories {
  3.         // These repositories are only for Gradle plugins, put any other repositories in the repository block further below
  4.         maven { url = 'https://maven.minecraftforge.net' }
  5.     }
  6.     dependencies {
  7.         classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
  8.     }
  9. }
  10. apply plugin: 'net.minecraftforge.gradle'
  11. // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
  12. apply plugin: 'eclipse'
  13. apply plugin: 'maven-publish'
  14.  
  15. version = '1.0'
  16. group = 'com.cardinal.expandedfood' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
  17. archivesBaseName = 'expandedfood'
  18.  
  19. configurations {
  20.     shade
  21.     compile.extendsFrom shade
  22. }
  23.  
  24. // Mojang ships Java 16 to end users in 1.17+ instead of Java 8 in 1.16 or lower, so your mod should target Java 16.
  25. java.toolchain.languageVersion = JavaLanguageVersion.of(16)
  26.  
  27. println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
  28. minecraft {
  29.     // The mappings can be changed at any time and must be in the following format.
  30.     // Channel:   Version:
  31.     // snapshot   YYYYMMDD   Snapshot are built nightly.
  32.     // stable     #          Stables are built at the discretion of the MCP team.
  33.     // official   MCVersion  Official field/method names from Mojang mapping files
  34.     //
  35.     // You must be aware of the Mojang license when using the 'official' mappings.
  36.     // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
  37.     //
  38.     // Use non-default mappings at your own risk. They may not always work.
  39.     // Simply re-run your setup task after changing the mappings to update your workspace.
  40.     mappings channel: 'official', version: '1.17.1'
  41.  
  42.     // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.
  43.  
  44.     // Default run configurations.
  45.     // These can be tweaked, removed, or duplicated as needed.
  46.     runs {
  47.         client {
  48.             workingDirectory project.file('run')
  49.  
  50.             // Recommended logging data for a userdev environment
  51.             // The markers can be added/remove as needed separated by commas.
  52.             // "SCAN": For mods scan.
  53.             // "REGISTRIES": For firing of registry events.
  54.             // "REGISTRYDUMP": For getting the contents of all registries.
  55.             property 'forge.logging.markers', 'REGISTRIES'
  56.  
  57.             // Recommended logging level for the console
  58.             // You can set various levels here.
  59.             // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
  60.             property 'forge.logging.console.level', 'debug'
  61.  
  62.             mods {
  63.                 expandedfood {
  64.                     source sourceSets.main
  65.                 }
  66.             }
  67.         }
  68.  
  69.         server {
  70.             workingDirectory project.file('run')
  71.  
  72.             // Recommended logging data for a userdev environment
  73.             // The markers can be added/remove as needed separated by commas.
  74.             // "SCAN": For mods scan.
  75.             // "REGISTRIES": For firing of registry events.
  76.             // "REGISTRYDUMP": For getting the contents of all registries.
  77.             property 'forge.logging.markers', 'REGISTRIES'
  78.  
  79.             // Recommended logging level for the console
  80.             // You can set various levels here.
  81.             // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
  82.             property 'forge.logging.console.level', 'debug'
  83.  
  84.             mods {
  85.                 expandedfood {
  86.                     source sourceSets.main
  87.                 }
  88.             }
  89.         }
  90.  
  91.         data {
  92.             workingDirectory project.file('run')
  93.  
  94.             // Recommended logging data for a userdev environment
  95.             // The markers can be added/remove as needed separated by commas.
  96.             // "SCAN": For mods scan.
  97.             // "REGISTRIES": For firing of registry events.
  98.             // "REGISTRYDUMP": For getting the contents of all registries.
  99.             property 'forge.logging.markers', 'REGISTRIES'
  100.  
  101.             // Recommended logging level for the console
  102.             // You can set various levels here.
  103.             // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
  104.             property 'forge.logging.console.level', 'debug'
  105.  
  106.             // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
  107.             args '--mod', 'expandedfood', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
  108.  
  109.             mods {
  110.                 expandedfood {
  111.                     source sourceSets.main
  112.                 }
  113.             }
  114.         }
  115.     }
  116. }
  117.  
  118. // Include resources generated by data generators.
  119. sourceSets.main.resources { srcDir 'src/generated/resources' }
  120.  
  121. repositories {
  122.     // Put repositories for dependencies here
  123.     // ForgeGradle automatically adds the Forge maven and Maven Central for you
  124.  
  125.     // If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
  126.     // flatDir {
  127.     //     dir 'libs'
  128.     // }
  129.     mavenCentral()
  130. }
  131.  
  132. dependencies {
  133.     // Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed
  134.     // that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied.
  135.     // The userdev artifact is a special name and will get all sorts of transformations applied to it.
  136.     minecraft 'net.minecraftforge:forge:1.17.1-37.0.82'
  137.     shade 'io.github.classgraph:classgraph:4.8.123'
  138.     // I guess I have to do both shade and implementation because Eclipse is not seeing my dependency without this line
  139.     implementation 'io.github.classgraph:classgraph:4.8.123'  
  140.  
  141.     // Real mod deobf dependency examples - these get remapped to your current mappings
  142.     // compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
  143.     // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency
  144.     // implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency
  145.  
  146.     // Examples using mod jars from ./libs
  147.     // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
  148.  
  149.     // For more info...
  150.     // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
  151.     // http://www.gradle.org/docs/current/userguide/dependency_management.html
  152. }
  153.  
  154. // Example for how to get properties into the manifest for reading at runtime.
  155. jar {
  156.     manifest {
  157.         attributes([
  158.                 "Specification-Title"     : "Expanded Food",
  159.                 "Specification-Vendor"    : "Cardinal System",
  160.                 "Specification-Version"   : "1", // We are version 1 of ourselves
  161.                 "Implementation-Title"    : project.name,
  162.                 "Implementation-Version"  : project.jar.archiveVersion,
  163.                 "Implementation-Vendor"   : "Cardinal System",
  164.                 "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  165.         ])
  166.     }
  167.     configurations.shade.each { dep ->
  168.         from(project.zipTree(dep)){
  169.             exclude 'META-INF', 'META-INF/**'
  170.         }
  171.     }
  172. }
  173.  
  174. // Example configuration to allow publishing using the maven-publish plugin
  175. // This is the preferred method to reobfuscate your jar file
  176. jar.finalizedBy('reobfJar')
  177. // 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
  178. // publish.dependsOn('reobfJar')
  179.  
  180. publishing {
  181.     publications {
  182.         mavenJava(MavenPublication) {
  183.             artifact jar
  184.         }
  185.     }
  186.     repositories {
  187.         maven {
  188.             url "file://${project.projectDir}/mcmodsrepo"
  189.         }
  190.     }
  191. }
  192.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement