build.gradle 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. tasks.withType(JavaCompile) {
  85. options.encoding = "UTF-8"
  86. }
  87. task jarFilter(type: net.corda.gradle.jarfilter.JarFilterTask) {
  88. jars remapJar
  89. annotations {
  90. forRemove = [
  91. "org.jetbrains.annotations.NotNull",
  92. "org.jetbrains.annotations.Nullable",
  93. "org.jetbrains.annotations.ApiStatus\$Experimental",
  94. "org.jetbrains.annotations.ApiStatus\$Internal",
  95. "org.jetbrains.annotations.ApiStatus\$ScheduledForRemoval",
  96. "org.jetbrains.annotations.ApiStatus\$AvailableSince",
  97. "org.jetbrains.annotations.ApiStatus\$NonExtendable",
  98. "org.jetbrains.annotations.ApiStatus\$OverrideOnly"
  99. ]
  100. }
  101. }
  102. task copyJarFilter(type: Copy) {
  103. from jarFilter
  104. into "${project.buildDir}/filtered-libs/"
  105. rename { "${project.archivesBaseName}-${project.version}.jar" }
  106. }
  107. task sourcesJar(type: Jar, dependsOn: classes) {
  108. classifier("sources")
  109. from sourceSets.main.allSource
  110. }
  111. task remapMavenJar(type: RemapJarTask, dependsOn: jar) {
  112. afterEvaluate {
  113. input = file("${project.buildDir}/libs/${archivesBaseName}-${version}-dev.jar")
  114. archiveName = "${archivesBaseName}-${version}.jar"
  115. addNestedDependencies = false
  116. }
  117. }
  118. def releaseChangelog = "No changelog"
  119. /* Thank you modmenu & fablabs */
  120. task releaseOnCf {
  121. def df = new SimpleDateFormat("yyyy-MM-dd HH:mm")
  122. df.setTimeZone(TimeZone.getTimeZone("UTC"))
  123. def branch
  124. if (System.env.BRANCH_NAME) {
  125. branch = System.env.BRANCH_NAME
  126. branch = branch.substring(branch.lastIndexOf("/") + 1)
  127. } else {
  128. branch = "git rev-parse --abbrev-ref HEAD".execute().in.text.trim()
  129. }
  130. if (branch == "HEAD") {
  131. branch = "git rev-parse --short HEAD".execute().in.text.trim()
  132. }
  133. def time = df.format(new Date())
  134. def changes = new StringBuilder()
  135. 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>"
  136. def proc = "git log --max-count=200 --pretty=format:%s".execute()
  137. proc.in.eachLine { line ->
  138. def processedLine = line.toString()
  139. if (!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) {
  140. changes << "<br>- ${processedLine.capitalize()}"
  141. }
  142. }
  143. proc.waitFor()
  144. releaseChangelog = changes.toString()
  145. dependsOn tasks.getByName("curseforge")
  146. }
  147. curseforge {
  148. if (project.hasProperty('danielshe_curse_api_key') || System.getenv('danielshe_curse_api_key') != null) {
  149. apiKey = project.hasProperty('danielshe_curse_api_key') ? project.property('danielshe_curse_api_key') : System.getenv('danielshe_curse_api_key')
  150. project {
  151. id = "310111"
  152. releaseType = "beta"
  153. changelogType = "html"
  154. changelog = releaseChangelog
  155. addGameVersion "1.16-Snapshot"
  156. addGameVersion "Java 8"
  157. addGameVersion "Fabric"
  158. relations {
  159. requiredDependency "fabric-api"
  160. embeddedLibrary "cloth"
  161. embeddedLibrary "cloth-config"
  162. embeddedLibrary "auto-config-updated-api"
  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. }