build.gradle 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. plugins {
  2. id("fabric-loom") version "0.4.5"
  3. id("maven-publish")
  4. id("java")
  5. id("java-library")
  6. id("net.minecrell.licenser") version("0.4.1")
  7. id("com.matthewprenger.cursegradle") version("1.4.0")
  8. id("net.corda.plugins.jar-filter") version("5.0.8") apply false
  9. }
  10. import net.fabricmc.loom.task.RemapJarTask
  11. import java.text.SimpleDateFormat
  12. sourceCompatibility = targetCompatibility = 1.8
  13. archivesBaseName = "RoughlyEnoughItems"
  14. group = "me.shedaniel"
  15. version = project.mod_version
  16. minecraft {
  17. accessWidener = file("src/main/resources/rei.aw")
  18. }
  19. license {
  20. header rootProject.file('HEADER')
  21. include '**/*.java'
  22. }
  23. repositories {
  24. maven { url "https://dl.bintray.com/shedaniel/legacy-yarn-updated" }
  25. }
  26. jar {
  27. from "LICENSE"
  28. }
  29. processResources {
  30. filesMatching('fabric.mod.json') {
  31. expand 'version': project.version
  32. }
  33. inputs.property "version", project.version
  34. }
  35. dependencies {
  36. minecraft("com.mojang:minecraft:${project.minecraft_version}")
  37. mappings("me.shedaniel:legacy-yarn:${project.yarn_version}:v2")
  38. modApi("net.fabricmc:fabric-loader:${project.fabricloader_version}")
  39. modApi("net.fabricmc.fabric-api:fabric-api:${project.fabric_api}") {
  40. exclude(module: "fabric-dimensions-v1")
  41. exclude(module: "fabric-biomes-v1")
  42. exclude(module: "fabric-events-interaction-v0")
  43. }
  44. modApi("me.shedaniel.cloth:cloth-events:${cloth_events_version}") {
  45. transitive = false
  46. }
  47. modApi("me.shedaniel.cloth:config-2:${cloth_config_version}") {
  48. exclude module: "fabric-api"
  49. }
  50. modApi("me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig1u}") {
  51. exclude module: "fabric-api"
  52. }
  53. modApi("org.jetbrains:annotations:18.0.0")
  54. modCompileOnly("io.github.prospector:modmenu:${modmenu_version}") {
  55. transitive = false
  56. }
  57. modRuntime("io.github.prospector:modmenu:${modmenu_version}") {
  58. transitive = false
  59. }
  60. afterEvaluate {
  61. def listAdded = new ArrayList(Arrays.asList((api_exculde as String).split(',')))
  62. def eachDep = { dep ->
  63. for (apiIncludeDepStr in (api_include as String).split(',')) {
  64. if (apiIncludeDepStr.isEmpty()) continue
  65. def apiIncludeGroup = apiIncludeDepStr.split(':')[0]
  66. def apiIncludeDep = apiIncludeDepStr.split(':')[1]
  67. if (dep.module.id.group == apiIncludeGroup && dep.module.id.name.startsWith(apiIncludeDep)) {
  68. def version = dep.module.id.version.indexOf('@') >= 0 ? dep.module.id.version.substring(0, dep.module.id.version.indexOf('@')) : dep.module.id.version
  69. def mavenDep = "${dep.module.id.group}:${dep.module.id.name}:$version"
  70. if (!(mavenDep in listAdded)) {
  71. include(mavenDep) {
  72. transitive = false
  73. }
  74. listAdded.add(mavenDep)
  75. }
  76. break
  77. }
  78. }
  79. }
  80. configurations.compile.resolvedConfiguration.firstLevelModuleDependencies.each eachDep
  81. configurations.runtimeClasspath.resolvedConfiguration.firstLevelModuleDependencies.each eachDep
  82. }
  83. }
  84. task jarFilter(type: net.corda.gradle.jarfilter.JarFilterTask) {
  85. jars remapJar
  86. annotations {
  87. forRemove = [
  88. "org.jetbrains.annotations.NotNull",
  89. "org.jetbrains.annotations.Nullable",
  90. "org.jetbrains.annotations.ApiStatus\$Experimental",
  91. "org.jetbrains.annotations.ApiStatus\$Internal",
  92. "org.jetbrains.annotations.ApiStatus\$ScheduledForRemoval",
  93. "org.jetbrains.annotations.ApiStatus\$AvailableSince",
  94. "org.jetbrains.annotations.ApiStatus\$NonExtendable",
  95. "org.jetbrains.annotations.ApiStatus\$OverrideOnly"
  96. ]
  97. }
  98. }
  99. task copyJarFilter(type: Copy) {
  100. from jarFilter
  101. into "${project.buildDir}/filtered-libs/"
  102. rename { "${project.archivesBaseName}-${project.version}.jar" }
  103. }
  104. task sourcesJar(type: Jar, dependsOn: classes) {
  105. classifier("sources")
  106. from sourceSets.main.allSource
  107. }
  108. task remapMavenJar(type: RemapJarTask, dependsOn: jar) {
  109. afterEvaluate {
  110. input = file("${project.buildDir}/libs/${archivesBaseName}-${version}-dev.jar")
  111. archiveName = "${archivesBaseName}-${version}.jar"
  112. addNestedDependencies = false
  113. }
  114. }
  115. def releaseChangelog = "No changelog"
  116. /* Thank you modmenu & fablabs */
  117. task releaseOnCf {
  118. def df = new SimpleDateFormat("yyyy-MM-dd HH:mm")
  119. df.setTimeZone(TimeZone.getTimeZone("UTC"))
  120. def branch
  121. if (System.env.BRANCH_NAME) {
  122. branch = System.env.BRANCH_NAME
  123. branch = branch.substring(branch.lastIndexOf("/") + 1)
  124. } else {
  125. branch = "git rev-parse --abbrev-ref HEAD".execute().in.text.trim()
  126. }
  127. if (branch == "HEAD") {
  128. branch = "git rev-parse --short HEAD".execute().in.text.trim()
  129. }
  130. def time = df.format(new Date())
  131. def changes = new StringBuilder()
  132. changes << "<h2>REI v$project.version for $project.supported_version</h2>Updated at <b>$time</b>.<br><a href=\"https://www.github.com/shedaniel/RoughlyEnoughItems/commits/$branch\">Click here for changelog</a>"
  133. def proc = "git log --max-count=200 --pretty=format:%s".execute()
  134. proc.in.eachLine { line ->
  135. def processedLine = line.toString()
  136. if (!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) {
  137. changes << "<br>- ${processedLine.capitalize()}"
  138. }
  139. }
  140. proc.waitFor()
  141. releaseChangelog = changes.toString()
  142. dependsOn tasks.getByName("curseforge")
  143. }
  144. curseforge {
  145. if (project.hasProperty('danielshe_curse_api_key') || System.getenv('danielshe_curse_api_key') != null) {
  146. apiKey = project.hasProperty('danielshe_curse_api_key') ? project.property('danielshe_curse_api_key') : System.getenv('danielshe_curse_api_key')
  147. project {
  148. id = "310111"
  149. releaseType = "beta"
  150. changelogType = "html"
  151. changelog = releaseChangelog
  152. addGameVersion "1.16-Snapshot"
  153. addGameVersion "Java 8"
  154. addGameVersion "Fabric"
  155. relations {
  156. requiredDependency "fabric-api"
  157. embeddedLibrary "cloth"
  158. embeddedLibrary "cloth-config"
  159. embeddedLibrary "auto-config-updated-api"
  160. }
  161. mainArtifact(file("${project.buildDir}/filtered-libs/${project.archivesBaseName}-${project.version}.jar")) {
  162. displayName = "[Fabric $project.supported_version] v$project.version"
  163. }
  164. addArtifact(file("${project.buildDir}/libs/${project.archivesBaseName}-${project.version}-sources.jar")) {
  165. displayName = "[Fabric $project.supported_version] v$project.version Sources"
  166. }
  167. afterEvaluate {
  168. uploadTask.dependsOn("copyJarFilter")
  169. }
  170. }
  171. }
  172. options {
  173. forgeGradleIntegration = false
  174. javaVersionAutoDetect = false
  175. }
  176. }
  177. publishing {
  178. publications {
  179. mavenJava(MavenPublication) {
  180. artifact(file("${project.buildDir}/libs/$archivesBaseName-${version}.jar")) {
  181. builtBy remapMavenJar
  182. }
  183. artifact(sourcesJar) {
  184. builtBy remapSourcesJar
  185. }
  186. }
  187. }
  188. repositories {
  189. if (project.hasProperty('danielshe_pass')) {
  190. maven {
  191. url = "http://deploy.modmuss50.me/"
  192. credentials {
  193. username = "danielshe"
  194. password = project.getProperty('danielshe_pass')
  195. }
  196. }
  197. }
  198. }
  199. }