Advertisement
Newek

Testmod build.gradle #1

Jan 14th, 2022
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.15 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.         mavenCentral()
  6.     }
  7.     dependencies {
  8.         classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
  9.     }
  10. }
  11. apply plugin: 'net.minecraftforge.gradle'
  12. // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
  13. apply plugin: 'eclipse'
  14. apply plugin: 'maven-publish'
  15.  
  16. version = mod_version_maj + '.' + mod_version_min + '.' + mod_patch + '.' + getBuildNumber()
  17. if (project.hasProperty('buildQualifier')) {
  18.     version = project.version + '-' + project.buildQualifier
  19. }
  20. group = 'newek.testmod' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
  21. archivesBaseName = 'testmod-' + mc_version
  22.  
  23. // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
  24. java.toolchain.languageVersion = JavaLanguageVersion.of(17)
  25.  
  26. println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
  27. minecraft {
  28.     // The mappings can be changed at any time and must be in the following format.
  29.     // Channel:   Version:
  30.     // snapshot   YYYYMMDD   Snapshot are built nightly.
  31.     // stable     #          Stables are built at the discretion of the MCP team.
  32.     // official   MCVersion  Official field/method names from Mojang mapping files
  33.     //
  34.     // You must be aware of the Mojang license when using the 'official' mappings.
  35.     // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
  36.     //
  37.     // Use non-default mappings at your own risk. They may not always work.
  38.     // Simply re-run your setup task after changing the mappings to update your workspace.
  39.     mappings channel: 'official', version: '1.18.1'
  40.  
  41.     // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.
  42.  
  43.     // Default run configurations.
  44.     // These can be tweaked, removed, or duplicated as needed.
  45.     runs {
  46.         client {
  47.             workingDirectory project.file('run')
  48.  
  49.             // Recommended logging data for a userdev environment
  50.             // The markers can be added/remove as needed separated by commas.
  51.             // "SCAN": For mods scan.
  52.             // "REGISTRIES": For firing of registry events.
  53.             // "REGISTRYDUMP": For getting the contents of all registries.
  54.             property 'forge.logging.markers', 'REGISTRIES'
  55.  
  56.             // Recommended logging level for the console
  57.             // You can set various levels here.
  58.             // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
  59.             property 'forge.logging.console.level', 'debug'
  60.  
  61.             mods {
  62.                 testmod {
  63.                     source sourceSets.main
  64.                 }
  65.             }
  66.         }
  67.  
  68.         server {
  69.             workingDirectory project.file('run')
  70.  
  71.             // Recommended logging data for a userdev environment
  72.             // The markers can be added/remove as needed separated by commas.
  73.             // "SCAN": For mods scan.
  74.             // "REGISTRIES": For firing of registry events.
  75.             // "REGISTRYDUMP": For getting the contents of all registries.
  76.             property 'forge.logging.markers', 'REGISTRIES'
  77.  
  78.             // Recommended logging level for the console
  79.             // You can set various levels here.
  80.             // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
  81.             property 'forge.logging.console.level', 'debug'
  82.  
  83.             mods {
  84.                 testmod {
  85.                     source sourceSets.main
  86.                 }
  87.             }
  88.         }
  89.  
  90.         data {
  91.             workingDirectory project.file('run')
  92.  
  93.             // Recommended logging data for a userdev environment
  94.             // The markers can be added/remove as needed separated by commas.
  95.             // "SCAN": For mods scan.
  96.             // "REGISTRIES": For firing of registry events.
  97.             // "REGISTRYDUMP": For getting the contents of all registries.
  98.             property 'forge.logging.markers', 'REGISTRIES'
  99.  
  100.             // Recommended logging level for the console
  101.             // You can set various levels here.
  102.             // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
  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', 'testmod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
  107.  
  108.             mods {
  109.                 testmod {
  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.  
  122.     maven {
  123.         name = "Progwml6 maven"
  124.         url = "https://dvs1.progwml6.com/files/maven"
  125.     }
  126.     maven {
  127.         url = 'https://jitpack.io' // Set Github as a maven repository
  128.     }
  129.     // Put repositories for dependencies here
  130.     // ForgeGradle automatically adds the Forge maven and Maven Central for you
  131.  
  132.     // If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
  133.     // flatDir {
  134.     //    dir 'libs'
  135.     //}
  136. }
  137.  
  138. dependencies {
  139.     // Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed
  140.     // that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied.
  141.     // The userdev artifact is a special name and will get all sorts of transformations applied to it.
  142.     minecraft 'net.minecraftforge:forge:1.18.1-39.0.9'
  143.  
  144.     // Real mod deobf dependency examples - these get remapped to your current mappings
  145.     compileOnly fg.deobf("mezz.jei:jei-${jei_mcversion}:${jei_version}:api") // Adds JEI API as a compile dependency
  146.     runtimeOnly fg.deobf("mezz.jei:jei-${jei_mcversion}:${jei_version}") // Adds the full JEI mod as a runtime dependency
  147.     // implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency
  148.  
  149.     compileOnly files("com.github.lazyMods:baubles:${baubles_mcversion}:api")
  150.  
  151.     // Examples using mod jars from ./libs
  152.     // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
  153.  
  154.     // For more info...
  155.     // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
  156.     // http://www.gradle.org/docs/current/userguide/dependency_management.html
  157. }
  158.  
  159. // Example for how to get properties into the manifest for reading at runtime.
  160. jar {
  161.     manifest {
  162.         attributes([
  163.                 "Specification-Title"     : "Testmod",
  164.                 "Specification-Vendor"    : "Newek",
  165.                 "Specification-Version"   : version,
  166.                 "Implementation-Title"    : project.name,
  167.                 "Implementation-Version"  : project.jar.archiveVersion,
  168.                 "Implementation-Vendor"   : "Newek",
  169.                 "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  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.  
  193. def getBuildNumber() {
  194.     return '$System.env.BUILD_NUMBER' != 'null' ? '$System.env.BUILD_NUMBER' : '0'
  195. }
  196.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement