diff --git a/src/main/kotlin/com/google/androidstudiopoet/input/AndroidBuildConfig.kt b/src/main/kotlin/com/google/androidstudiopoet/input/AndroidBuildConfig.kt new file mode 100644 index 00000000..fc0955b2 --- /dev/null +++ b/src/main/kotlin/com/google/androidstudiopoet/input/AndroidBuildConfig.kt @@ -0,0 +1,7 @@ +package com.google.androidstudiopoet.input + +class AndroidBuildConfig { + var minSdkVersion: Int? = null + var compileSdkVersion: Int? = null + var targetSdkVersion: Int? = null +} \ No newline at end of file diff --git a/src/main/kotlin/com/google/androidstudiopoet/input/BuildSystemConfig.kt b/src/main/kotlin/com/google/androidstudiopoet/input/BuildSystemConfig.kt new file mode 100644 index 00000000..cc30e246 --- /dev/null +++ b/src/main/kotlin/com/google/androidstudiopoet/input/BuildSystemConfig.kt @@ -0,0 +1,28 @@ +package com.google.androidstudiopoet.input + +/** + * Configuration of the build system, right now only Gradle is supported + */ +class BuildSystemConfig { + /** + * Build system version + */ + var version: String? = null + + /** + * AGP version + */ + var agpVersion: String? = null + + /** + * Kotlin version + */ + var kotlinVersion: String? = null + + + /** + * Default AndroidBuildConfig for all android modules + */ + var defaultAndroidBuildConfig: AndroidBuildConfig? = null + +} diff --git a/src/main/kotlin/com/google/androidstudiopoet/input/DependencyConfig.kt b/src/main/kotlin/com/google/androidstudiopoet/input/DependencyConfig.kt new file mode 100644 index 00000000..5490b798 --- /dev/null +++ b/src/main/kotlin/com/google/androidstudiopoet/input/DependencyConfig.kt @@ -0,0 +1,27 @@ +package com.google.androidstudiopoet.input + +open class DependencyConfig { + + var type: DependencyType? = null + + /** + * Identifies ModuleConfig that this one should depend on + */ + lateinit var moduleNamePrefix: String + +} + +enum class DependencyType { + SINGLE, + BULK +} + +class BulkDependencyConfig: DependencyConfig() { + /** + * Amount of modules from target bulk to depend on. + * If ModuleConfig with ModuleConfig#moduleCount >= 1 contains this BulkDependencyConfig then algorithm will try to + * distribute dependencies evenly, and do its' best to be sure that there are dependencies on the all modules from + * the target bulk + */ + var moduleCount: Int = 1 +} \ No newline at end of file diff --git a/src/main/kotlin/com/google/androidstudiopoet/input/Flavour.kt b/src/main/kotlin/com/google/androidstudiopoet/input/Flavour.kt new file mode 100644 index 00000000..2f65146f --- /dev/null +++ b/src/main/kotlin/com/google/androidstudiopoet/input/Flavour.kt @@ -0,0 +1,7 @@ +package com.google.androidstudiopoet.input + +class Flavour { + var name: String? = null + var dimension: String? = null + var buildConfig: AndroidBuildConfig? = null +} \ No newline at end of file diff --git a/src/main/kotlin/com/google/androidstudiopoet/input/GenerationConfig.kt b/src/main/kotlin/com/google/androidstudiopoet/input/GenerationConfig.kt new file mode 100644 index 00000000..adf9c22c --- /dev/null +++ b/src/main/kotlin/com/google/androidstudiopoet/input/GenerationConfig.kt @@ -0,0 +1,7 @@ +package com.google.androidstudiopoet.input + +class GenerationConfig { + lateinit var inputVersion: String + + lateinit var projectConfig: ProjectConfig +} \ No newline at end of file diff --git a/src/main/kotlin/com/google/androidstudiopoet/input/ModuleConfig.kt b/src/main/kotlin/com/google/androidstudiopoet/input/ModuleConfig.kt new file mode 100644 index 00000000..dcb70317 --- /dev/null +++ b/src/main/kotlin/com/google/androidstudiopoet/input/ModuleConfig.kt @@ -0,0 +1,76 @@ +package com.google.androidstudiopoet.input + +enum class ModuleType { + ANDROID, + PURE +} + +open class ModuleConfig { + + lateinit var moduleType: ModuleType + + /** + * How many modules should be created according to this configuration + */ + var moduleCount: Int? = null + + /** + * Module Name prefix used to create an actual modules names according to formula "$moduleNamePrefix$moduleNumber", + * So if moduleCount = 2 and moduleNamePrefix = "module" then there would be generated two modules with names "module0" and "module1" + * All the module names in the project must be unique + */ + lateinit var moduleNamePrefix: String + + /** + * how many java packages should be generated + */ + var javaPackageCount: Int = 1 + + /** + * how many kotlin packages should be generated + */ + var kotlinPackageCount: Int = 1 + + /** + * how many classes should be generated in each Java package + */ + var javaClassCount: Int = 1 + + /** + * how many classes should be generated in each Kotlin package + */ + var kotlinClassCount: Int = 1 + + /** + * how many methods should be generated in each Java class + */ + var javaMethodCount: Int = 1 + + /** + * how many methods should be generated in each Kotlin class + */ + var kotlinMethodCount: Int = 1 + + var dependencies: List? = listOf() +} + +class AndroidModuleConfig: ModuleConfig() { + /** + * If true then android application plugin is applied. + */ + val isApplication: Boolean? = false + val buildConfig: AndroidBuildConfig? = null + + val numActivities: Int? = 0 + val resourcesConfig: ResourcesConfig? = null + + val flavours: List? = null +} + +class ResourcesConfig { + var stringCount: Int? = null + var imageCount: Int? = null + var layoutCount: Int? = null +} + + diff --git a/src/main/kotlin/com/google/androidstudiopoet/input/NewInputExample.json b/src/main/kotlin/com/google/androidstudiopoet/input/NewInputExample.json new file mode 100644 index 00000000..6e961e8e --- /dev/null +++ b/src/main/kotlin/com/google/androidstudiopoet/input/NewInputExample.json @@ -0,0 +1,103 @@ +{ + //Project configuration is wrapped in another object to help us deal with versioning + "inputVersion": "0.0.1", + "projectConfig": { + "projectName": "genny", + "root": "./modules/", + "buildSystemConfig": { + //Optional param, but it is possible to specify what exactly build system setup should be used + }, + "moduleConfigs": [ + //Even though there are only 3 blocks here, in total 11 modules would be generated. + //One other thing, I believe that we should forbid dependencies withing one block, only interblock dependencies are allowed. + { + //Andorid Application Module + "moduleType": "ANDROID", + "moduleNamePrefix": "app", + "isApplication": true, + + "numActivities": 8, + "resourcesConfig": { + "stringCount": 10, + "imageCount": 9, + "layoutCount": 7 + }, + + "javaPackageCount": 3, + "javaClassCount": 8, + "javaMethodCount": 2000, + + "kotlinPackageCount": 3, + "kotlinClassCount": 5, + "kotlinMethodCount": 1000, + + "dependencies": [ + { + //Depends on the first "pure" module + "type": "SINGLE", + "moduleNamePrefix": "pure" + }, + { + //Depends on the all five "andoirdLib" modules + "type": "SINGLE", + "moduleNamePrefix": "androidLib", + "moduleCount": 5 + } + ], + "flavours": [ + { + "name": "master" + }, + { + "name": "Dev21", + "buildConfig": { + "minSdkVersion": 21 + } + } + ] + }, + { + //5 Pure Java + Kotlin libraries + "moduleType": "PURE", + "moduleCount": 5, + "moduleNamePrefix": "pure", + + "javaPackageCount": 3, + "javaClassCount": 8, + "javaMethodCount": 2000, + + "kotlinPackageCount": 3, + "kotlinClassCount": 5, + "kotlinMethodCount": 1000 + }, + { + //5 Android libraries that depends on corresponding "pure" modules + "moduleType": "ANDROID", + "moduleCount": 5, + "moduleNamePrefix": "androidLib", + + "numActivities": 2, + "resourcesConfig": { + "stringCount": 1, + "imageCount": 5, + "layoutCount": 3 + }, + + "javaPackageCount": 3, + "javaClassCount": 8, + "javaMethodCount": 2000, + + "kotlinPackageCount": 3, + "kotlinClassCount": 5, + "kotlinMethodCount": 1000, + "dependencies": [{ + //Each "androidLib" depends on one "pure" module, so that they together depends on as many modules as possible + "type": "BULK", + "moduleNamePrefix": "pure", + "moduleCount": 1 + } + ] + } + ] + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/google/androidstudiopoet/input/ProjectConfig.kt b/src/main/kotlin/com/google/androidstudiopoet/input/ProjectConfig.kt new file mode 100644 index 00000000..2bd5da47 --- /dev/null +++ b/src/main/kotlin/com/google/androidstudiopoet/input/ProjectConfig.kt @@ -0,0 +1,28 @@ +package com.google.androidstudiopoet.input + +/** + * Configuration of the whole project that should be generated + */ +class ProjectConfig { + + + /** + * Name of the new project + */ + lateinit var projectName: String + + /** + * Directory where generator should put generated project + */ + lateinit var root: String + + /** + * Name of the buildSystemConfig + */ + var buildSystemConfig: BuildSystemConfig? = null + + /** + * Module Configurations + */ + lateinit var moduleConfigs: List +}