build.gradle 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. plugins {
  2. id 'fabric-loom' version '0.4.3'
  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. def forceVersion = ""
  16. version = forceVersion != "" ? forceVersion : project.mod_version
  17. def includeDep = true
  18. minecraft {
  19. accessWidener = file("src/main/resources/rei.aw")
  20. }
  21. license {
  22. header rootProject.file('HEADER')
  23. include '**/*.java'
  24. }
  25. repositories {
  26. }
  27. jar {
  28. from "LICENSE"
  29. }
  30. processResources {
  31. filesMatching('fabric.mod.json') {
  32. expand 'version': project.version
  33. }
  34. inputs.property "version", project.version
  35. }
  36. dependencies {
  37. minecraft("com.mojang:minecraft:${project.minecraft_version}")
  38. mappings("net.fabricmc:yarn:${project.yarn_version}:v2")
  39. modApi("net.fabricmc:fabric-loader:${project.fabricloader_version}")
  40. modApi("net.fabricmc.fabric-api:fabric-api:${project.fabric_api}") {
  41. exclude module: "fabric-biomes-v1"
  42. }
  43. modApi("me.shedaniel.cloth:cloth-events:${cloth_events_version}") {
  44. transitive = false
  45. }
  46. modApi("me.shedaniel.cloth:config-2:${cloth_config_version}") {
  47. exclude module: "fabric-api"
  48. }
  49. modApi("me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig1u}") {
  50. exclude module: "fabric-api"
  51. }
  52. modApi("org.jetbrains:annotations:18.0.0")
  53. modCompileOnly("io.github.prospector:modmenu:${modmenu_version}") {
  54. transitive = false
  55. }
  56. modRuntime("io.github.prospector:modmenu:${modmenu_version}") {
  57. transitive = false
  58. }
  59. if (includeDep) {
  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. }
  85. task jarFilter(type: net.corda.gradle.jarfilter.JarFilterTask) {
  86. jars remapJar
  87. annotations {
  88. forRemove = [
  89. "org.jetbrains.annotations.NotNull",
  90. "org.jetbrains.annotations.Nullable",
  91. "org.jetbrains.annotations.ApiStatus\$Experimental",
  92. "org.jetbrains.annotations.ApiStatus\$Internal",
  93. "org.jetbrains.annotations.ApiStatus\$ScheduledForRemoval",
  94. "org.jetbrains.annotations.ApiStatus\$AvailableSince",
  95. "org.jetbrains.annotations.ApiStatus\$NonExtendable",
  96. "org.jetbrains.annotations.ApiStatus\$OverrideOnly"
  97. ]
  98. }
  99. }
  100. task copyJarFilter(type: Copy) {
  101. from jarFilter
  102. into "${project.buildDir}/filtered-libs/"
  103. rename { "${project.archivesBaseName}-${project.version}.jar" }
  104. }
  105. task sourcesJar(type: Jar, dependsOn: classes) {
  106. classifier("sources")
  107. from sourceSets.main.allSource
  108. }
  109. task remapMavenJar(type: RemapJarTask, dependsOn: jar) {
  110. // classifier = "maven"
  111. afterEvaluate {
  112. //noinspection GroovyAccessibility
  113. input = file("${project.buildDir}/libs/${archivesBaseName}-${version}-dev.jar")
  114. archiveName = "${archivesBaseName}-${version}.jar"
  115. //noinspection GroovyAccessibility
  116. addNestedDependencies = false
  117. }
  118. }
  119. def releaseChangelog = "No changelog"
  120. /* Thank you modmenu & fablabs */
  121. task releaseOnCf {
  122. def df = new SimpleDateFormat("yyyy-MM-dd HH:mm")
  123. df.setTimeZone(TimeZone.getTimeZone("UTC"))
  124. def branch
  125. if (System.env.BRANCH_NAME) {
  126. branch = System.env.BRANCH_NAME
  127. branch = branch.substring(branch.lastIndexOf("/") + 1)
  128. } else {
  129. branch = "git rev-parse --abbrev-ref HEAD".execute().in.text.trim()
  130. }
  131. if (branch == "HEAD") {
  132. branch = "git rev-parse --short HEAD".execute().in.text.trim()
  133. }
  134. def time = df.format(new Date())
  135. def changes = new StringBuilder()
  136. 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>"
  137. def proc = "git log --max-count=200 --pretty=format:%s".execute()
  138. proc.in.eachLine { line ->
  139. def processedLine = line.toString()
  140. if (!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) {
  141. changes << "<br>- ${processedLine.capitalize()}"
  142. }
  143. }
  144. proc.waitFor()
  145. releaseChangelog = changes.toString()
  146. dependsOn tasks.getByName("curseforge")
  147. }
  148. curseforge {
  149. if (project.hasProperty('danielshe_curse_api_key') || System.getenv('danielshe_curse_api_key') != null) {
  150. apiKey = project.hasProperty('danielshe_curse_api_key') ? project.property('danielshe_curse_api_key') : System.getenv('danielshe_curse_api_key')
  151. project {
  152. id = '310111'
  153. releaseType = 'beta'
  154. changelogType = "html"
  155. changelog = releaseChangelog
  156. addGameVersion '1.16-Snapshot'
  157. addGameVersion 'Java 8'
  158. addGameVersion 'Fabric'
  159. relations {
  160. requiredDependency 'fabric-api'
  161. embeddedLibrary 'cloth'
  162. embeddedLibrary 'cloth-config'
  163. }
  164. mainArtifact(file("${project.buildDir}/filtered-libs/${project.archivesBaseName}-${project.version}.jar")) {
  165. displayName = "[Fabric $project.supported_version] v$project.version"
  166. }
  167. addArtifact(file("${project.buildDir}/libs/${project.archivesBaseName}-${project.version}-sources.jar")) {
  168. displayName = "[Fabric $project.supported_version] v$project.version Sources"
  169. }
  170. afterEvaluate {
  171. uploadTask.dependsOn("copyJarFilter")
  172. }
  173. }
  174. }
  175. options {
  176. forgeGradleIntegration = false
  177. javaVersionAutoDetect = false
  178. }
  179. }
  180. publishing {
  181. publications {
  182. mavenJava(MavenPublication) {
  183. artifact(file("${project.buildDir}/libs/$archivesBaseName-${version}.jar")) {
  184. builtBy remapMavenJar
  185. }
  186. artifact(sourcesJar) {
  187. builtBy remapSourcesJar
  188. }
  189. }
  190. }
  191. repositories {
  192. if (project.hasProperty('danielshe_pass')) {
  193. maven {
  194. url = "http://deploy.modmuss50.me/"
  195. credentials {
  196. username = "danielshe"
  197. password = project.getProperty('danielshe_pass')
  198. }
  199. }
  200. }
  201. }
  202. }