build.gradle 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. 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("net.fabricmc: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. modApi("me.shedaniel.cloth:cloth-events:${cloth_events_version}") {
  41. transitive = false
  42. }
  43. modApi("me.shedaniel.cloth:config-2:${cloth_config_version}") {
  44. exclude module: "fabric-api"
  45. }
  46. modApi("me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig1u}") {
  47. exclude module: "fabric-api"
  48. }
  49. modApi("org.jetbrains:annotations:18.0.0")
  50. modCompileOnly("io.github.prospector:modmenu:${modmenu_version}") {
  51. transitive = false
  52. }
  53. modRuntime("io.github.prospector:modmenu:${modmenu_version}") {
  54. transitive = false
  55. }
  56. afterEvaluate {
  57. def listAdded = new ArrayList(Arrays.asList((api_exculde as String).split(',')))
  58. def eachDep = { dep ->
  59. for (apiIncludeDepStr in (api_include as String).split(',')) {
  60. if (apiIncludeDepStr.isEmpty()) continue
  61. def apiIncludeGroup = apiIncludeDepStr.split(':')[0]
  62. def apiIncludeDep = apiIncludeDepStr.split(':')[1]
  63. if (dep.module.id.group == apiIncludeGroup && dep.module.id.name.startsWith(apiIncludeDep)) {
  64. def version = dep.module.id.version.indexOf('@') >= 0 ? dep.module.id.version.substring(0, dep.module.id.version.indexOf('@')) : dep.module.id.version
  65. def mavenDep = "${dep.module.id.group}:${dep.module.id.name}:$version"
  66. if (!(mavenDep in listAdded)) {
  67. include(mavenDep) {
  68. transitive = false
  69. }
  70. listAdded.add(mavenDep)
  71. }
  72. break
  73. }
  74. }
  75. }
  76. configurations.compile.resolvedConfiguration.firstLevelModuleDependencies.each eachDep
  77. configurations.runtimeClasspath.resolvedConfiguration.firstLevelModuleDependencies.each eachDep
  78. }
  79. }
  80. task jarFilter(type: net.corda.gradle.jarfilter.JarFilterTask) {
  81. jars remapJar
  82. annotations {
  83. forRemove = [
  84. "org.jetbrains.annotations.NotNull",
  85. "org.jetbrains.annotations.Nullable",
  86. "org.jetbrains.annotations.ApiStatus\$Experimental",
  87. "org.jetbrains.annotations.ApiStatus\$Internal",
  88. "org.jetbrains.annotations.ApiStatus\$ScheduledForRemoval",
  89. "org.jetbrains.annotations.ApiStatus\$AvailableSince",
  90. "org.jetbrains.annotations.ApiStatus\$NonExtendable",
  91. "org.jetbrains.annotations.ApiStatus\$OverrideOnly"
  92. ]
  93. }
  94. }
  95. task copyJarFilter(type: Copy) {
  96. from jarFilter
  97. into "${project.buildDir}/filtered-libs/"
  98. rename { "${project.archivesBaseName}-${project.version}.jar" }
  99. }
  100. task sourcesJar(type: Jar, dependsOn: classes) {
  101. classifier("sources")
  102. from sourceSets.main.allSource
  103. }
  104. task remapMavenJar(type: RemapJarTask, dependsOn: jar) {
  105. afterEvaluate {
  106. input = file("${project.buildDir}/libs/${archivesBaseName}-${version}-dev.jar")
  107. archiveName = "${archivesBaseName}-${version}.jar"
  108. addNestedDependencies = false
  109. }
  110. }
  111. def releaseChangelog = "No changelog"
  112. /* Thank you modmenu & fablabs */
  113. task releaseOnCf {
  114. def df = new SimpleDateFormat("yyyy-MM-dd HH:mm")
  115. df.setTimeZone(TimeZone.getTimeZone("UTC"))
  116. def branch
  117. if (System.env.BRANCH_NAME) {
  118. branch = System.env.BRANCH_NAME
  119. branch = branch.substring(branch.lastIndexOf("/") + 1)
  120. } else {
  121. branch = "git rev-parse --abbrev-ref HEAD".execute().in.text.trim()
  122. }
  123. if (branch == "HEAD") {
  124. branch = "git rev-parse --short HEAD".execute().in.text.trim()
  125. }
  126. def time = df.format(new Date())
  127. def changes = new StringBuilder()
  128. 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>"
  129. def proc = "git log --max-count=200 --pretty=format:%s".execute()
  130. proc.in.eachLine { line ->
  131. def processedLine = line.toString()
  132. if (!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) {
  133. changes << "<br>- ${processedLine.capitalize()}"
  134. }
  135. }
  136. proc.waitFor()
  137. releaseChangelog = changes.toString()
  138. dependsOn tasks.getByName("curseforge")
  139. }
  140. curseforge {
  141. if (project.hasProperty('danielshe_curse_api_key') || System.getenv('danielshe_curse_api_key') != null) {
  142. apiKey = project.hasProperty('danielshe_curse_api_key') ? project.property('danielshe_curse_api_key') : System.getenv('danielshe_curse_api_key')
  143. project {
  144. id = "310111"
  145. releaseType = "beta"
  146. changelogType = "html"
  147. changelog = releaseChangelog
  148. addGameVersion "1.16-Snapshot"
  149. addGameVersion "Java 8"
  150. addGameVersion "Fabric"
  151. relations {
  152. requiredDependency "fabric-api"
  153. embeddedLibrary "cloth"
  154. embeddedLibrary "cloth-config"
  155. embeddedLibrary "auto-config-updated-api"
  156. }
  157. mainArtifact(file("${project.buildDir}/filtered-libs/${project.archivesBaseName}-${project.version}.jar")) {
  158. displayName = "[Fabric $project.supported_version] v$project.version"
  159. }
  160. addArtifact(file("${project.buildDir}/libs/${project.archivesBaseName}-${project.version}-sources.jar")) {
  161. displayName = "[Fabric $project.supported_version] v$project.version Sources"
  162. }
  163. afterEvaluate {
  164. uploadTask.dependsOn("copyJarFilter")
  165. }
  166. }
  167. }
  168. options {
  169. forgeGradleIntegration = false
  170. javaVersionAutoDetect = false
  171. }
  172. }
  173. publishing {
  174. publications {
  175. mavenJava(MavenPublication) {
  176. artifact(file("${project.buildDir}/libs/$archivesBaseName-${version}.jar")) {
  177. builtBy remapMavenJar
  178. }
  179. artifact(sourcesJar) {
  180. builtBy remapSourcesJar
  181. }
  182. }
  183. }
  184. repositories {
  185. if (project.hasProperty('danielshe_pass')) {
  186. maven {
  187. url = "http://deploy.modmuss50.me/"
  188. credentials {
  189. username = "danielshe"
  190. password = project.getProperty('danielshe_pass')
  191. }
  192. }
  193. }
  194. }
  195. }