From c881cad5fe406e58bfaf0d17c7b323b9cfbeaff1 Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 30 Oct 2023 16:05:02 -0400 Subject: [PATCH] Document how to load subset of modules for local dev --- CONTRIBUTING.md | 7 +++++ gradle.properties | 2 +- settings.gradle.kts | 63 ++++++++++++++++++++++++++------------------- 3 files changed, 44 insertions(+), 28 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 639dd863c..fe055ba6c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -176,6 +176,13 @@ Each extension should reside in `src//`. Use `all` as `` used in the folder inside `src` should be the major `language` part. For example, if you will be creating a `pt-BR` source, use `` 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 The simplest extension structure looks like this: diff --git a/gradle.properties b/gradle.properties index 08688f6bd..a30adac64 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ # Specifies the JVM arguments used for the daemon process. # 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. # This option should only be used with decoupled projects. More details, visit diff --git a/settings.gradle.kts b/settings.gradle.kts index 62e6f6d93..3e0631f9e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,6 +1,6 @@ include(":core") -// all the directories under /lib instead of manually adding each to a list +// Load all modules under /lib File(rootDir, "lib").eachDir { val libName = it.name include(":lib-$libName") @@ -13,34 +13,14 @@ if (System.getenv("CI") == null || System.getenv("CI_MODULE_GEN") == "true") { include(":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, - * comment out the parts above and uncomment below. + * Add or remove modules to load as needed for local development here. + * To generate multisrc extensions first, run the `:multisrc:generateExtensions` task first. */ -// val lang = "all" -// val name = "mangadex" -// val projectName = ":extensions:individual:$lang:$name" -// val projectName = ":extensions:multisrc:$lang:$name" -// include(projectName) -// project(projectName).projectDir = File("src/${lang}/${name}") -// project(projectName).projectDir = File("generated-src/${lang}/${name}") + loadAllIndividualExtensions() + loadAllGeneratedMultisrcExtensions() + // loadIndividualExtension("all", "mangadex") + // loadGeneratedMultisrcExtension("en", "guya") } else { // 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? { return listFiles() // Lang folder