TheOnlyTails

build.gradle

Oct 16th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.37 KB | None | 0 0
  1. buildscript {
  2. repositories {
  3. maven {
  4. url = 'https://files.minecraftforge.net/maven'
  5. }
  6. jcenter()
  7. mavenCentral()
  8. }
  9. dependencies {
  10. classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
  11. classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.10"
  12. }
  13. }
  14. apply plugin: 'net.minecraftforge.gradle'
  15. // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
  16. apply plugin: 'kotlin'
  17. apply plugin: 'idea'
  18. apply plugin: 'eclipse'
  19. apply plugin: 'maven-publish'
  20.  
  21. version = project.minecraft_version + '-' + project.mod_version
  22. group = project.maven_group
  23. archivesBaseName = project.archives_base_name
  24.  
  25. sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
  26.  
  27. println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
  28.  
  29. minecraft {
  30. mappings channel: project.mappings_channel, version: project.mappings_version
  31. // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
  32.  
  33. accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
  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. property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
  43.  
  44. // Recommended logging level for the console
  45. property 'forge.logging.console.level', 'debug'
  46.  
  47. mods {
  48. rubymod {
  49. source sourceSets.main
  50. }
  51. }
  52. }
  53.  
  54. server {
  55. workingDirectory project.file('run')
  56.  
  57. // Recommended logging data for a userdev environment
  58. property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
  59.  
  60. // Recommended logging level for the console
  61. property 'forge.logging.console.level', 'debug'
  62.  
  63. mods {
  64. rubymod {
  65. source sourceSets.main
  66. }
  67. }
  68. }
  69.  
  70. data {
  71. workingDirectory project.file('run')
  72.  
  73. // Recommended logging data for a userdev environment
  74. property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
  75.  
  76. // Recommended logging level for the console
  77. property 'forge.logging.console.level', 'debug'
  78.  
  79. args '--mod', project.modid, '--all', '--output', file('src/generated/resources/'), "--existing", file('src/main/resources/')
  80.  
  81. mods {
  82. rubymod {
  83. source sourceSets.main
  84. }
  85. }
  86. }
  87. }
  88. }
  89.  
  90. repositories {
  91. maven {
  92. name = 'Kotlin for Forge'
  93. url = 'https://thedarkcolour.github.io/KotlinForForge/'
  94. }
  95. }
  96.  
  97. dependencies {
  98. implementation 'org.jetbrains:annotations:19.0.0'
  99.  
  100. minecraft 'net.minecraftforge:forge:' + project.minecraft_version + '-' + project.forge_version
  101.  
  102. // Use the latest version of KotlinForForge
  103. fg.deobf(implementation('thedarkcolour:kotlinforforge:1.6.0'))
  104. }
  105.  
  106. compileKotlin {
  107. kotlinOptions {
  108. jvmTarget = '1.8'
  109. }
  110. }
  111.  
  112. jar {
  113. manifest {
  114. attributes([
  115. "Specification-Title" : project.modid,
  116. "Specification-Vendor" : project.author,
  117. "Specification-Version" : "1", // We are version 1 of ourselves
  118. "Implementation-Title" : project.name,
  119. "Implementation-Version" : project.version,
  120. "Implementation-Vendor" : project.author,
  121. "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  122. ])
  123. }
  124. }
  125.  
  126. // Example configuration to allow publishing using the maven-publish task
  127. // This is the preferred method to reobfuscate your jar file
  128. jar.finalizedBy('reobfJar')
  129. // 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
  130. //publish.dependsOn('reobfJar')
  131.  
  132. task sourcesJar(type: Jar, dependsOn: classes) {
  133. classifier = 'sources'
  134. from sourceSets.main.allSource
  135. }
  136.  
  137. build.dependsOn sourcesJar
  138.  
  139. artifacts {
  140. archives sourcesJar
  141. }
  142.  
  143. // Process resources on build
  144. processResources {
  145. // This will ensure that this task is redone when the versions change.
  146. inputs.property 'version', project.version
  147.  
  148. // Replace stuff in mods.toml, nothing else
  149. from(sourceSets.main.resources.srcDirs) {
  150. include 'META-INF/mods.toml'
  151.  
  152. // Replace version
  153. expand 'version': project.version
  154. }
  155.  
  156. // Copy everything else except the mods.toml
  157. from(sourceSets.main.resources.srcDirs) {
  158. exclude 'META-INF/mods.toml'
  159. }
  160. }
  161.  
  162. publishing {
  163. publications {
  164. mavenJava(MavenPublication) {
  165. artifact jar
  166. }
  167. }
  168.  
  169. repositories {
  170. maven {
  171. url "file:///${project.projectDir}/mcmodsrepo"
  172. }
  173. }
  174. }
Advertisement
Add Comment
Please, Sign In to add comment