build.gradle 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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/functions/**'
  92. }
  93. sourceSets.main.resources { srcDir 'src/generated/resources' }
  94. repositories {
  95. mavenLocal()
  96. maven {
  97. name 'Jared\'s Maven' // JEI
  98. url 'https://maven.blamejared.com/'
  99. }
  100. maven {
  101. name = "OctoStudios" //Curios
  102. url = uri("https://maven.octo-studios.com/releases")
  103. }
  104. maven {
  105. name 'Shedaniel\'s Maven' //REI
  106. url "https://maven.shedaniel.me"
  107. }
  108. maven {
  109. name = "TerraformersMC" //EMI
  110. url = "https://maven.terraformersmc.com/"
  111. }
  112. maven { // TOP
  113. url "https://maven.k-4u.nl"
  114. }
  115. maven { //CS
  116. url "https://nexus.resourcefulbees.com/repository/maven-public/"
  117. }
  118. maven {
  119. name 'Curseforge Maven' // Jade
  120. url "https://www.cursemaven.com"
  121. content {
  122. includeGroup "curse.maven"
  123. }
  124. }
  125. }
  126. dependencies {
  127. // Purely so we can see MDG sources for debugging purposes
  128. compileOnly "net.neoforged.moddev:net.neoforged.moddev.gradle.plugin:${project.mdg_version}"
  129. jarJar implementation(project(":tf-asm"))
  130. //make sure to only pick one of these when testing (switch others to compileOnly)
  131. implementation "mezz.jei:jei-${project.base_minecraft_version}-neoforge:${project.jei_version}"
  132. compileOnly "me.shedaniel:RoughlyEnoughItems-neoforge:${project.rei_version}"
  133. compileOnly "dev.emi:emi-neoforge:${project.emi_version}+${project.base_minecraft_version}"
  134. // theillusivec4
  135. implementation "top.theillusivec4.curios:curios-neoforge:${project.curios_version}+${project.base_minecraft_version}"
  136. //curse maven
  137. implementation "curse.maven:jade-324717:5529595"
  138. implementation "curse.maven:cosmetic-armor-reworked-237307:5427303"
  139. // runtimeOnly "curse.maven:jeed-532286:5483315"
  140. // runtimeOnly "curse.maven:museum-curator-859070:4629894"
  141. compileOnly "mcjty.theoneprobe:theoneprobe:${project.top_version}"
  142. //mods we dont have compat with but are nice to have
  143. runtimeOnly "com.telepathicgrunt:CommandStructures-Neoforge:4.3.2+1.20.6"
  144. testImplementation group: 'net.neoforged', name: 'testframework', version: project.neo_version
  145. testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: '5.10.3'
  146. testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.10.3'
  147. testImplementation group: 'org.mockito', name: 'mockito-junit-jupiter', version: '5.12.0'
  148. }
  149. configurations.testImplementation {
  150. exclude module: 'tf-asm'
  151. }
  152. test {
  153. useJUnitPlatform()
  154. testLogging {
  155. events "failed"
  156. showExceptions true
  157. exceptionFormat "full"
  158. showCauses true
  159. showStackTraces true
  160. showStandardStreams = false
  161. }
  162. }
  163. jar {
  164. manifest {
  165. archiveClassifier = 'universal'
  166. attributes([
  167. 'Specification-Title' : mod_id,
  168. 'Specification-Vendor' : "TeamTwilight",
  169. 'Specification-Version' : "1",
  170. 'Implementation-Title' : this.project.name,
  171. 'Implementation-Version' : this.project.jar.archiveVersion,
  172. 'Implementation-Vendor' : "TeamTwilight",
  173. 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  174. ])
  175. }
  176. }
  177. publishing {
  178. publications {
  179. create('mavenJava', MavenPublication) {
  180. afterEvaluate {
  181. artifact this.project.jar
  182. artifact this.project.sourceJar
  183. }
  184. groupId 'team-twilight'
  185. artifactId this.project.mod_id
  186. }
  187. }
  188. repositories {
  189. maven {
  190. //url "file:///${project.projectDir}/mcmodsrepo"
  191. url "https://maven.tamaized.com/releases"
  192. credentials {
  193. username System.getenv('ARTIFACTORY_USER')
  194. password System.getenv('ARTIFACTORY_PASS')
  195. }
  196. }
  197. }
  198. }
  199. tasks.register('sourceJar', Jar) {
  200. dependsOn 'classes'
  201. from sourceSets.main.allSource
  202. archiveClassifier = 'sources'
  203. }
  204. tasks.withType(JavaCompile).configureEach {
  205. options.encoding = 'UTF-8'
  206. }