build.gradle 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. buildscript {
  2. repositories {
  3. maven { url = 'https://maven.minecraftforge.net' }
  4. maven { url = 'https://maven.blamejared.com' }
  5. maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
  6. mavenCentral()
  7. }
  8. dependencies {
  9. classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
  10. classpath 'gradle.plugin.com.matthewprenger:CurseGradle:1.4.0'
  11. classpath group: 'com.blamejared', name: 'ModTemplate', version: '2.+', changing: true
  12. classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
  13. }
  14. }
  15. apply plugin: 'java'
  16. apply plugin: 'net.minecraftforge.gradle'
  17. apply plugin: 'com.blamejared.modtemplate'
  18. apply plugin: 'eclipse'
  19. apply plugin: 'org.spongepowered.mixin'
  20. apply plugin: 'maven-publish'
  21. apply plugin: 'com.matthewprenger.cursegradle'
  22. import com.blamejared.modtemplate.Utils
  23. archivesBaseName = "${mod_name}-forge-${minecraft_version}"
  24. version = Utils.updatingVersion(mod_version)
  25. mixin {
  26. add sourceSets.main, "controlling.refmap.json"
  27. }
  28. minecraft {
  29. mappings channel: 'official', version: minecraft_version
  30. if (project.hasProperty('forge_ats_enabled') && project.findProperty('forge_ats_enabled').toBoolean()) {
  31. // This location is hardcoded in Forge and can not be changed.
  32. // https://github.com/MinecraftForge/MinecraftForge/blob/be1698bb1554f9c8fa2f58e32b9ab70bc4385e60/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java#L123
  33. accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
  34. project.logger.debug('Forge Access Transformers are enabled for this project.')
  35. }
  36. runs {
  37. client {
  38. workingDirectory project.file('run')
  39. ideaModule "${rootProject.name}.${project.name}.main"
  40. taskName 'Client'
  41. arg "--mixin=controlling.mixins.json"
  42. mods {
  43. modClientRun {
  44. source sourceSets.main
  45. source project(":Common").sourceSets.main
  46. }
  47. }
  48. }
  49. server {
  50. workingDirectory project.file('run')
  51. ideaModule "${rootProject.name}.${project.name}.main"
  52. taskName 'Server'
  53. arg "--mixin=controlling.mixins.json"
  54. mods {
  55. modServerRun {
  56. source sourceSets.main
  57. source project(":Common").sourceSets.main
  58. }
  59. }
  60. }
  61. data {
  62. workingDirectory project.file('run')
  63. ideaModule "${rootProject.name}.${project.name}.main"
  64. args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
  65. taskName 'Data'
  66. arg "--mixin=controlling.mixins.json"
  67. mods {
  68. modDataRun {
  69. source sourceSets.main
  70. source project(":Common").sourceSets.main
  71. }
  72. }
  73. }
  74. }
  75. }
  76. modTemplate {
  77. mcVersion minecraft_version
  78. curseHomepage curse_homepage
  79. displayName mod_name
  80. modLoader "Forge"
  81. changelog {
  82. enabled true
  83. firstCommit git_first_commit
  84. repo git_repo
  85. }
  86. versionTracker {
  87. enabled true
  88. author mod_author
  89. projectName mod_name
  90. }
  91. webhook {
  92. enabled true
  93. curseId curse_project_id
  94. avatarUrl mod_avatar
  95. }
  96. }
  97. sourceSets.main.resources.srcDir 'src/generated/resources'
  98. dependencies {
  99. minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
  100. compileOnly project(":Common")
  101. annotationProcessor 'org.spongepowered:mixin:0.8.4-SNAPSHOT:processor'
  102. }
  103. tasks.withType(JavaCompile) {
  104. source(project(":Common").sourceSets.main.allSource)
  105. }
  106. processResources {
  107. from project(":Common").sourceSets.main.resources
  108. }
  109. jar {
  110. manifest {
  111. attributes([
  112. "Specification-Title" : mod_name,
  113. "Specification-Vendor" : mod_author,
  114. "Specification-Version" : "1",
  115. "Implementation-Title" : project.name,
  116. "Implementation-Version" : project.jar.archiveVersion,
  117. "Implementation-Vendor" : mod_author,
  118. "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
  119. "MixinConfigs" : "controlling.mixins.json"
  120. ])
  121. }
  122. }
  123. jar.finalizedBy('reobfJar')
  124. publishing {
  125. publications {
  126. mavenJava(MavenPublication) {
  127. artifact jar
  128. }
  129. }
  130. repositories {
  131. maven {
  132. url "file://${project.projectDir}/mcmodsrepo"
  133. }
  134. }
  135. }
  136. curseforge {
  137. apiKey = findProperty('curseforge_api_token') ?: 0
  138. project {
  139. id = curse_project_id
  140. releaseType = 'release'
  141. changelog = file("changelog.md")
  142. changelogType = 'markdown'
  143. addGameVersion "Forge"
  144. addGameVersion minecraft_version
  145. }
  146. }