build.gradle 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. plugins {
  2. id 'fabric-loom' version '0.5-SNAPSHOT'
  3. id 'com.github.johnrengelman.shadow' version '6.1.0'
  4. id 'maven-publish'
  5. }
  6. sourceCompatibility = JavaVersion.VERSION_1_8
  7. targetCompatibility = JavaVersion.VERSION_1_8
  8. archivesBaseName = project.archives_base_name
  9. version = project.mod_version
  10. group = project.maven_group
  11. sourceSets {
  12. testMod {
  13. compileClasspath += main.compileClasspath
  14. runtimeClasspath += main.runtimeClasspath
  15. annotationProcessorPath += main.annotationProcessorPath
  16. }
  17. }
  18. repositories {
  19. maven {
  20. url "https://maven.shedaniel.me/"
  21. }
  22. maven {
  23. url "https://maven.terraformersmc.com/"
  24. }
  25. }
  26. dependencies {
  27. // --- Main ---
  28. minecraft("com.mojang:minecraft:${project.minecraft_version}")
  29. mappings("net.fabricmc:yarn:${project.yarn_mappings}:v2")
  30. modImplementation("net.fabricmc:fabric-loader:${project.loader_version}")
  31. modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
  32. exclude(group: "net.fabricmc.fabric-api")
  33. }
  34. // Using modApi because api does not include dependency inside Maven pom file (see https://github.com/FabricMC/fabric-loom/issues/200)
  35. modApi("org.spongepowered:configurate-hocon:${project.configurate_version}")
  36. shadow("org.spongepowered:configurate-hocon:${project.configurate_version}")
  37. compileOnly("org.projectlombok:lombok:${project.lombok_version}")
  38. annotationProcessor("org.projectlombok:lombok:${project.lombok_version}")
  39. // --- Test ---
  40. testImplementation("org.junit.jupiter:junit-jupiter:${project.junit_version}")
  41. testImplementation("org.assertj:assertj-core:${project.assertj_version}")
  42. testImplementation("org.mockito:mockito-inline:${project.mockito_version}")
  43. testImplementation("org.mockito:mockito-junit-jupiter:${project.mockito_junit_version}")
  44. testImplementation("io.github.hakky54:logcaptor:${project.logcaptor_version}")
  45. testImplementation("com.google.jimfs:jimfs:${project.jimfs_version}")
  46. // --- Test Mod ---
  47. testModImplementation(sourceSets.main.output)
  48. modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}")
  49. }
  50. processResources {
  51. inputs.property "version", project.version
  52. filesMatching("fabric.mod.json") {
  53. expand "version": project.version
  54. }
  55. }
  56. tasks.withType(JavaCompile).configureEach {
  57. // ensure that the encoding is set to UTF-8, no matter what the system default is
  58. // this fixes some edge cases with special characters not displaying correctly
  59. // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
  60. it.options.encoding = "UTF-8"
  61. }
  62. java {
  63. // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
  64. // if it is present.
  65. withSourcesJar()
  66. }
  67. jar {
  68. from "LICENSE"
  69. }
  70. shadowJar {
  71. configurations = [project.configurations.shadow]
  72. archiveClassifier = "shadow"
  73. }
  74. remapJar {
  75. dependsOn(shadowJar)
  76. input.set(shadowJar.archiveFile)
  77. }
  78. test {
  79. useJUnitPlatform()
  80. }
  81. javadoc {
  82. options {
  83. source = "8"
  84. encoding = "UTF-8"
  85. charSet = "UTF-8"
  86. memberLevel = JavadocMemberLevel.PROTECTED
  87. // Disable the crazy super-strict doclint tool in Java 8
  88. addStringOption("Xdoclint:none", "-quiet")
  89. }
  90. source = sourceSets.main.allJava
  91. failOnError false
  92. }
  93. task javadocJar(type: Jar) {
  94. dependsOn javadoc
  95. from javadoc.destinationDir
  96. archiveClassifier = "javadoc"
  97. }
  98. build.dependsOn javadocJar
  99. // configure the maven publication
  100. publishing {
  101. publications {
  102. mavenJava(MavenPublication) {
  103. artifact(remapJar) {
  104. builtBy remapJar
  105. }
  106. artifact(sourcesJar) {
  107. builtBy remapSourcesJar
  108. }
  109. artifact javadocJar
  110. }
  111. }
  112. }