settings.gradle.kts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. apply(from = "repositories.gradle.kts")
  2. include(":core")
  3. // Load all modules under /lib
  4. File(rootDir, "lib").eachDir { include("lib:${it.name}") }
  5. // Load all modules under /lib-multisrc
  6. File(rootDir, "lib-multisrc").eachDir { include("lib-multisrc:${it.name}") }
  7. if (System.getenv("CI") != "true") {
  8. // Local development (full project build)
  9. /**
  10. * Add or remove modules to load as needed for local development here.
  11. */
  12. loadAllIndividualExtensions()
  13. // loadIndividualExtension("all", "jellyfin")
  14. } else {
  15. // Running in CI (GitHub Actions)
  16. val chunkSize = System.getenv("CI_CHUNK_SIZE").toInt()
  17. val chunk = System.getenv("CI_CHUNK_NUM").toInt()
  18. // Loads individual extensions
  19. File(rootDir, "src").getChunk(chunk, chunkSize)?.forEach {
  20. loadIndividualExtension(it.parentFile.name, it.name)
  21. }
  22. }
  23. fun loadAllIndividualExtensions() {
  24. File(rootDir, "src").eachDir { dir ->
  25. dir.eachDir { subdir ->
  26. loadIndividualExtension(dir.name, subdir.name)
  27. }
  28. }
  29. }
  30. fun loadIndividualExtension(lang: String, name: String) {
  31. include("src:$lang:$name")
  32. }
  33. fun File.getChunk(chunk: Int, chunkSize: Int): List<File>? {
  34. return listFiles()
  35. // Lang folder
  36. ?.filter { it.isDirectory }
  37. // Extension subfolders
  38. ?.mapNotNull { dir -> dir.listFiles()?.filter { it.isDirectory } }
  39. ?.flatten()
  40. ?.sortedBy { it.name }
  41. ?.chunked(chunkSize)
  42. ?.get(chunk)
  43. }
  44. fun File.eachDir(block: (File) -> Unit) {
  45. val files = listFiles() ?: return
  46. for (file in files) {
  47. if (file.isDirectory && file.name != ".gradle" && file.name != "build") {
  48. block(file)
  49. }
  50. }
  51. }