Last active
May 15, 2020 00:20
-
-
Save ubiratansoares/e2db55ccc1cc670b9802fb3952f65de4 to your computer and use it in GitHub Desktop.
Magic Modules Blog Post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object GradleModules { | |
const val LOGIN = ":features:login" | |
const val SIGNUP = ":features:signup" | |
const val CATALOG_LIST = ":features:catalog:list" | |
const val CATALOG_DETAILS = ":features:catalog:details" | |
// .... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generated by MagicModules plugin. Mind your Linters! | |
import kotlin.String | |
import kotlin.collections.List | |
object Libraries { | |
const val FEATURES_HOME: String = ":features:home" | |
const val FEATURES_LOGIN: String = ":features:login" | |
const val COMMON_CORE: String = ":common:core" | |
const val COMMON_UTILS: String = ":common:utils" | |
val allAvailable: List<String> = | |
listOf( | |
FEATURES_HOME, | |
FEATURES_LOGIN, | |
COMMON_CORE, | |
COMMON_UTILS | |
) | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rotProject.name='awesome-project' | |
apply plugin: "io.labs.dotanuki.magicmodules" | |
magicModules { | |
includeApps = false | |
} | |
include ':app' | |
// Note that both the app name and the control flag | |
// might be dynamically defined in our your build | |
// (eg, env vars) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MagicModulesPlugin : Plugin<Settings> { | |
override fun apply(target: Settings) { | |
target.computeModulesAndPatchSettings() | |
} | |
private fun Settings.computeModulesAndPatchSettings() { | |
val parsedStructure = ProjectStructureParser().parse(settingsDir) | |
val processedScripts = BuildScriptsProcessor.process(parsedStructure) | |
gradle.settingsEvaluated { | |
processedScripts.forEach { processed -> | |
GradleSettingsPatcher.patch(this, processed) | |
ModuleNamesWriter.write( | |
folder = ResolveOutputFilesDir.using(settingsDir), | |
filename = processed.moduleType.conventionedFileName(), | |
coordinates = processed.coordinates | |
) | |
} | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rootProject.name = 'my-superb-project' | |
include ':features:login' | |
include ':features:signup' | |
include ':features:catalog:list' | |
include ':features:catalog:details' | |
include ':features:catalog:recommendations' | |
// ... | |
include 'core:notifications' | |
include 'core::translations' | |
include 'core::security' | |
include 'core::networking' | |
// ....... | |
include ':dagger-utils' | |
include ':extensions' | |
include ':legacy' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.gradle.api.Plugin | |
import org.gradle.api.Project | |
class SomeGradlePlugin : Plugin<Project> { | |
override fun apply(target: Project) { | |
// Plugin logic here | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.gradle.api.Plugin | |
import org.gradle.api.initialization.Settings | |
class SomeSettingsPlugin : Plugin<Settings> { | |
override fun apply(target: Settings) { | |
// Plugin logic here | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment