build.gradle 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. googleaccessCompileOnly('com.google.guava:guava:31.0.1-jre')
  34. googleaccessCompileOnly('org.jetbrains:annotations:19.0.0')
  35. }
  36. architectury {
  37. injectInjectables = false
  38. common(false)
  39. }
  40. jar {
  41. // Move googleaccess to a directory that does not match the package to prevent accidental loads
  42. into('googleaccess') {
  43. from sourceSets.googleaccess.output
  44. rename { String filename ->
  45. // Add suffix to stop parts of the toolchain from moving these classes to the "correct" package
  46. filename + "_manual"
  47. }
  48. }
  49. from(sourceSets.googleimpl.output)
  50. }
  51. test {
  52. useJUnitPlatform()
  53. }
  54. configurations {
  55. dev
  56. }
  57. artifacts {
  58. dev(jar)
  59. }