build.gradle 7.7 KB

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