build.gradle 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. import net.neoforged.moddevgradle.internal.RunGameTask
  2. plugins {
  3. id 'java-library'
  4. id 'eclipse'
  5. id 'idea'
  6. id 'maven-publish'
  7. // Version List: https://projects.neoforged.net/neoforged/ModDevGradle
  8. id 'net.neoforged.moddev' version "${mdg_version}"
  9. id "com.dorongold.task-tree" version "4.0.0"
  10. }
  11. def secrets = new Properties()
  12. def secretsFile = file('secrets.properties')
  13. if (secretsFile.exists()) {
  14. secretsFile.withInputStream {
  15. stream -> secrets.load(stream)
  16. }
  17. fileTree("secrets").matching {
  18. include "**/*.properties"
  19. }.each {
  20. File file ->
  21. file.withInputStream {
  22. stream -> secrets.load(stream)
  23. }
  24. }
  25. }
  26. idea {
  27. module {
  28. downloadJavadoc = true
  29. downloadSources = true
  30. }
  31. }
  32. version = (hasProperty("CIRevision") ? CIRevision : project.mod_version)
  33. group = group_name
  34. java {
  35. toolchain {
  36. languageVersion.set(JavaLanguageVersion.of(21))
  37. }
  38. }
  39. tasks.withType(JavaCompile).configureEach {
  40. options.compilerArgs << "-Xlint:all,-classfile,-processing,-deprecation,-this-escape" << "-Werror"
  41. options.encoding = 'UTF-8'
  42. }
  43. base {
  44. archivesName = "${project.mod_id}-${project.minecraft_version}"
  45. }
  46. subprojects {
  47. version = project(":").version
  48. }
  49. neoForge {
  50. evaluationDependsOnChildren() // we need the subprojects to evaluate first so that the sourceSets are properly constructed
  51. version = project.neo_version
  52. validateAccessTransformers = true
  53. mods {
  54. twilightforest {
  55. sourceSet this.sourceSets.main
  56. }
  57. 'tf-asm' {
  58. sourceSet project(":tf-asm").sourceSets.main
  59. }
  60. }
  61. unitTest {
  62. enable()
  63. testedMod = mods.twilightforest
  64. }
  65. runs {
  66. configureEach {
  67. gameDirectory = project.file('run')
  68. systemProperty 'forge.logging.console.level', 'debug'
  69. logLevel = org.slf4j.event.Level.DEBUG
  70. }
  71. client {
  72. client()
  73. systemProperty 'forge.enabledGameTestNamespaces', mod_id
  74. programArguments.addAll '--username', secrets.getProperty("username") ?: 'Dev', secrets.getProperty("uuid") ? '--uuid' : '', secrets.getProperty("uuid") ?: ''
  75. }
  76. server {
  77. server()
  78. systemProperty 'forge.enabledGameTestNamespaces', mod_id
  79. programArgument '--nogui'
  80. }
  81. clientData {
  82. clientData()
  83. gameDirectory = project.file('run-data')
  84. programArguments.addAll '--mod', mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
  85. }
  86. }
  87. }
  88. afterEvaluate { // DO NOT ASK... it fixes the runClient and family tasks :harold:
  89. tasks.withType(RunGameTask).configureEach {
  90. classpathProvider.setFrom(classpathProvider.files.stream().filter(f -> !f.toString().contains('tf-asm')).toList())
  91. }
  92. }
  93. jar {
  94. exclude 'data/twilightforest/function/**'
  95. if (hasProperty("CIRevision"))
  96. exclude 'data/twilightforest/structure/lich_tower'
  97. }
  98. sourceSets.main.resources { srcDir 'src/generated/resources' }
  99. repositories {
  100. mavenLocal()
  101. maven {
  102. name 'Jared\'s Maven' // JEI
  103. url 'https://maven.blamejared.com/'
  104. }
  105. maven {
  106. name = "OctoStudios" //Curios
  107. url = uri("https://maven.octo-studios.com/releases")
  108. }
  109. maven {
  110. name 'Shedaniel\'s Maven' //REI
  111. url "https://maven.shedaniel.me"
  112. }
  113. maven {
  114. name = "TerraformersMC" //EMI
  115. url = "https://maven.terraformersmc.com/"
  116. }
  117. maven { // TOP
  118. url "https://maven.k-4u.nl"
  119. }
  120. maven { //CS
  121. url "https://nexus.resourcefulbees.com/repository/maven-public/"
  122. }
  123. maven {
  124. name 'Curseforge Maven' // Jade
  125. url "https://www.cursemaven.com"
  126. content {
  127. includeGroup "curse.maven"
  128. }
  129. }
  130. }
  131. dependencies {
  132. // Purely so we can see MDG sources for debugging purposes
  133. compileOnly "net.neoforged.moddev:net.neoforged.moddev.gradle.plugin:${project.mdg_version}"
  134. jarJar implementation(project(":tf-asm"))
  135. //make sure to only pick one of these when testing (switch others to compileOnly)
  136. // implementation "mezz.jei:jei-${project.base_minecraft_version}-neoforge:${project.jei_version}"
  137. // compileOnly "me.shedaniel:RoughlyEnoughItems-neoforge:${project.rei_version}"
  138. // compileOnly "dev.emi:emi-neoforge:${project.emi_version}+${project.base_minecraft_version}"
  139. // theillusivec4
  140. // implementation "top.theillusivec4.curios:curios-neoforge:${project.curios_version}+${project.base_minecraft_version}"
  141. //curse maven
  142. implementation "curse.maven:jade-324717:6011327"
  143. implementation "curse.maven:cosmetic-armor-reworked-237307:5961480"
  144. // runtimeOnly "curse.maven:jeed-532286:5483315"
  145. // runtimeOnly "curse.maven:museum-curator-859070:4629894"
  146. // compileOnly "mcjty.theoneprobe:theoneprobe:${project.top_version}"
  147. //mods we dont have compat with but are nice to have
  148. runtimeOnly "com.telepathicgrunt:CommandStructures-Neoforge:4.4.3+1.21.4"
  149. runtimeOnly "curse.maven:world-edit-225608:6013137"
  150. testImplementation group: 'net.neoforged', name: 'testframework', version: project.neo_version
  151. testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: '5.10.3'
  152. testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.10.3'
  153. testImplementation group: 'org.mockito', name: 'mockito-junit-jupiter', version: '5.12.0'
  154. }
  155. configurations.testImplementation {
  156. exclude module: 'tf-asm'
  157. }
  158. test {
  159. useJUnitPlatform()
  160. testLogging {
  161. events "failed"
  162. showExceptions true
  163. exceptionFormat "full"
  164. showCauses true
  165. showStackTraces true
  166. showStandardStreams = false
  167. }
  168. }
  169. processResources {
  170. def mc = minecraft_version
  171. def neo = neo_version
  172. def ver = project.version
  173. filesMatching("META-INF/neoforge.mods.toml") {
  174. expand([
  175. 'file' : [
  176. 'jarVersion': ver
  177. ],
  178. 'm' : mc,
  179. 'l' : "NeoForge",
  180. 'v': neo,
  181. ])
  182. }
  183. }
  184. jar {
  185. manifest {
  186. archiveClassifier = 'universal'
  187. attributes([
  188. 'Specification-Title' : mod_id,
  189. 'Specification-Vendor' : "TeamTwilight",
  190. 'Specification-Version' : "1",
  191. 'Implementation-Title' : this.project.name,
  192. 'Implementation-Version' : this.project.jar.archiveVersion,
  193. 'Implementation-Vendor' : "TeamTwilight",
  194. 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  195. ])
  196. }
  197. }
  198. publishing {
  199. publications {
  200. create('mavenJava', MavenPublication) {
  201. afterEvaluate {
  202. artifact this.project.jar
  203. artifact this.project.sourceJar
  204. }
  205. groupId 'team-twilight'
  206. artifactId this.project.mod_id
  207. }
  208. }
  209. repositories {
  210. maven {
  211. //url "file:///${project.projectDir}/mcmodsrepo"
  212. url "https://maven.tamaized.com/releases"
  213. credentials {
  214. username System.getenv('ARTIFACTORY_USER')
  215. password System.getenv('ARTIFACTORY_PASS')
  216. }
  217. }
  218. }
  219. }
  220. tasks.register('sourceJar', Jar) {
  221. dependsOn 'classes'
  222. from sourceSets.main.allSource
  223. archiveClassifier = 'sources'
  224. }