build.gradle 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. plugins {
  2. id("fabric-loom") version("0.5-SNAPSHOT") apply false
  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. archivesBaseName = "RoughlyEnoughItems"
  13. version = project.mod_version
  14. group = "me.shedaniel"
  15. allprojects {
  16. apply plugin: 'maven-publish'
  17. apply plugin: 'maven'
  18. apply plugin: 'fabric-loom'
  19. apply plugin: 'net.minecrell.licenser'
  20. apply plugin: 'net.corda.plugins.jar-filter'
  21. sourceCompatibility = targetCompatibility = 1.8
  22. sourceSets {
  23. testmod {
  24. compileClasspath += main.compileClasspath
  25. runtimeClasspath += main.runtimeClasspath
  26. }
  27. }
  28. repositories {
  29. maven { url "https://dl.bintray.com/shedaniel/legacy-yarn-updated" }
  30. maven { url "https://dl.bintray.com/shedaniel/shedaniel-mods" }
  31. mavenLocal()
  32. }
  33. afterEvaluate {
  34. processResources {
  35. filesMatching('fabric.mod.json') {
  36. expand 'version': project.version
  37. }
  38. inputs.property "version", project.version
  39. }
  40. license {
  41. header rootProject.file('HEADER')
  42. include '**/*.java'
  43. }
  44. jar {
  45. from rootProject.file("LICENSE")
  46. }
  47. }
  48. dependencies {
  49. minecraft("com.mojang:minecraft:${project.minecraft_version}")
  50. mappings("me.shedaniel:legacy-yarn:${project.yarn_version}:v2")
  51. modApi("net.fabricmc:fabric-loader:${project.fabricloader_version}")
  52. modApi("net.fabricmc.fabric-api:fabric-api:${project.fabric_api}") {
  53. exclude(module: "fabric-biomes-v1")
  54. }
  55. modApi("me.shedaniel.cloth.api:cloth-client-events-v0:${cloth_client_events_v0_version}") {
  56. transitive(false)
  57. }
  58. modApi("me.shedaniel.cloth:config-2:${cloth_config_version}") {
  59. exclude(module: "fabric-api")
  60. }
  61. modApi("me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig1u}") {
  62. exclude(module: "fabric-api")
  63. }
  64. modApi("org.jetbrains:annotations:19.0.0")
  65. modCompileOnly("io.github.prospector:modmenu:${modmenu_version}") {
  66. transitive(false)
  67. }
  68. modRuntime("io.github.prospector:modmenu:${modmenu_version}") {
  69. transitive(false)
  70. }
  71. modRuntime("me.shedaniel:SmoothScrollingEverywhere:3.0.3-unstable") {
  72. transitive(false)
  73. }
  74. }
  75. tasks.withType(JavaCompile) {
  76. options.encoding = "UTF-8"
  77. }
  78. task sourcesJar(type: Jar, dependsOn: classes) {
  79. classifier("sources")
  80. from sourceSets.main.allSource
  81. }
  82. }
  83. subprojects {
  84. group = rootProject.group
  85. version = rootProject.version
  86. dependencies {
  87. testmodCompile sourceSets.main.output
  88. }
  89. task remapMavenJar(type: Copy, dependsOn: remapJar) {
  90. afterEvaluate {
  91. from("${project.buildDir}/libs/$archivesBaseName-${version}.jar")
  92. into("${project.buildDir}/libs/")
  93. rename { String fn -> "$archivesBaseName-${version}-maven.jar" }
  94. }
  95. }
  96. configurations {
  97. dev
  98. remapped
  99. }
  100. jar {
  101. classifier("dev")
  102. }
  103. remapJar {
  104. input.set(file("${project.buildDir}/filtered-libs/$archivesBaseName-${version}-dev-filtered.jar"))
  105. classifier(null)
  106. }
  107. artifacts {
  108. dev file: file("${project.buildDir}/libs/$archivesBaseName-${version}-dev.jar"), type: "jar", builtBy: jar
  109. remapped file: file("${project.buildDir}/libs/$archivesBaseName-${version}.jar"), type: "jar", builtBy: remapJar
  110. }
  111. task jarFilter(type: net.corda.gradle.jarfilter.JarFilterTask) {
  112. jars jar
  113. annotations {
  114. forRemove = [
  115. "org.jetbrains.annotations.NotNull",
  116. "org.jetbrains.annotations.Nullable",
  117. "org.jetbrains.annotations.ApiStatus\$Experimental",
  118. "org.jetbrains.annotations.ApiStatus\$Internal",
  119. "org.jetbrains.annotations.ApiStatus\$ScheduledForRemoval",
  120. "org.jetbrains.annotations.ApiStatus\$AvailableSince",
  121. "org.jetbrains.annotations.ApiStatus\$NonExtendable",
  122. "org.jetbrains.annotations.ApiStatus\$OverrideOnly"
  123. ]
  124. }
  125. }
  126. remapJar.dependsOn("jarFilter")
  127. publishing {
  128. publications {
  129. create("${archivesBaseName}_mavenJava", MavenPublication) {
  130. afterEvaluate {
  131. artifact(file("${project.buildDir}/libs/$archivesBaseName-${version}-maven.jar")) {
  132. builtBy remapMavenJar
  133. }
  134. artifact(sourcesJar) {
  135. builtBy remapSourcesJar
  136. }
  137. }
  138. }
  139. }
  140. repositories {
  141. if (project.hasProperty('danielshe_pass')) {
  142. maven {
  143. url = "http://deploy.modmuss50.me/"
  144. credentials {
  145. username = "danielshe"
  146. password = project.getProperty('danielshe_pass')
  147. }
  148. }
  149. }
  150. }
  151. }
  152. }
  153. task licenseFormatAll
  154. subprojects { licenseFormatAll.dependsOn("${path}:licenseFormat") }
  155. subprojects { rootProject.remapJar.dependsOn("${path}:remapJar") }
  156. task remapMavenJar(type: RemapJarTask, dependsOn: jar) {
  157. afterEvaluate {
  158. input.set(file("${project.buildDir}/libs/${archivesBaseName}-${version}-dev.jar"))
  159. archiveName = "${archivesBaseName}-${version}-maven.jar"
  160. addNestedDependencies.set(false)
  161. }
  162. }
  163. sourceSets {
  164. testmod
  165. }
  166. dependencies {
  167. afterEvaluate {
  168. subprojects.each {
  169. compile project(path: ":${it.name}", configuration: "dev")
  170. include project(path: ":${it.name}", configuration: "remapped")
  171. testmodCompile project("${it.name}:").sourceSets.testmod.output
  172. }
  173. def listAdded = new ArrayList(Arrays.asList((api_exculde as String).split(',')))
  174. def eachDep = { dep ->
  175. for (apiIncludeDepStr in (api_include as String).split(',')) {
  176. if (apiIncludeDepStr.isEmpty()) continue
  177. def apiIncludeGroup = apiIncludeDepStr.split(':')[0]
  178. def apiIncludeDep = apiIncludeDepStr.split(':')[1]
  179. if (dep.module.id.group == apiIncludeGroup && dep.module.id.name.startsWith(apiIncludeDep)) {
  180. def version = dep.module.id.version.indexOf('@') >= 0 ? dep.module.id.version.substring(0, dep.module.id.version.indexOf('@')) : dep.module.id.version
  181. def mavenDep = "${dep.module.id.group}:${dep.module.id.name}:$version"
  182. if (!(mavenDep in listAdded)) {
  183. include(mavenDep) {
  184. transitive = false
  185. }
  186. listAdded.add(mavenDep)
  187. }
  188. break
  189. }
  190. }
  191. }
  192. rootProject.configurations.compile.resolvedConfiguration.firstLevelModuleDependencies.each eachDep
  193. rootProject.configurations.runtimeClasspath.resolvedConfiguration.firstLevelModuleDependencies.each eachDep
  194. }
  195. }
  196. def releaseChangelog = "No changelog"
  197. /* Thank you modmenu & fablabs */
  198. task releaseOnCf {
  199. def df = new SimpleDateFormat("yyyy-MM-dd HH:mm")
  200. df.setTimeZone(TimeZone.getTimeZone("UTC"))
  201. def branch
  202. if (System.env.BRANCH_NAME) {
  203. branch = System.env.BRANCH_NAME
  204. branch = branch.substring(branch.lastIndexOf("/") + 1)
  205. } else {
  206. branch = "git rev-parse --abbrev-ref HEAD".execute().in.text.trim()
  207. }
  208. if (branch == "HEAD") {
  209. branch = "git rev-parse --short HEAD".execute().in.text.trim()
  210. }
  211. def time = df.format(new Date())
  212. def changes = new StringBuilder()
  213. 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>"
  214. def proc = "git log --max-count=200 --pretty=format:%s".execute()
  215. proc.in.eachLine { line ->
  216. def processedLine = line.toString()
  217. if (!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) {
  218. changes << "<br>- ${processedLine.capitalize()}"
  219. }
  220. }
  221. proc.waitFor()
  222. releaseChangelog = changes.toString()
  223. dependsOn tasks.getByName("curseforge")
  224. }
  225. curseforge {
  226. if (project.hasProperty('danielshe_curse_api_key') || System.getenv('danielshe_curse_api_key') != null) {
  227. apiKey = project.hasProperty('danielshe_curse_api_key') ? project.property('danielshe_curse_api_key') : System.getenv('danielshe_curse_api_key')
  228. project {
  229. id = "310111"
  230. releaseType = "beta"
  231. changelogType = "html"
  232. changelog = releaseChangelog
  233. addGameVersion "1.16-Snapshot"
  234. addGameVersion "Java 8"
  235. addGameVersion "Fabric"
  236. relations {
  237. requiredDependency "fabric-api"
  238. embeddedLibrary "cloth-api"
  239. embeddedLibrary "cloth-config"
  240. embeddedLibrary "auto-config-updated-api"
  241. }
  242. mainArtifact(file("${project.buildDir}/libs/${project.archivesBaseName}-${project.version}.jar")) {
  243. displayName = "[Fabric $project.supported_version] v$project.version"
  244. }
  245. addArtifact(file("${project.buildDir}/libs/${project.archivesBaseName}-${project.version}-sources.jar")) {
  246. displayName = "[Fabric $project.supported_version] v$project.version Sources"
  247. }
  248. afterEvaluate {
  249. uploadTask.dependsOn("build")
  250. }
  251. }
  252. }
  253. options {
  254. forgeGradleIntegration = false
  255. javaVersionAutoDetect = false
  256. }
  257. }
  258. publishing {
  259. publications {
  260. mavenJava(MavenPublication) {
  261. artifact(file("${project.buildDir}/libs/$archivesBaseName-${version}-maven.jar")) {
  262. builtBy remapMavenJar
  263. }
  264. artifact(sourcesJar) {
  265. builtBy remapSourcesJar
  266. }
  267. pom.withXml {
  268. def depsNode = asNode().appendNode("dependencies")
  269. subprojects.each {
  270. def depNode = depsNode.appendNode("dependency")
  271. depNode.appendNode("groupId", it.group)
  272. depNode.appendNode("artifactId", it.name)
  273. depNode.appendNode("version", it.version)
  274. depNode.appendNode("scope", "compile")
  275. }
  276. }
  277. }
  278. }
  279. repositories {
  280. if (project.hasProperty('danielshe_pass')) {
  281. maven {
  282. url = "http://deploy.modmuss50.me/"
  283. credentials {
  284. username = "danielshe"
  285. password = project.getProperty('danielshe_pass')
  286. }
  287. }
  288. }
  289. }
  290. }