build.gradle 7.9 KB

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