build.gradle 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. apply plugin: 'java'
  2. sourceSets {
  3. // Only defines classes that override the package-private Google methods as public, to allow access from other
  4. // packages. Loaded on the app classloader
  5. googleaccess {
  6. java
  7. }
  8. // Defines custom implementations of ImmutableMap (and related classes). These classes live on the transforming/knot
  9. // classloader, but need to be loaded after googleaccess
  10. googleimpl {
  11. java {
  12. compileClasspath += googleaccess.output + main.compileClasspath + main.output
  13. }
  14. }
  15. main {
  16. java {
  17. runtimeClasspath += googleimpl.output
  18. }
  19. }
  20. test {
  21. java {
  22. runtimeClasspath += googleaccess.output + googleimpl.output
  23. }
  24. }
  25. }
  26. dependencies {
  27. compileOnly "com.google.code.findbugs:jsr305:3.+"
  28. // We depend on fabric loader here to use the fabric @Environment annotations
  29. // Do NOT use other classes from fabric loader
  30. modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
  31. testImplementation(platform('org.junit:junit-bom:5.7.1'))
  32. testImplementation('org.junit.jupiter:junit-jupiter')
  33. // Not what MC depends on (21), but Forge/FG sometimes end up with 27 because it's a transitive dependency of
  34. // patchy (Mojang lib for chat blocking)
  35. googleaccessCompileOnly('com.google.guava:guava:27.0.1-jre')
  36. googleaccessCompileOnly('org.jetbrains:annotations:19.0.0')
  37. }
  38. architectury {
  39. injectInjectables = false
  40. common()
  41. }
  42. jar {
  43. // Move googleaccess to a directory that does not match the package to prevent accidental loads
  44. into('googleaccess') {
  45. from sourceSets.googleaccess.output
  46. rename { String filename ->
  47. // Add suffix to stop parts of the toolchain from moving these classes to the "correct" package
  48. filename + "_manual"
  49. }
  50. }
  51. from(sourceSets.googleimpl.output)
  52. }
  53. test {
  54. useJUnitPlatform()
  55. }
  56. configurations {
  57. dev
  58. }
  59. artifacts {
  60. dev(jar)
  61. }