build.gradle 6.5 KB

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