Document how to load subset of modules for local dev

This commit is contained in:
arkon 2023-10-30 16:05:02 -04:00
parent e2cdf2b34f
commit c881cad5fe
3 changed files with 44 additions and 28 deletions

View File

@ -176,6 +176,13 @@ Each extension should reside in `src/<lang>/<mysourcename>`. Use `all` as `<lang
The `<lang>` used in the folder inside `src` should be the major `language` part. For example, if you will be creating a `pt-BR` source, use `<lang>` here as `pt` only. Inside the source class, use the full locale string instead. The `<lang>` used in the folder inside `src` should be the major `language` part. For example, if you will be creating a `pt-BR` source, use `<lang>` here as `pt` only. Inside the source class, use the full locale string instead.
### Loading a subset of Gradle modules
By default, all individual and generated multisrc extensions are loaded for local development.
This may be inconvenient if you only need to work on one extension at a time.
To adjust which modules are loaded, make adjustments to the `settings.gradle.kts` file as needed.
#### Extension file structure #### Extension file structure
The simplest extension structure looks like this: The simplest extension structure looks like this:

View File

@ -9,7 +9,7 @@
# Specifies the JVM arguments used for the daemon process. # Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings. # The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx5120m org.gradle.jvmargs=-Xmx6144m
# When configured, Gradle will run in incubating parallel mode. # When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit # This option should only be used with decoupled projects. More details, visit

View File

@ -1,6 +1,6 @@
include(":core") include(":core")
// all the directories under /lib instead of manually adding each to a list // Load all modules under /lib
File(rootDir, "lib").eachDir { File(rootDir, "lib").eachDir {
val libName = it.name val libName = it.name
include(":lib-$libName") include(":lib-$libName")
@ -13,34 +13,14 @@ if (System.getenv("CI") == null || System.getenv("CI_MODULE_GEN") == "true") {
include(":multisrc") include(":multisrc")
project(":multisrc").projectDir = File("multisrc") project(":multisrc").projectDir = File("multisrc")
// Loads all extensions
File(rootDir, "src").eachDir { dir ->
dir.eachDir { subdir ->
val name = ":extensions:individual:${dir.name}:${subdir.name}"
include(name)
project(name).projectDir = File("src/${dir.name}/${subdir.name}")
}
}
// Loads all generated extensions from multisrc
File(rootDir, "generated-src").eachDir { dir ->
dir.eachDir { subdir ->
val name = ":extensions:multisrc:${dir.name}:${subdir.name}"
include(name)
project(name).projectDir = File("generated-src/${dir.name}/${subdir.name}")
}
}
/** /**
* If you're developing locally and only want to work with a single module, * Add or remove modules to load as needed for local development here.
* comment out the parts above and uncomment below. * To generate multisrc extensions first, run the `:multisrc:generateExtensions` task first.
*/ */
// val lang = "all" loadAllIndividualExtensions()
// val name = "mangadex" loadAllGeneratedMultisrcExtensions()
// val projectName = ":extensions:individual:$lang:$name" // loadIndividualExtension("all", "mangadex")
// val projectName = ":extensions:multisrc:$lang:$name" // loadGeneratedMultisrcExtension("en", "guya")
// include(projectName)
// project(projectName).projectDir = File("src/${lang}/${name}")
// project(projectName).projectDir = File("generated-src/${lang}/${name}")
} else { } else {
// Running in CI (GitHub Actions) // Running in CI (GitHub Actions)
@ -70,6 +50,35 @@ if (System.getenv("CI") == null || System.getenv("CI_MODULE_GEN") == "true") {
} }
} }
fun loadAllIndividualExtensions() {
File(rootDir, "src").eachDir { dir ->
dir.eachDir { subdir ->
val name = ":extensions:individual:${dir.name}:${subdir.name}"
include(name)
project(name).projectDir = File("src/${dir.name}/${subdir.name}")
}
}
}
fun loadAllGeneratedMultisrcExtensions() {
File(rootDir, "generated-src").eachDir { dir ->
dir.eachDir { subdir ->
val name = ":extensions:multisrc:${dir.name}:${subdir.name}"
include(name)
project(name).projectDir = File("generated-src/${dir.name}/${subdir.name}")
}
}
}
fun loadIndividualExtension(lang: String, name: String) {
val projectName = ":extensions:individual:$lang:$name"
include(projectName)
project(projectName).projectDir = File("src/${lang}/${name}")
}
fun loadGeneratedMultisrcExtension(lang: String, name: String) {
val projectName = ":extensions:multisrc:$lang:$name"
include(projectName)
project(projectName).projectDir = File("generated-src/${lang}/${name}")
}
fun File.getChunk(chunk: Int, chunkSize: Int): List<File>? { fun File.getChunk(chunk: Int, chunkSize: Int): List<File>? {
return listFiles() return listFiles()
// Lang folder // Lang folder