diff --git a/README.md b/README.md index 293b78f9..66e916ff 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ### Список плагинов в репозитории -- [hh-carnival](/plugins/hh-carnival) - плагин для быстрого создания нового feature-модуля, который также добавляет ещё немного полезных вещеё +- [hh-carnival](/plugins/hh-carnival) - плагин для быстрого создания нового feature-модуля, который также добавляет ещё немного полезных вещей - [hh-garcon](/plugins/hh-garcon) - плагин для быстрого создания Page Object-ов из XML-вёрстки - [hh-geminio](/plugins/hh-geminio) - плагин, добавляющий возможность создавать свои шаблоны кода на основе FreeMarker-а diff --git a/build-logic/idea-convention/src/main/kotlin/convention.idea-plugin-base.gradle.kts b/build-logic/idea-convention/src/main/kotlin/convention.idea-plugin-base.gradle.kts index 13898ba6..ef8f63c6 100644 --- a/build-logic/idea-convention/src/main/kotlin/convention.idea-plugin-base.gradle.kts +++ b/build-logic/idea-convention/src/main/kotlin/convention.idea-plugin-base.gradle.kts @@ -24,7 +24,6 @@ configure { plugins.set(currentVersion.pluginsNames) } -@Suppress("UnstableApiUsage") tasks.getByName("instrumentCode") { val currentVersion = Libs.chosenIdeaVersion if (currentVersion is ExternalLibrariesExtension.Product.LocalIde) { diff --git a/build.gradle.kts b/build.gradle.kts index aae117a4..c9223a0d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,11 @@ plugins { staticAnalysis { detekt { - configPath = files(project.rootDir.resolve("build-logic/static-analysis-convention/rules/detekt/detekt-config.yaml")) - baselinePath = file(project.rootDir.resolve("build-logic/static-analysis-convention/rules/detekt/detekt-baseline.xml")) + configPath = files( + project.rootDir.resolve("build-logic/static-analysis-convention/rules/detekt/detekt-config.yaml") + ) + baselinePath = file( + project.rootDir.resolve("build-logic/static-analysis-convention/rules/detekt/detekt-baseline.xml") + ) } } diff --git a/gradle.properties b/gradle.properties index aa47aa5f..3c73adc5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ kotlin.code.style=official systemProp.gradleIntellijPluginVersion=1.12.0 systemProp.gradleChangelogPluginVersion=1.3.1 systemProp.kotlinVersion=1.8.0 -systemProp.detektVersion=1.21.0 +systemProp.detektVersion=1.22.0 systemProp.androidStudioPath=/Applications/Android Studio.app/Contents systemProp.androidStudioCompilerVersion=221.6008.13 diff --git a/infra/scripts/build_all_plugins.sh b/infra/scripts/build_all_plugins.sh index ba7e853d..b1b06447 100644 --- a/infra/scripts/build_all_plugins.sh +++ b/infra/scripts/build_all_plugins.sh @@ -8,6 +8,11 @@ readonly repoUrl=$(prop "${PROPERTY_PLUGINS_REPO_URL}" "${PLUGINS_PROPERTIES_FIL logMessage "Build all plugins..." -bash gradlew clean buildAllPlugins collectUpdatePluginsXmlTask --customRepositoryUrl="${repoUrl}" +bash gradlew \ + clean \ + buildAllPlugins \ + collectUpdatePluginsXmlTask \ + --customRepositoryUrl="${repoUrl}" \ + --no-configuration-cache logMessage "Successfully build all plugins" \ No newline at end of file diff --git a/plugins/hh-carnival/src/main/kotlin/ru/hh/android/plugin/actions/boilerplate/fragment_view_model/GenerateFragmentViewModelNames.kt b/plugins/hh-carnival/src/main/kotlin/ru/hh/android/plugin/actions/boilerplate/fragment_view_model/GenerateFragmentViewModelNames.kt index 04a30ff1..5f070c41 100644 --- a/plugins/hh-carnival/src/main/kotlin/ru/hh/android/plugin/actions/boilerplate/fragment_view_model/GenerateFragmentViewModelNames.kt +++ b/plugins/hh-carnival/src/main/kotlin/ru/hh/android/plugin/actions/boilerplate/fragment_view_model/GenerateFragmentViewModelNames.kt @@ -21,23 +21,24 @@ data class GenerateFragmentViewModelNames( companion object { fun from(featurePrefix: String, packageName: String): GenerateFragmentViewModelNames { - val (modelsPackageName, mviFeaturePackageName, mviFeatureElementPackageName) = if (packageName.isNotBlank()) { - val splitted = packageName.split(".") - val previous = if (splitted.isNotEmpty()) { - packageName.removeSuffix(".${splitted.last()}") + val (modelsPackageName, mviFeaturePackageName, mviFeatureElementPackageName) = + if (packageName.isNotBlank()) { + val splitted = packageName.split(".") + val previous = if (splitted.isNotEmpty()) { + packageName.removeSuffix(".${splitted.last()}") + } else { + packageName + } + + Triple( + "$packageName.model.", + "$previous.feature.", + "$previous.feature.element." + ) } else { - packageName + Triple(String.EMPTY, String.EMPTY, String.EMPTY) } - Triple( - "$packageName.model.", - "$previous.feature.", - "$previous.feature.element." - ) - } else { - Triple(String.EMPTY, String.EMPTY, String.EMPTY) - } - val viewModelClassName = "${featurePrefix}ViewModel" val singleEventClassName = "${featurePrefix}Event" val uiStateClassName = "${featurePrefix}UiState" diff --git a/plugins/hh-carnival/src/main/kotlin/ru/hh/android/plugin/config/view/PluginConfigEditor.kt b/plugins/hh-carnival/src/main/kotlin/ru/hh/android/plugin/config/view/PluginConfigEditor.kt index afac0c99..fdd8480d 100644 --- a/plugins/hh-carnival/src/main/kotlin/ru/hh/android/plugin/config/view/PluginConfigEditor.kt +++ b/plugins/hh-carnival/src/main/kotlin/ru/hh/android/plugin/config/view/PluginConfigEditor.kt @@ -106,7 +106,9 @@ class PluginConfigEditor( initialJiraHostName != jiraHostNameTextField.text || initialJiraUsername != jiraUsernameTextField.text || initialJiraPassword != jiraPasswordTextField.text || - initialJiraDevelopmentTeam != JiraDevelopmentTeam.fromLabel(jiraDevelopmentTeamComboBoxModel.selected.orEmpty()) + initialJiraDevelopmentTeam != JiraDevelopmentTeam.fromLabel( + jiraDevelopmentTeamComboBoxModel.selected.orEmpty() + ) } fun applyNewConfiguration(project: Project, pluginConfig: PluginConfig) { diff --git a/plugins/hh-carnival/src/main/kotlin/ru/hh/android/plugin/core/model/enums/CodeStyleViewDeclaration.kt b/plugins/hh-carnival/src/main/kotlin/ru/hh/android/plugin/core/model/enums/CodeStyleViewDeclaration.kt index 45b99262..13d44006 100644 --- a/plugins/hh-carnival/src/main/kotlin/ru/hh/android/plugin/core/model/enums/CodeStyleViewDeclaration.kt +++ b/plugins/hh-carnival/src/main/kotlin/ru/hh/android/plugin/core/model/enums/CodeStyleViewDeclaration.kt @@ -1,6 +1,5 @@ package ru.hh.android.plugin.core.model.enums - private const val ANDROID_WIDGET_PKG = "android.widget" private const val ANDROIDX_APPCOMPAT_WIDGET_PKG = "androidx.appcompat.widget" diff --git a/plugins/hh-carnival/src/main/kotlin/ru/hh/android/plugin/core/model/jira/JiraDevelopmentTeam.kt b/plugins/hh-carnival/src/main/kotlin/ru/hh/android/plugin/core/model/jira/JiraDevelopmentTeam.kt index f8bc0188..e8e4de5c 100644 --- a/plugins/hh-carnival/src/main/kotlin/ru/hh/android/plugin/core/model/jira/JiraDevelopmentTeam.kt +++ b/plugins/hh-carnival/src/main/kotlin/ru/hh/android/plugin/core/model/jira/JiraDevelopmentTeam.kt @@ -14,6 +14,7 @@ enum class JiraDevelopmentTeam( companion object { - fun fromLabel(label: String): JiraDevelopmentTeam = values().firstOrNull { it.comboBoxLabel == label } ?: MOBILE_CORE + fun fromLabel(label: String): JiraDevelopmentTeam = values().firstOrNull { it.comboBoxLabel == label } + ?: MOBILE_CORE } } diff --git a/plugins/hh-carnival/src/main/kotlin/ru/hh/android/plugin/extensions/PsiDirectoryExt.kt b/plugins/hh-carnival/src/main/kotlin/ru/hh/android/plugin/extensions/PsiDirectoryExt.kt index c26070b3..93808ba7 100644 --- a/plugins/hh-carnival/src/main/kotlin/ru/hh/android/plugin/extensions/PsiDirectoryExt.kt +++ b/plugins/hh-carnival/src/main/kotlin/ru/hh/android/plugin/extensions/PsiDirectoryExt.kt @@ -21,7 +21,10 @@ fun PsiDirectory.findSubdirectoryByPackageName(moduleName: String, packageName: for (item in directoriesNames) { result = result.findSubdirectory(item) ?: throw CopyModuleActionException( - "Can't find main package directory in copying module. Please, check AndroidManifest.xml in \"${moduleName}\" module and make sure that main package name is \"${packageName}\"" + """Can't find main package directory in copying module. + |Please, check AndroidManifest.xml in \"$moduleName\" + |module and make sure that main package name is \"$packageName\""" + .trimMargin() ) } return result diff --git a/plugins/hh-geminio/CHANGELOG.md b/plugins/hh-geminio/CHANGELOG.md index bf400a51..3e2e4004 100644 --- a/plugins/hh-geminio/CHANGELOG.md +++ b/plugins/hh-geminio/CHANGELOG.md @@ -1,21 +1,42 @@ # Geminio +## [1.4.2] + +### Added + +- New `currentDirPackageName` parameter in FTL - add package name from selected folder in specified module. +- New `currentDirOut` parameter in recipes - path to selected directory that launched Geminio's action. +- Improvements for docs. + +## [1.4.1] + +### Added + +- Support `ksp` dependency configuration in Geminio's recipes. + ## [1.4.0] + ### Added -- Support for Android Studio Electric Eel | 2022.1.1 + +- Support for Android Studio Electric Eel | 2022.1.1 ## [1.3.0] + ### Added + - Support for Android Studio Dolphin | 2021.3.1 (thanks to @IlyaGulya) - Added "Enable debug mode" checkbox in settings - Optional Gradle sync after creating files from templates ### Fixed + - Fixed some problems on Android Studio Chipmunk Patch 2 | 2021.2.1 - Fixed too many templates rescan ## [1.2.0] + ### Added + - Sync dialog after creating templates - Display templates folders with recipes only - Ability to rescan templates folders without restarting @@ -23,80 +44,115 @@ - Multi-window support with different projects ### Fixed + - Fixed duplication templates items after reopen project - Fixed 'addGradlePlugin' and other modification commands in files ## [1.1.11] + ### Added + - Support for Android Studio Chipmunk | 2021.2.1 ## [1.1.10] + ### Added -- Ability to change predefined package name for modules templates through -`enableModuleCreationParams.defaultPackageNamePrefix` property in `recipe.xml`. + +- Ability to change predefined package name for modules templates through + `enableModuleCreationParams.defaultPackageNamePrefix` property in `recipe.xml`. ## [1.1.9] + ### Added + - Support for Android Studio Bumblebee | 2021.1.1 ## [1.1.8] + ### Fixed + - Fixed duplication of projects in dependencies after recipe execution ## [1.1.7] + ### Added + - Support for Android Studio Arctic Fox | 2020.3.1 ## [1.1.6] + ### Added + - Support for Android Studio 4.2 ### Changed -- **Breaking change**!!! In Android Studio 4.2 `underlinesToCamelCase` function was removed, - so we renamed `underlinesToCamelCase` modifier in templates into `underscoreToCamelCase`. - + +- **Breaking change**!!! In Android Studio 4.2 `underlinesToCamelCase` function was removed, + so we renamed `underlinesToCamelCase` modifier in templates into `underscoreToCamelCase`. + ### Fixed -- Don't generate actions if there is no Geminio config + +- Don't generate actions if there is no Geminio config ## [1.1.5] + ### Fixed + - Fixed adding dependencies into build.gradle / build.gradle.kts files ## [1.1.4] + ### Added + - [Gradle Changelog Plugin](https://github.com/JetBrains/gradle-changelog-plugin) integration. ### Changed -- Now we configure plugin modules with [gradle convention plugins](https://docs.gradle.org/current/samples/sample_convention_plugins.html); + +- Now we configure plugin modules + with [gradle convention plugins](https://docs.gradle.org/current/samples/sample_convention_plugins.html); - Upgrade Gradle Wrapper to `7.0`; BuildGradleModificationService.kt + ## [1.1.3] + ### Changed + - Remove `'Choose module'` step from modules actions. ## [1.1.2] + ### Changed + - Moved templates actions to the top of `'New'` action group. ### Fixed + - Made `'help'` parameter optional in widgets section. ## [1.1.1] + ### Fixed + - Fix bug with duplicated project service. ## [1.1.0] + ### Added + - Support for modules creation; - A lot of validation messages for recipes to help you properly create new recipes; - New command for recipe: `mkDirs` for creating directories structure; - Predefined variables in `recipe` section: `{manifestOut}` and `{rootOut}`. ## [1.0.1] + ### Added -- Add new command for recipe: `addDependencies` for adding dependencies into build.gradle file; + +- Add new command for recipe: `addDependencies` for adding dependencies into build.gradle file; - New hardcoded parameter in FTL-files: `applicationPackage` - it is package name from AndroidManifest.xml file. ## [1.0.0] + ### Added + - Initial project release. diff --git a/plugins/hh-geminio/README.md b/plugins/hh-geminio/README.md index c924f88a..bbfad414 100644 --- a/plugins/hh-geminio/README.md +++ b/plugins/hh-geminio/README.md @@ -1,6 +1,6 @@ # Geminio -![Geminio](/plugins/hh-geminio/img/Geminio.png) +![Geminio](./img/Geminio.png) **Geminio** -- Android Studio Plugin for generating code from templates. @@ -21,8 +21,8 @@ ## Содержание -- [Как работает плагин](/plugins/hh-geminio/docs/ru/HOW_IT_WORKS.md) -- [Конфигурация плагина](/plugins/hh-geminio/docs/ru/PLUGIN_CONFIG.md) -- [Выражения](/plugins/hh-geminio/docs/ru/EXPRESSIONS.md) -- [Устройство "рецепта"](/plugins/hh-geminio/docs/ru/RECIPE_CONTENT.md) -- [Шаблоны модулей](/plugins/hh-geminio/docs/ru/MODULES_TEMPLATES.md) +- [Как работает плагин](./docs/ru/HOW_IT_WORKS.md) +- [Конфигурация плагина](./docs/ru/PLUGIN_CONFIG.md) +- [Выражения](./docs/ru/EXPRESSIONS.md) +- [Устройство "рецепта"](./docs/ru/RECIPE_CONTENT.md) +- [Шаблоны модулей](./docs/ru/MODULES_TEMPLATES.md) diff --git a/plugins/hh-geminio/README_EN.md b/plugins/hh-geminio/README_EN.md index 232871b4..6a99f27c 100644 --- a/plugins/hh-geminio/README_EN.md +++ b/plugins/hh-geminio/README_EN.md @@ -1,21 +1,25 @@ -# Geminio +# Geminio -![Geminio](/plugins/hh-geminio/img/Geminio.png) +![Geminio](./img/Geminio.png) Android Studio's plugin for generating code from FreeMarker templates ## Why? -Android Studio 4.1 has [disabled support for custom FreeMarker templates](https://issuetracker.google.com/issues/154531807). Previously, you could create custom templates, put them into a specific folder, and then the Android Studio should use your templates as 'Other'-templates. +Android Studio 4.1 +has [disabled support for custom FreeMarker templates](https://issuetracker.google.com/issues/154531807). Previously, +you could create custom templates, put them into a specific folder, and then the Android Studio should use your +templates as 'Other'-templates. -Starting from Android Studio 4.1 you can add custom templates only from IDEA plugins. We at hh.ru are not satisfied with this and we want to add and update templates independently from plugins. +Starting from Android Studio 4.1 you can add custom templates only from IDEA plugins. We at hh.ru are not satisfied with +this and we want to add and update templates independently from plugins. That's what Geminio is for. ## MoC (Map of contents) -- [How the plugins works](/plugins/hh-geminio/docs/en/HOW_IT_WORKS.md) -- [Plugin's configuration](/plugins/hh-geminio/docs/en/PLUGIN_CONFIG.md) -- [Expressions](/plugins/hh-geminio/docs/en/EXPRESSIONS.md) -- [`recipe.yaml` content](/plugins/hh-geminio/docs/en/RECIPE_CONTENT.md) -- [Modules templates](/plugins/hh-geminio/docs/en/MODULES_TEMPLATES.md) \ No newline at end of file +- [How the plugins works](./docs/en/HOW_IT_WORKS.md) +- [Plugin's configuration](./docs/en/PLUGIN_CONFIG.md) +- [Expressions](./docs/en/EXPRESSIONS.md) +- [`recipe.yaml` content](./docs/en/RECIPE_CONTENT.md) +- [Modules templates](./docs/en/MODULES_TEMPLATES.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/en/EXPRESSIONS.md b/plugins/hh-geminio/docs/en/EXPRESSIONS.md index 3b38d1ac..56c7d3fb 100644 --- a/plugins/hh-geminio/docs/en/EXPRESSIONS.md +++ b/plugins/hh-geminio/docs/en/EXPRESSIONS.md @@ -15,7 +15,8 @@ availability: true The text inside `${}` is considered the «dynamic» part of the expression, which needs to be calculated depending on the content. Text outside the curly braces is the fixed part. -Inside `${}` you can use only those parameters that have already been declared ABOVE in the `widgets` (or `globals`) section text. +Inside `${}` you can use only those parameters that have already been declared ABOVE in the `widgets` (or `globals`) +section text. Additional extension functions can be used for text parameters: @@ -28,6 +29,7 @@ Additional extension functions can be used for text parameters: - `underscoreToCamelCase`. There are special values for boolean expressions - `true` / `false` + + you can use only boolean-parameters inside ${} for them Examples of expressions for the recipe section: @@ -35,7 +37,7 @@ Examples of expressions for the recipe section: ```yaml - open: file: ${srcOut}/di/${moduleName}.kt - + - instantiate: from: root/build.gradle.ftl to: ${rootOut}/build.gradle @@ -43,7 +45,7 @@ Examples of expressions for the recipe section: - instantiateAndOpen: from: root/res/layout/fragment_container.xml.ftl to: ${resOut}/layout/${fragmentName}.xml - + - instantiateAndOpen: from: root/main/AndroidManifest.xml to: ${manifestOut}/AndroidManifest.xml @@ -55,7 +57,9 @@ In the `recipe` section, we add several additional parameters for string values: - `manifestOut` - path to the `src/main` folder inside module - `resOut` — path to the res folder inside the module where the template is running; - `srcOut` — path to the src / main / / folder in the module where the template is running. +- `currentDirOut` - path to the folder that was selected in the `Project View` to launch the `Action` of the Geminio + plugin. --- -[Return to MoC](/plugins/hh-geminio/README_EN.md) \ No newline at end of file +[Return to MoC](../../README_EN.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/en/HOW_IT_WORKS.md b/plugins/hh-geminio/docs/en/HOW_IT_WORKS.md index 87aec52f..9b7f7e9a 100644 --- a/plugins/hh-geminio/docs/en/HOW_IT_WORKS.md +++ b/plugins/hh-geminio/docs/en/HOW_IT_WORKS.md @@ -1,8 +1,8 @@ ## How the plugin works -When you open a project in Android Studio, the plugin will scan the specified -folders in search of «recipes» for preparing your templates or modules templates. -For each template, a separate Action (menu item) is created. +When you open a project in Android Studio, the plugin will scan the specified +folders in search of «recipes» for preparing your templates or modules templates. +For each template, a separate Action (menu item) is created. This Action will be added: @@ -11,9 +11,9 @@ This Action will be added: After choosing a template from the menu, the plugin parses the «recipe.yaml» associated with the Action and executes it. -For module templates and regular templates, the appearing content of the wizard will be different, +For module templates and regular templates, the appearing content of the wizard will be different, but the templates themselves support all listed features. --- -[Return to MoC](/plugins/hh-geminio/README_EN.md) \ No newline at end of file +[Return to MoC](../../README_EN.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/en/MODULES_TEMPLATES.md b/plugins/hh-geminio/docs/en/MODULES_TEMPLATES.md index 1ccedd56..6bc6dd97 100644 --- a/plugins/hh-geminio/docs/en/MODULES_TEMPLATES.md +++ b/plugins/hh-geminio/docs/en/MODULES_TEMPLATES.md @@ -1,24 +1,24 @@ ## Modules templates -Templates for modules are slightly different from regular templates, and are designed for -creation of new modules with a specific folder structure, dependencies, content. -When creating a module, Geminio executes the commands specified in the recipe, and also -adds a description of the created module to the `settings.gradle` file, +Templates for modules are slightly different from regular templates, and are designed for +creation of new modules with a specific folder structure, dependencies, content. +When creating a module, Geminio executes the commands specified in the recipe, and also +adds a description of the created module to the `settings.gradle` file, and adds a dependency on the created module to the selected application modules. ### Differences from regular templates - Module templates are available not only inside android modules, but also outside any modules, inside any folder. -- In addition to building a wizard page for filling in parameters from a recipe, - the module template adds two more pages to the wizard: a page for selecting dependencies - on existing modules, and a page for selecting application modules to which +- In addition to building a wizard page for filling in parameters from a recipe, + the module template adds two more pages to the wizard: a page for selecting dependencies + on existing modules, and a page for selecting application modules to which the created module will need to be connected. - Additional parameters are available in FTL-templates of new modules: - * `__applicationsModules` - a list of names of application-modules to which + * `__applicationsModules` - a list of names of application-modules to which the created module will need to be connected. --- -[Return to MoC](/plugins/hh-geminio/README_EN.md) \ No newline at end of file +[Return to MoC](../../README_EN.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/en/PLUGIN_CONFIG.md b/plugins/hh-geminio/docs/en/PLUGIN_CONFIG.md index b7c48895..ec5264c8 100644 --- a/plugins/hh-geminio/docs/en/PLUGIN_CONFIG.md +++ b/plugins/hh-geminio/docs/en/PLUGIN_CONFIG.md @@ -27,4 +27,4 @@ you will need to reload the project for Android Studio could parse the new templ --- -[Return to MoC](/plugins/hh-geminio/README_EN.md) \ No newline at end of file +[Return to MoC](../../README_EN.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/en/RECIPE_CONTENT.md b/plugins/hh-geminio/docs/en/RECIPE_CONTENT.md index 7d4d8295..671620a7 100644 --- a/plugins/hh-geminio/docs/en/RECIPE_CONTENT.md +++ b/plugins/hh-geminio/docs/en/RECIPE_CONTENT.md @@ -105,6 +105,9 @@ recipe: - instantiate: from: root/res/layout/fragment_blank.xml.ftl to: ${resOut}/layout/${fragmentName}.xml + - instantiate: + from: root/src/app_package/BlankViewModel.kt.ftl + to: ${currentDirOut}/presentation/${className}ViewModel.kt - open: file: ${resOut}/layout/${fragmentName}.xml - predicate: @@ -122,6 +125,7 @@ recipe: - addDependencies: - implementation: Libs.jetpack.compose - kapt: Libs.di.toothpick + - ksp: Libs.jetpack.room - compileOnly: com.github.stephanenicolas.toothpick:toothpick:3.1.0 - testImplementation: :shared-core-test - androidTestImplementation: Libs.uiTests.kaspresso @@ -134,8 +138,8 @@ The recipe consists of 6 sections: - `requiredParams` — required parameters for your template; - `optionalParams` — optional parameters; -- `predefinedFeatures` - a set of predefined features in Geminio, which - can add new widgets to the template, supplement the functionality. +- `predefinedFeatures` - a set of predefined features in Geminio, which can add new widgets to the template, supplement + the functionality. - `widgets` — description of template parameters; only string and boolean parameters are available for use; - `globals` - description of invisible parameters for templates, some "global" variables. - `recipe` — a set of instructions that should be executed. @@ -145,17 +149,17 @@ but only combined into a single file, — you are absolutely right. ### Recipe's sections -- [requiredParams](/plugins/hh-geminio/docs/en/recipe_content/REQURED_PARAMS.md) -- [optionalParams](/plugins/hh-geminio/docs/en/recipe_content/OPTIONAL_PARAMS.md) -- [predefinedFeatures](/plugins/hh-geminio/docs/en/recipe_content/PREDEFINED_FEATURES.md) -- [widgets](/plugins/hh-geminio/docs/en/recipe_content/WIDGETS.md) -- [globals](/plugins/hh-geminio/docs/en/recipe_content/GLOBALS.md) -- [recipe](/plugins/hh-geminio/docs/en/recipe_content/RECIPE.md) +- [requiredParams](./recipe_content/REQURED_PARAMS.md) +- [optionalParams](./recipe_content/OPTIONAL_PARAMS.md) +- [predefinedFeatures](./recipe_content/PREDEFINED_FEATURES.md) +- [widgets](./recipe_content/WIDGETS.md) +- [globals](./recipe_content/GLOBALS.md) +- [recipe](./recipe_content/RECIPE.md) ### Additional info -- [Expressions](/plugins/hh-geminio/docs/en/EXPRESSIONS.md) +- [Expressions](./EXPRESSIONS.md) --- -[Return to MoC](/plugins/hh-geminio/README_EN.md) +[Return to MoC](../../README_EN.md) diff --git a/plugins/hh-geminio/docs/en/recipe_content/GLOBALS.md b/plugins/hh-geminio/docs/en/recipe_content/GLOBALS.md index 5d0ea5c0..0dc457bb 100644 --- a/plugins/hh-geminio/docs/en/recipe_content/GLOBALS.md +++ b/plugins/hh-geminio/docs/en/recipe_content/GLOBALS.md @@ -1,13 +1,13 @@ ### `globals` section -It is often necessary to describe a number of "invisible" template parameters, -which are usually not visible to the user, but are actively used in FTL templates. +It is often necessary to describe a number of "invisible" template parameters, +which are usually not visible to the user, but are actively used in FTL templates. The `globals` section is for a quick description of such parameters. -The syntax is similar to `widgets`, but much shorter. +The syntax is similar to `widgets`, but much shorter. Each element of the `globals` section will be transformed into an invisible widget. -Also, this section automatically adds a special checkbox `Show hidden globals values`, +Also, this section automatically adds a special checkbox `Show hidden globals values`, which will show all globals values at once. ```yaml @@ -15,7 +15,7 @@ globals: - stringParameter: id: diModuleClassName value: ${__formattedModuleName}Module - + - booleanParameter: id: someFlag value: ${anotherFlag} @@ -29,9 +29,8 @@ The section supports two types of widgets: Each widget has only two parameters: - `id` - unique widget's identifier; -- `value` - [expression](/plugins/hh-geminio/docs/en/EXPRESSIONS.md) for values calculation. - +- `value` - [expression](../EXPRESSIONS.md) for values calculation. --- -[Back to `recipe.yaml` content](/plugins/hh-geminio/docs/en/RECIPE_CONTENT.md) \ No newline at end of file +[Back to `recipe.yaml` content](../RECIPE_CONTENT.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/en/recipe_content/OPTIONAL_PARAMS.md b/plugins/hh-geminio/docs/en/recipe_content/OPTIONAL_PARAMS.md index 6542ee6c..9c973687 100644 --- a/plugins/hh-geminio/docs/en/recipe_content/OPTIONAL_PARAMS.md +++ b/plugins/hh-geminio/docs/en/recipe_content/OPTIONAL_PARAMS.md @@ -1,54 +1,57 @@ ### `optionalParams` section These parameters are required for the Template Api engine, but in the context of the plugin, -they are not needed yet. Perhaps we will add the ability to automatically add templates through existing extension points, but for now, these parameters **do not affect anything** and you can skip them. +they are not needed yet. Perhaps we will add the ability to automatically add templates through existing extension +points, but for now, these parameters **do not affect anything** and you can skip them. - `revision` — you need this value to override existing templates. Assume you want to override the template for creating a new empty fragment in Android Studio. If your revision value is higher than the standard, and the name of the template matches, then Android Studio should take your template. -- `category` — the category of templates, where the template should appear after adding through extension point. Available values: - * `activity`; - * `fragment`; - * `application`; - * `folder`; - * `ui_component`; - * `automotive`; - * `xml`; - * `wear`; - * `aidl`; - * `widget`; - * `google`; - * `compose`; - * `other`. +- `category` — the category of templates, where the template should appear after adding through extension point. + Available values: + * `activity`; + * `fragment`; + * `application`; + * `folder`; + * `ui_component`; + * `automotive`; + * `xml`; + * `wear`; + * `aidl`; + * `widget`; + * `google`; + * `compose`; + * `other`. - `formFactor` — determines which form-factor the template belongs to. This affects which projects your template can be displayed in. Available values: - * `mobile`; - * `wear`; - * `tv`; - * `automotive`; - * `generic`. + * `mobile`; + * `wear`; + * `tv`; + * `automotive`; + * `generic`. - `constraints` — constraints on the project in which your template can be run. For example, your template should only work in the project that uses Kotlin. Available values for the list: - * `androidx`; - * `kotlin`. + * `androidx`; + * `kotlin`. -- `screens` — list of gallery wizards inside Android Studio where your template should appear. Available values for the list: +- `screens` — list of gallery wizards inside Android Studio where your template should appear. Available values for the + list: - * `new_project`; - * `new_module`; - * `menu_entry`; - * `activity_gallery`; - * `fragment_gallery`. + * `new_project`; + * `new_module`; + * `menu_entry`; + * `activity_gallery`; + * `fragment_gallery`. - `minApi` — the `minSdkVersion` value of the project required for your template. - `minBuildApi` - the `compileSdkVersion` value of the project required for your template. --- -[Back to `recipe.yaml` content](/plugins/hh-geminio/docs/en/RECIPE_CONTENT.md) \ No newline at end of file +[Back to `recipe.yaml` content](../RECIPE_CONTENT.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/en/recipe_content/PREDEFINED_FEATURES.md b/plugins/hh-geminio/docs/en/recipe_content/PREDEFINED_FEATURES.md index be773d1f..c420da0c 100644 --- a/plugins/hh-geminio/docs/en/recipe_content/PREDEFINED_FEATURES.md +++ b/plugins/hh-geminio/docs/en/recipe_content/PREDEFINED_FEATURES.md @@ -5,10 +5,9 @@ wThe section is needed to enable some built-in features inside Geminio. Available list values: -- `enableModuleCreationParams` - adds two text fields for new module's name and its main package name. - After adding this feature, in [expressions](/plugins/hh-geminio/docs/en/EXPRESSIONS.md) of - [`widgets`](/plugins/hh-geminio/docs/en/recipe_content/WIDGETS.md) and [`globals`](/plugins/hh-geminio/docs/en/recipe_content/GLOBALS.md), - sections and also in FTL templates you can use the following parameters: +- `enableModuleCreationParams` - adds two text fields for new module's name and its main package name. + After adding this feature, in [expressions](../EXPRESSIONS.md) of [`widgets`](./WIDGETS.md) + and [`globals`](./GLOBALS.md), sections and also in FTL templates you can use the following parameters: * `__moduleName` - module name * `__packageName` - the packageName of the module that is added to` AndroidManifest.xml` * `__formattedModuleName` is a formatted module name that can be used as a prefix for classes inside a new module. @@ -25,4 +24,4 @@ Here, `ru.hh.test` - new value of your custom package name. --- -[Back to `recipe.yaml` content](/plugins/hh-geminio/docs/en/RECIPE_CONTENT.md) \ No newline at end of file +[Back to `recipe.yaml` content](../RECIPE_CONTENT.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/en/recipe_content/RECIPE.md b/plugins/hh-geminio/docs/en/recipe_content/RECIPE.md index 92a6983a..c2fe485c 100644 --- a/plugins/hh-geminio/docs/en/recipe_content/RECIPE.md +++ b/plugins/hh-geminio/docs/en/recipe_content/RECIPE.md @@ -5,14 +5,14 @@ all necessary parameters in your template. #### Available commands list -- [addDependencies](/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/ADD_DEPENDENCIES.md) -- [addGradlePlugins](/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/ADD_GRADLE_PLUGINS.md) -- [instantiate](/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/INSTANTIATE.md) -- [instantiateAndOpen](/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/INSTANTIATE_AND_OPEN.md) -- [mkDirs](/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/MK_DIRS.md) -- [open](/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/OPEN.md) -- [predicate](/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/PREDICATE.md) +- [addDependencies](./recipe_commands/ADD_DEPENDENCIES.md) +- [addGradlePlugins](./recipe_commands/ADD_GRADLE_PLUGINS.md) +- [instantiate](./recipe_commands/INSTANTIATE.md) +- [instantiateAndOpen](./recipe_commands/INSTANTIATE_AND_OPEN.md) +- [mkDirs](./recipe_commands/MK_DIRS.md) +- [open](./recipe_commands/OPEN.md) +- [predicate](./recipe_commands/PREDICATE.md) --- -[Back to `recipe.yaml` content](/plugins/hh-geminio/docs/en/RECIPE_CONTENT.md) +[Back to `recipe.yaml` content](../RECIPE_CONTENT.md) diff --git a/plugins/hh-geminio/docs/en/recipe_content/REQURED_PARAMS.md b/plugins/hh-geminio/docs/en/recipe_content/REQURED_PARAMS.md index afdfd19d..ce4ef86a 100644 --- a/plugins/hh-geminio/docs/en/recipe_content/REQURED_PARAMS.md +++ b/plugins/hh-geminio/docs/en/recipe_content/REQURED_PARAMS.md @@ -2,12 +2,12 @@ There are only two required parameters for your templates: -- `name` — name of the template (it must be unique among your templates and templates \ - that already exist in Android Studio); +- `name` — name of the template (it must be unique among your templates and templates \ that already exist in Android + Studio); - `description` — description of the template, its functions. The recipe will not start execution without these parameters. --- -[Back to `recipe.yaml` content](/plugins/hh-geminio/docs/en/RECIPE_CONTENT.md) \ No newline at end of file +[Back to `recipe.yaml` content](../RECIPE_CONTENT.md) diff --git a/plugins/hh-geminio/docs/en/recipe_content/WIDGETS.md b/plugins/hh-geminio/docs/en/recipe_content/WIDGETS.md index 379382d4..8ac89a31 100644 --- a/plugins/hh-geminio/docs/en/recipe_content/WIDGETS.md +++ b/plugins/hh-geminio/docs/en/recipe_content/WIDGETS.md @@ -1,9 +1,7 @@ ### `widgets` section -The `widget` section is a user's parameter list for your template. -For now, we support only string and boolean parameters. -Each parameter supports [expression](/plugins/hh-geminio/docs/en/EXPRESSIONS.md) evaluation. - +The `widget` section is a user's parameter list for your template. For now, we support only string and boolean +parameters. Each parameter supports [expression](../EXPRESSIONS.md) evaluation. #### `stringParameter` @@ -12,8 +10,8 @@ Will be converted to a text input field on the UI. The required values inside this block are: -- `id` — parameter identifier. This parameter can be used in - [expression](/plugins/hh-geminio/docs/en/EXPRESSIONS.md) and in FreeMarker templates when generating code; +- `id` — parameter identifier. This parameter can be used in [expression](../EXPRESSIONS.md) and in FreeMarker templates + when generating code; - `name` — the value will be indicated next to the text field when rendering the template. @@ -22,32 +20,37 @@ Optional parameters: - `help` — help for the text field; - `constraints` — constraints for text field validation. Available values: - * `unique`; - * `exists`; - * `nonempty`; - * `activity`; - * `class`; - * `package`; - * `app_package`; - * `module`; - * `layout`; - * `drawable`; - * `navigation`; - * `values`; - * `source_set_folder`; - * `string`; - * `uri_authority`; - * `kotlin_function`. + * `unique`; + * `exists`; + * `nonempty`; + * `activity`; + * `class`; + * `package`; + * `app_package`; + * `module`; + * `layout`; + * `drawable`; + * `navigation`; + * `values`; + * `source_set_folder`; + * `string`; + * `uri_authority`; + * `kotlin_function`. - `default` — the default value of the parameter; -- `suggest` — a string [expression](/plugins/hh-geminio/docs/en/EXPRESSIONS.md) to automatically change the field, which may depend on other fields; -- `visibility` — boolean [expression](/plugins/hh-geminio/docs/en/EXPRESSIONS.md) to show / hide the field depending on the condition; -- `availability` — boolean [expression](/plugins/hh-geminio/docs/en/EXPRESSIONS.md) to switch the field to enabled / disabled state depending on the condition. +- `suggest` — a string [expression](../EXPRESSIONS.md) to automatically change the field, which may depend on other + fields; +- `visibility` — boolean [expression](../EXPRESSIONS.md) to show / hide the field depending on the condition; +- `availability` — boolean [expression](../EXPRESSIONS.md) to switch the field to enabled / disabled state depending on + the condition. #### `booleanParameter` `booleanParameter` — description of the boolean parameter for your template (for example, whether you need to generate -a module, some additional method, and so on). -Will be converted to a checkbox on the UI. +a module, some additional method, and so on). Will be converted to a checkbox on the UI. Has exactly the same parameters as `stringParameter`, but `booleanParameter` has no `suggest`. + +--- + +[Back to `recipe.yaml` content](../RECIPE_CONTENT.md) diff --git a/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/ADD_DEPENDENCIES.md b/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/ADD_DEPENDENCIES.md index 76fea003..38cdd75b 100644 --- a/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/ADD_DEPENDENCIES.md +++ b/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/ADD_DEPENDENCIES.md @@ -10,18 +10,19 @@ Each dependency has the following format: Here: - `` - dependency configuration type, could be one of the following values: - * `compileOnly` - * `api` - * `implementation` - * `testImplementation` - * `androidTestImplementation` - * `kapt` + * `compileOnly` + * `api` + * `implementation` + * `testImplementation` + * `androidTestImplementation` + * `kapt` + * `ksp` - `` - dependency declaration notation. Has three different formats: - * Maven's artifact notation, e.g, `org.company:artifact:version` - * Project dependency, e.g. `:shared-core-model` - * Library constant, e.g. `Libs.jetpack.compose` + * Maven's artifact notation, e.g, `org.company:artifact:version` + * Project dependency, e.g. `:shared-core-model` + * Library constant, e.g. `Libs.jetpack.compose` --- -[Back to the commands list](/plugins/hh-geminio/docs/en/recipe_content/RECIPE.md) \ No newline at end of file +[Back to the commands list](../RECIPE.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/ADD_GRADLE_PLUGINS.md b/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/ADD_GRADLE_PLUGINS.md index 1efb4621..8527c36f 100644 --- a/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/ADD_GRADLE_PLUGINS.md +++ b/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/ADD_GRADLE_PLUGINS.md @@ -13,4 +13,4 @@ Here: --- -[Back to the commands list](/plugins/hh-geminio/docs/en/recipe_content/RECIPE.md) +[Back to the commands list](../RECIPE.md) diff --git a/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/INSTANTIATE.md b/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/INSTANTIATE.md index c9368c57..c4c21c55 100644 --- a/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/INSTANTIATE.md +++ b/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/INSTANTIATE.md @@ -2,16 +2,14 @@ Options: -- `from` — string [expression](/plugins/hh-geminio/docs/en/EXPRESSIONS.md), - usually a relative path from the root of the recipe folder to the desired ftl-template; -- `to` — string [expression](/plugins/hh-geminio/docs/en/EXPRESSIONS.md), - path to the target file with the code. +- `from` — string [expression](../../EXPRESSIONS.md), usually a relative path from the root of the recipe folder to the + desired ftl-template; +- `to` — string [expression](../../EXPRESSIONS.md), path to the target file with the code. -This command takes a FreeMarker ftl-file, the path to which is calculated -from the `from` [expression](/plugins/hh-geminio/docs/en/EXPRESSIONS.md), passes parameters -into it, generates the code and puts the result into the file, the path of which is -specified in the `to` [expression](/plugins/hh-geminio/docs/en/EXPRESSIONS.md). +This command takes a FreeMarker ftl-file, the path to which is calculated from +the `from` [expression](../../EXPRESSIONS.md), passes parameters into it, generates the code and puts the result into +the file, the path of which is specified in the `to` [expression](../../EXPRESSIONS.md). --- -[Back to the commands list](/plugins/hh-geminio/docs/en/recipe_content/RECIPE.md) \ No newline at end of file +[Back to the commands list](../RECIPE.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/INSTANTIATE_AND_OPEN.md b/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/INSTANTIATE_AND_OPEN.md index 248f8e8f..90cfe2e9 100644 --- a/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/INSTANTIATE_AND_OPEN.md +++ b/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/INSTANTIATE_AND_OPEN.md @@ -2,13 +2,12 @@ Options: -- `from` — string [expression](/plugins/hh-geminio/docs/en/EXPRESSIONS.md), - usually a relative path from the root of the recipe folder to the desired ftl-template; -- `to` — string [expression](/plugins/hh-geminio/docs/en/EXPRESSIONS.md), - path to the target file with the code. +- `from` — string [expression](../../EXPRESSIONS.md), usually a relative path from the root of the recipe folder to the + desired ftl-template; +- `to` — string [expression](../../EXPRESSIONS.md), path to the target file with the code. The command combines `instantiate` and `open` commands. --- -[Back to the commands list](/plugins/hh-geminio/docs/en/recipe_content/RECIPE.md) \ No newline at end of file +[Back to the commands list](../RECIPE.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/MK_DIRS.md b/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/MK_DIRS.md index 9a9d6302..680b9834 100644 --- a/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/MK_DIRS.md +++ b/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/MK_DIRS.md @@ -20,8 +20,8 @@ mkDirs: - values ``` -Each list item can be [expression](/plugins/hh-geminio/docs/en/EXPRESSIONS.md). +Each list item can be [expression](../../EXPRESSIONS.md). --- -[Back to the commands list](/plugins/hh-geminio/docs/en/recipe_content/RECIPE.md) \ No newline at end of file +[Back to the commands list](../RECIPE.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/OPEN.md b/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/OPEN.md index 1fba2ee1..8a3dbe92 100644 --- a/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/OPEN.md +++ b/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/OPEN.md @@ -2,10 +2,10 @@ Options: -- `file` — string [expression](/plugins/hh-geminio/docs/en/EXPRESSIONS.md), the path to the target file to open. +- `file` — string [expression](../../EXPRESSIONS.md), the path to the target file to open. The command opens the specified file in the code editor. --- -[Back to the commands list](/plugins/hh-geminio/docs/en/recipe_content/RECIPE.md) \ No newline at end of file +[Back to the commands list](../RECIPE.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/PREDICATE.md b/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/PREDICATE.md index 65da2f4b..eb80603d 100644 --- a/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/PREDICATE.md +++ b/plugins/hh-geminio/docs/en/recipe_content/recipe_commands/PREDICATE.md @@ -2,17 +2,16 @@ Options: -- `validIf` — boolean [expression](/plugins/hh-geminio/docs/en/EXPRESSIONS.md) for calculating the predicate for the specified commands; +- `validIf` — boolean [expression](../../EXPRESSIONS.md) for calculating the predicate for the specified commands; - `commands` — a set of commands to be executed if `validIf` returns `true`. -- `elseCommands` -- a set of commands to be executed if `validIf` returns `false` +- `elseCommands` -- a set of commands to be executed if `validIf` returns `false` -The command calculates the [expression](/plugins/hh-geminio/docs/en/EXPRESSIONS.md) that you specified in `validIf`. -If the result is `true`, then the set of commands that you specify in the `commands` list will be executed. -If `validIf` [expression](/plugins/hh-geminio/docs/en/EXPRESSIONS.md) returns `false`, -`elseCommands` list will be executed. +The command calculates the [expression](../../EXPRESSIONS.md) that you specified in `validIf`. If the result is `true`, +then the set of commands that you specify in the `commands` list will be executed. +If `validIf` [expression](../../EXPRESSIONS.md) returns `false`, `elseCommands` list will be executed. This list supports every other commands. --- -[Back to the commands list](/plugins/hh-geminio/docs/en/recipe_content/RECIPE.md) \ No newline at end of file +[Back to the commands list](../RECIPE.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/ru/EXPRESSIONS.md b/plugins/hh-geminio/docs/ru/EXPRESSIONS.md index 45c63caa..ecf885cf 100644 --- a/plugins/hh-geminio/docs/ru/EXPRESSIONS.md +++ b/plugins/hh-geminio/docs/ru/EXPRESSIONS.md @@ -1,7 +1,7 @@ ## Expressions - выражения -Некоторые настройки параметров шаблона могут быть представлены "выражениями" - -это строчки определённого формата, которые могут быть вычислены для работы шаблонов. +Некоторые настройки параметров шаблона могут быть представлены "выражениями" - это строчки определённого формата, +которые могут быть вычислены для работы шаблонов. Выражения бывают двух типов - текстовые и булевы. @@ -13,9 +13,9 @@ visibility: ${includeModule} availability: true ``` -Текст внутри ${} считается за "динамическую" часть выражения, которую требуется вычислять в зависимости от содержания, +Текст внутри `${}` считается за "динамическую" часть выражения, которую требуется вычислять в зависимости от содержания, текст вне фигурных скобок - фиксированная часть. -Внутри ${} можно использовать только те параметры, которые уже были объявлены ВЫШЕ по тексту рецепта. +Внутри `${}` можно использовать только те параметры, которые уже были объявлены ВЫШЕ по тексту рецепта. Для текстовых параметров можно использовать дополнительные extension-функции: @@ -28,14 +28,15 @@ availability: true - `underscoreToCamelCase` Для булевских выражений есть специальные значения - `true` / `false` -+ для них возможно использование только только boolean-параметров + ++ для них возможно использование только boolean-параметров Примеры выражений для секции `recipe`: ```yaml - open: file: ${srcOut}/di/${moduleName}.kt - + - instantiate: from: root/build.gradle.ftl to: ${rootOut}/build.gradle @@ -43,10 +44,14 @@ availability: true - instantiateAndOpen: from: root/res/layout/fragment_container.xml.ftl to: ${resOut}/layout/${fragmentName}.xml - + - instantiateAndOpen: from: root/main/AndroidManifest.xml to: ${manifestOut}/AndroidManifest.xml + +- instantiate: + from: root/main/MyFile.kt + to: ${currentDirOut}/folder/MyFile.kt ``` В секции `recipe` добавляются 4 встроенных параметра: @@ -55,7 +60,8 @@ availability: true - `manifestOut` - путь до папки `src/main` в модуле - `resOut` - путь до папки `res` внутри модуля - `srcOut` - путь до папки `src//` в модуле +- `currentDirOut` - путь до папки, которая была выбрана в `Project View` для запуска `Action` плагина Geminio. --- -[Обратно к содержанию](/plugins/hh-geminio/README.md#Содержание) \ No newline at end of file +[Обратно к содержанию](../../README.md#Содержание) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/ru/HOW_IT_WORKS.md b/plugins/hh-geminio/docs/ru/HOW_IT_WORKS.md index 44477846..0a91d21b 100644 --- a/plugins/hh-geminio/docs/ru/HOW_IT_WORKS.md +++ b/plugins/hh-geminio/docs/ru/HOW_IT_WORKS.md @@ -3,14 +3,14 @@ При открытии проекта в Android Studio плагин проводит сканирование указанных ему папок в поисках "рецептов" приготовления ваших шаблонов. Для каждого шаблона создаётся отдельный Action (пункт меню), который добавится: -- в меню Generate (Cmd + N - внутри редактора кода) -- в отдельные группы внутри меню New (Cmd + N - в Project View) +- в меню `Generate` (Cmd + N - внутри редактора кода) +- в отдельные группы внутри меню `New` (Cmd + N - в Project View) -После выбора шаблона из меню плагин парсит связанный с Action-ом "рецепт" и выполняет его. +После выбора шаблона из меню плагин парсит связанный с `Action` "рецепт" и выполняет его. Для шаблонов модулей и обычных шаблонов появляющийся наполнение визарда будет отличаться, но сами шаблоны поддерживают все перечисленные фичи. --- -[Обратно к содержанию](/plugins/hh-geminio/README.md#Содержание) \ No newline at end of file +[Обратно к содержанию](../../README.md#Содержание) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/ru/MODULES_TEMPLATES.md b/plugins/hh-geminio/docs/ru/MODULES_TEMPLATES.md index afb0aafb..ade82cc2 100644 --- a/plugins/hh-geminio/docs/ru/MODULES_TEMPLATES.md +++ b/plugins/hh-geminio/docs/ru/MODULES_TEMPLATES.md @@ -1,7 +1,7 @@ ## Шаблоны модулей Шаблоны для модулей немного отличаются от обычных шаблонов, и предназначены для создания новых модулей с определённой -структурой папок, зависимостями, содержанием. При создании модуля Geminio выполняет команды, указанные в рецепте, а ещё +структурой папок, зависимостями, содержанием. При создании модуля Geminio выполняет команды, указанные в рецепте, а ещё добавляет описание созданного модуля в файл `settings.gradle`, а также добавляет зависимость от созданного модуля в выбранные application-модули. @@ -9,13 +9,13 @@ - Шаблоны модулей доступны не только внутри android-модулей, но и вне любых модулей, внутри любой папки. -- Помимо построения страницы wizard-а для заполнения параметров из рецепта, шаблон модуля добавляет ещё две -страницы в wizard: страницу выбора зависимости от существующих модулей, и страницу выбора application-модулей, -к которым нужно будет подключить создаваемый модуль. +- Помимо построения страницы wizard-а для заполнения параметров из рецепта, шаблон модуля добавляет ещё две + страницы в wizard: страницу выбора зависимости от существующих модулей, и страницу выбора application-модулей, + к которым нужно будет подключить создаваемый модуль. - в FTL-шаблонах новых модулей доступны дополнительные параметры: * `__applicationsModules` - список названий application-модулей, в которые нужно будет подключать созданный модуль. --- -[Обратно к содержанию](/plugins/hh-geminio/README.md#Содержание) \ No newline at end of file +[Обратно к содержанию](../../README.md#Содержание) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/ru/PLUGIN_CONFIG.md b/plugins/hh-geminio/docs/ru/PLUGIN_CONFIG.md index 714b1a9d..cef0c6d5 100644 --- a/plugins/hh-geminio/docs/ru/PLUGIN_CONFIG.md +++ b/plugins/hh-geminio/docs/ru/PLUGIN_CONFIG.md @@ -17,16 +17,17 @@ groupsNames: - `modulesTemplatesRootDirPath` - это относительный путь от папки вашего проекта до папки с шаблонами модулей. - `groupNames` - названия групп, в которые будут добавлены action-ы. - * `forNewGroup` - название группы, которая отобразится в меню New (CMD+N на Project View) - * `forNewModulesGroup` - название группы с шаблонами модулей, которая отобразится в меню New (CMD+N на Project View) + * `forNewGroup` - название группы, которая отобразится в меню New (Cmd + N на `Project View`) + * `forNewModulesGroup` - название группы с шаблонами модулей, которая отобразится в меню New (Cmd + N + на `Project View`) - -После создания файла, откройте страничку настроек Preferences -> Appearance & Behavior -> Geminio plugin. -Там выберите путь до файла-конфига, нажмите Apply. +После создания файла, откройте страничку настроек `Preferences` -> `Appearance & Behavior` -> `Geminio plugin`. +Там выберите путь до файла-конфига, нажмите `Apply`. После этого - перезагружайте проект, и ваши шаблоны должны подтянуться. -При добавлении новой папки шаблона (неважно, модулей или обычных), чтобы Android Studio увидела этот шаблон, придётся перезагрузить проект. +При добавлении новой папки шаблона (неважно, модулей или обычных), чтобы Android Studio увидела этот шаблон, придётся +перезагрузить проект. --- -[Обратно к содержанию](/plugins/hh-geminio/README.md#Содержание) \ No newline at end of file +[Обратно к содержанию](../../README.md#Содержание) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/ru/RECIPE_CONTENT.md b/plugins/hh-geminio/docs/ru/RECIPE_CONTENT.md index 02163352..c44fe48a 100644 --- a/plugins/hh-geminio/docs/ru/RECIPE_CONTENT.md +++ b/plugins/hh-geminio/docs/ru/RECIPE_CONTENT.md @@ -105,6 +105,9 @@ recipe: - instantiate: from: root/res/layout/fragment_blank.xml.ftl to: ${resOut}/layout/${fragmentName}.xml + - instantiate: + from: root/src/app_package/BlankViewModel.kt.ftl + to: ${currentDirOut}/presentation/${className}ViewModel.kt - open: file: ${resOut}/layout/${fragmentName}.xml - predicate: @@ -122,6 +125,7 @@ recipe: - addDependencies: - implementation: Libs.jetpack.compose - kapt: Libs.di.toothpick + - ksp: Libs.jetpack.room - compileOnly: com.github.stephanenicolas.toothpick:toothpick:3.1.0 - testImplementation: :shared-core-test - androidTestImplementation: Libs.uiTests.kaspresso @@ -144,17 +148,17 @@ recipe: ### Секции "рецептов" -- [requiredParams](/plugins/hh-geminio/docs/ru/recipe_content/REQURED_PARAMS.md) -- [optionalParams](/plugins/hh-geminio/docs/ru/recipe_content/OPTIONAL_PARAMS.md) -- [predefinedFeatures](/plugins/hh-geminio/docs/ru/recipe_content/PREDEFINED_FEATURES.md) -- [widgets](/plugins/hh-geminio/docs/ru/recipe_content/WIDGETS.md) -- [globals](/plugins/hh-geminio/docs/ru/recipe_content/GLOBALS.md) -- [recipe](/plugins/hh-geminio/docs/ru/recipe_content/RECIPE.md) +- [requiredParams](./recipe_content/REQURED_PARAMS.md) +- [optionalParams](./recipe_content/OPTIONAL_PARAMS.md) +- [predefinedFeatures](./recipe_content/PREDEFINED_FEATURES.md) +- [widgets](./recipe_content/WIDGETS.md) +- [globals](./recipe_content/GLOBALS.md) +- [recipe](./recipe_content/RECIPE.md) ### Дополнительно -- [Выражения](/plugins/hh-geminio/docs/ru/EXPRESSIONS.md) +- [Выражения](./EXPRESSIONS.md) --- -[Обратно к содержанию](/plugins/hh-geminio/README.md#Содержание) +[Обратно к содержанию](../../README.md#Содержание) diff --git a/plugins/hh-geminio/docs/ru/recipe_content/GLOBALS.md b/plugins/hh-geminio/docs/ru/recipe_content/GLOBALS.md index 6b131f90..23e21220 100644 --- a/plugins/hh-geminio/docs/ru/recipe_content/GLOBALS.md +++ b/plugins/hh-geminio/docs/ru/recipe_content/GLOBALS.md @@ -29,8 +29,8 @@ globals: Каждый виджет имеет всего два параметра: - `id` - уникальный идентификатор виджета; -- `value` - [выражение](/plugins/hh-geminio/docs/ru/EXPRESSIONS.md) для вычисления значения. +- `value` - [выражение](../EXPRESSIONS.md) для вычисления значения. --- -[Обратно к устройству "рецептов"](/plugins/hh-geminio/docs/ru/RECIPE_CONTENT.md) \ No newline at end of file +[Обратно к устройству "рецептов"](../RECIPE_CONTENT.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/ru/recipe_content/OPTIONAL_PARAMS.md b/plugins/hh-geminio/docs/ru/recipe_content/OPTIONAL_PARAMS.md index 06a9dad5..9fdee2cb 100644 --- a/plugins/hh-geminio/docs/ru/recipe_content/OPTIONAL_PARAMS.md +++ b/plugins/hh-geminio/docs/ru/recipe_content/OPTIONAL_PARAMS.md @@ -53,4 +53,4 @@ --- -[Обратно к устройству "рецептов"](/plugins/hh-geminio/docs/ru/RECIPE_CONTENT.md) \ No newline at end of file +[Обратно к устройству "рецептов"](../RECIPE_CONTENT.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/ru/recipe_content/PREDEFINED_FEATURES.md b/plugins/hh-geminio/docs/ru/recipe_content/PREDEFINED_FEATURES.md index c20802ad..5e933c4b 100644 --- a/plugins/hh-geminio/docs/ru/recipe_content/PREDEFINED_FEATURES.md +++ b/plugins/hh-geminio/docs/ru/recipe_content/PREDEFINED_FEATURES.md @@ -1,17 +1,16 @@ ### Секция `predefinedFeatures` -Секция нужна для включения некоторых встроенных фич внутри Geminio. +Секция нужна для включения некоторых встроенных фич внутри Geminio. Возможные значения списка: -- `enableModuleCreationParams` - добавляет два текстовых поля для ввода имени нового модуля и его основного packageName-а. -После добавления этой фичи, в [выражениях](/plugins/hh-geminio/docs/ru/EXPRESSIONS.md) - секций [`widgets`](/plugins/hh-geminio/docs/ru/recipe_content/WIDGETS.md) и [`globals`](/plugins/hh-geminio/docs/ru/recipe_content/GLOBALS.md), - а также в FTL-шаблонах можно использовать следующие параметры: - * `__moduleName` - имя модуля - * `__packageName` - packageName модуля, который добавляется в `AndroidManifest.xml` - * `__formattedModuleName` - отформатированное имя модуля, которое можно использовать - в качестве префикса для классов внутри нового модуля. +- `enableModuleCreationParams` - добавляет два текстовых поля для ввода имени нового модуля и его основного + packageName-а. После добавления этой фичи, в [выражениях](../EXPRESSIONS.md) секций [`widgets`](./WIDGETS.md) + и [`globals`](./GLOBALS.md), а также в FTL-шаблонах можно использовать следующие параметры: + * `__moduleName` - имя модуля + * `__packageName` - packageName модуля, который добавляется в `AndroidManifest.xml` + * `__formattedModuleName` - отформатированное имя модуля, которое можно использовать + в качестве префикса для классов внутри нового модуля. Также есть возможность изменить значение базового package name-а, подставляемого в шаблон модуля, с помощью свойства: @@ -22,8 +21,8 @@ predefinedFeatures: defaultPackageNamePrefix: ru.hh.test ``` -Здесь `ru.hh.test` - значение нужного вам custom-пакета. +Здесь `ru.hh.test` - значение нужного вам custom-пакета. --- -[Обратно к устройству "рецептов"](/plugins/hh-geminio/docs/ru/RECIPE_CONTENT.md) \ No newline at end of file +[Обратно к устройству "рецептов"](../RECIPE_CONTENT.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/ru/recipe_content/RECIPE.md b/plugins/hh-geminio/docs/ru/recipe_content/RECIPE.md index 9faed871..f9543c91 100644 --- a/plugins/hh-geminio/docs/ru/recipe_content/RECIPE.md +++ b/plugins/hh-geminio/docs/ru/recipe_content/RECIPE.md @@ -5,14 +5,14 @@ #### Список доступных команд -- [addDependencies](/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/ADD_DEPENDENCIES.md) -- [addGradlePlugins](/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/ADD_GRADLE_PLUGINS.md) -- [instantiate](/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/INSTANTIATE.md) -- [instantiateAndOpen](/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/INSTANTIATE_AND_OPEN.md) -- [mkDirs](/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/MK_DIRS.md) -- [open](/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/OPEN.md) -- [predicate](/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/PREDICATE.md) +- [addDependencies](./recipe_commands/ADD_DEPENDENCIES.md) +- [addGradlePlugins](./recipe_commands/ADD_GRADLE_PLUGINS.md) +- [instantiate](./recipe_commands/INSTANTIATE.md) +- [instantiateAndOpen](./recipe_commands/INSTANTIATE_AND_OPEN.md) +- [mkDirs](./recipe_commands/MK_DIRS.md) +- [open](./recipe_commands/OPEN.md) +- [predicate](./recipe_commands/PREDICATE.md) --- -[Обратно к устройству "рецептов"](/plugins/hh-geminio/docs/ru/RECIPE_CONTENT.md) +[Обратно к устройству "рецептов"](../RECIPE_CONTENT.md) diff --git a/plugins/hh-geminio/docs/ru/recipe_content/REQURED_PARAMS.md b/plugins/hh-geminio/docs/ru/recipe_content/REQURED_PARAMS.md index 5b3be9db..9a7f3d79 100644 --- a/plugins/hh-geminio/docs/ru/recipe_content/REQURED_PARAMS.md +++ b/plugins/hh-geminio/docs/ru/recipe_content/REQURED_PARAMS.md @@ -9,4 +9,4 @@ --- -[Обратно к устройству "рецептов"](/plugins/hh-geminio/docs/ru/RECIPE_CONTENT.md) \ No newline at end of file +[Обратно к устройству "рецептов"](../RECIPE_CONTENT.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/ru/recipe_content/WIDGETS.md b/plugins/hh-geminio/docs/ru/recipe_content/WIDGETS.md index 6712a2b7..afa13ad2 100644 --- a/plugins/hh-geminio/docs/ru/recipe_content/WIDGETS.md +++ b/plugins/hh-geminio/docs/ru/recipe_content/WIDGETS.md @@ -1,14 +1,13 @@ ### Секция `widgets` Секция виджетов - это список параметров вашего шаблона, которые зависят от пользователя. -В данный момент поддерживаются строковые и булевские параметры. -Параметры поддерживают вычисление [выражений](/plugins/hh-geminio/docs/ru/EXPRESSIONS.md). - +В данный момент поддерживаются строковые и булевские параметры. +Параметры поддерживают вычисление [выражений](../EXPRESSIONS.md). #### `stringParameter` -`stringParameter` - описание строкового параметра для вашего шаблона (например, название класса, названиие layout-а и т.д). -Будет преобразовано в текстовое поле ввода на UI. +`stringParameter` - описание строкового параметра для вашего шаблона (например, название класса, названиие layout-а и +т.д). Будет преобразовано в текстовое поле ввода на UI. Обязательными значениями внутри этого блока являются: @@ -41,17 +40,19 @@ * `kotlin_function` - `default` - значение параметра по умолчанию -- `suggest` - текстовое [выражение](/plugins/hh-geminio/docs/ru/EXPRESSIONS.md) для автоматического изменения поля, которое может зависеть от других полей -- `visibility` - булево [выражение](/plugins/hh-geminio/docs/ru/EXPRESSIONS.md) для показа / скрытия поля в зависимости от условия -- `availability` - булево [выражение](/plugins/hh-geminio/docs/ru/EXPRESSIONS.md) для переключения поля в состояния enabled / disabled в зависимости от условия +- `suggest` - текстовое [выражение](../EXPRESSIONS.md) для автоматического изменения поля, которое может зависеть от + других полей +- `visibility` - булево [выражение](../EXPRESSIONS.md) для показа / скрытия поля в зависимости от условия +- `availability` - булево [выражение](../EXPRESSIONS.md) для переключения поля в состояния enabled / disabled в + зависимости от условия #### `booleanParameter` -`booleanParameter` - описание булевого параметра для вашего шаблона (например, нужно ли сгенерировать модуль, какой-то доп. метод и так далее). -Будет преобразовано в чекбокс на UI. +`booleanParameter` - описание булевого параметра для вашего шаблона (например, нужно ли сгенерировать модуль, какой-то +доп. метод и так далее). Будет преобразовано в чекбокс на UI. Имеет ровно такие же параметры, как и `stringParamter`, только у `booleanParameter` нет `suggest`. --- -[Обратно к устройству "рецептов"](/plugins/hh-geminio/docs/ru/RECIPE_CONTENT.md) \ No newline at end of file +[Обратно к устройству "рецептов"](../RECIPE_CONTENT.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/ADD_DEPENDENCIES.md b/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/ADD_DEPENDENCIES.md index afdd4e9c..6223c521 100644 --- a/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/ADD_DEPENDENCIES.md +++ b/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/ADD_DEPENDENCIES.md @@ -16,6 +16,7 @@ * `testImplementation` * `androidTestImplementation` * `kapt` + * `ksp` - `` - нотация объявления зависимости. Имеет три поддерживаемых формата: * Нотация Maven-артефакта, например, `org.company:artifact:version` @@ -24,4 +25,4 @@ --- -[Обратно к списку команд](/plugins/hh-geminio/docs/ru/recipe_content/RECIPE.md) \ No newline at end of file +[Обратно к списку команд](../RECIPE.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/ADD_GRADLE_PLUGINS.md b/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/ADD_GRADLE_PLUGINS.md index e00ed69e..9649bd9a 100644 --- a/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/ADD_GRADLE_PLUGINS.md +++ b/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/ADD_GRADLE_PLUGINS.md @@ -13,4 +13,4 @@ --- -[Обратно к списку команд](/plugins/hh-geminio/docs/ru/recipe_content/RECIPE.md) +[Обратно к списку команд](../RECIPE.md) diff --git a/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/INSTANTIATE.md b/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/INSTANTIATE.md index 624b5fe4..a7597615 100644 --- a/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/INSTANTIATE.md +++ b/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/INSTANTIATE.md @@ -2,13 +2,14 @@ Параметры: -- `from` -- текстовое [выражение](/plugins/hh-geminio/docs/ru/EXPRESSIONS.md), обычно - относительный путь от корня папки с рецептом до нужного ftl-шаблона -- `to` -- текстовое [выражение](/plugins/hh-geminio/docs/ru/EXPRESSIONS.md), путь до целевого файла с кодом +- `from` -- текстовое [выражение](../../EXPRESSIONS.md), обычно - относительный путь от корня + папки с рецептом до нужного ftl-шаблона. +- `to` -- текстовое [выражение](../../EXPRESSIONS.md), путь до целевого файла с кодом. -Команда берёт freemarker-ный ftl-файл, путь до которого вычисляется из [выражение](/plugins/hh-geminio/docs/ru/EXPRESSIONS.md) `from`, +Команда берёт freemarker-ный ftl-файл, путь до которого вычисляется из [выражения](../../EXPRESSIONS.md) `from`, пробрасывает в него параметры, генерирует код, и помещает результат в файл, путь которого указан -в [выражение](/plugins/hh-geminio/docs/ru/EXPRESSIONS.md) `to`. +в [выражении](../../EXPRESSIONS.md) `to`. --- -[Обратно к списку команд](/plugins/hh-geminio/docs/ru/recipe_content/RECIPE.md) \ No newline at end of file +[Обратно к списку команд](../RECIPE.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/INSTANTIATE_AND_OPEN.md b/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/INSTANTIATE_AND_OPEN.md index 1d6849f9..fd718cf2 100644 --- a/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/INSTANTIATE_AND_OPEN.md +++ b/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/INSTANTIATE_AND_OPEN.md @@ -2,14 +2,13 @@ Параметры: -- `from` -- текстовое [выражение](/plugins/hh-geminio/docs/ru/EXPRESSIONS.md), - обычно - относительный путь от корня папки с рецептом до нужного ftl-шаблона -- `to` -- текстовое [выражение](/plugins/hh-geminio/docs/ru/EXPRESSIONS.md), - путь до целевого файла с кодом +- `from` -- текстовое [выражение](../../EXPRESSIONS.md), обычно - относительный путь от корня папки с рецептом до + нужного ftl-шаблона. +- `to` -- текстовое [выражение](../../EXPRESSIONS.md), путь до целевого файла с кодом. -Команда сразу совмещает в себе команды [instantiate](/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/INSTANTIATE.md) и -[open](/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/OPEN.md) - создаёт и открывает файл по пути `to`. +Команда сразу совмещает в себе команды [instantiate](./INSTANTIATE.md) и [open](./OPEN.md) - создаёт и открывает файл по +пути `to`. --- -[Обратно к списку команд](/plugins/hh-geminio/docs/ru/recipe_content/RECIPE.md) \ No newline at end of file +[Обратно к списку команд](../RECIPE.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/MK_DIRS.md b/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/MK_DIRS.md index b1a48aa7..2bd301fc 100644 --- a/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/MK_DIRS.md +++ b/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/MK_DIRS.md @@ -20,8 +20,8 @@ mkDirs: - values ``` -Каждый элемент списка может быть представлен [выражением](/plugins/hh-geminio/docs/ru/EXPRESSIONS.md). +Каждый элемент списка может быть представлен [выражением](../../EXPRESSIONS.md). --- -[Обратно к списку команд](/plugins/hh-geminio/docs/ru/recipe_content/RECIPE.md) \ No newline at end of file +[Обратно к списку команд](../RECIPE.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/OPEN.md b/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/OPEN.md index 5ac94198..f1953b3f 100644 --- a/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/OPEN.md +++ b/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/OPEN.md @@ -2,10 +2,10 @@ Параметры: -- `file` -- текстовое [выражение](/plugins/hh-geminio/docs/ru/EXPRESSIONS.md), путь до целевого файла, который нужно открыть +- `file` -- текстовое [выражение](../../EXPRESSIONS.md), путь до целевого файла, который нужно открыть Команда открывает в редакторе кода указанный файл. --- -[Обратно к списку команд](/plugins/hh-geminio/docs/ru/recipe_content/RECIPE.md) \ No newline at end of file +[Обратно к списку команд](../RECIPE.md) \ No newline at end of file diff --git a/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/PREDICATE.md b/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/PREDICATE.md index 2122af19..1669b997 100644 --- a/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/PREDICATE.md +++ b/plugins/hh-geminio/docs/ru/recipe_content/recipe_commands/PREDICATE.md @@ -2,19 +2,19 @@ Параметры: -- `validIf` -- булево [выражение](/plugins/hh-geminio/docs/ru/EXPRESSIONS.md) для вычисления предиката дя указанных команд -- `commands` -- набор команд, которые должны выполнится, если [выражение](/plugins/hh-geminio/docs/ru/EXPRESSIONS.md) `validIf` +- `validIf` -- булево [выражение](../../EXPRESSIONS.md) для вычисления предиката дя указанных команд +- `commands` -- набор команд, которые должны выполнится, если [выражение](../../EXPRESSIONS.md) `validIf` возвращает `true`. -- `elseCommands` -- набор команд, которые должны выполнится, если [выражение](/plugins/hh-geminio/docs/ru/EXPRESSIONS.md) `validIf` +- `elseCommands` -- набор команд, которые должны выполнится, если [выражение](../../EXPRESSIONS.md) `validIf` возвращает `false`. -Команда вычисляет [выражение](/plugins/hh-geminio/docs/ru/EXPRESSIONS.md), которое вы указываете в `validIf`. +Команда вычисляет [выражение](../../EXPRESSIONS.md), которое вы указываете в `validIf`. Если результат равен `true`, то будет выполнен набор команд, которые вы -укажете в списке `commands`, если `false` - выполняются команды в `elseCommands`. +укажете в списке `commands`, если `false` - выполняются команды в `elseCommands`. Списки команд поддерживают все перечисленные команды. --- -[Обратно к списку команд](/plugins/hh-geminio/docs/ru/recipe_content/RECIPE.md) \ No newline at end of file +[Обратно к списку команд](../RECIPE.md) \ No newline at end of file diff --git a/plugins/hh-geminio/gradle.properties b/plugins/hh-geminio/gradle.properties index 2c3cccca..5358e9f3 100644 --- a/plugins/hh-geminio/gradle.properties +++ b/plugins/hh-geminio/gradle.properties @@ -1,4 +1,4 @@ -pluginVersion=1.4.1 +pluginVersion=1.4.2 pluginGroup=ru.hh.plugins pluginName=hh-geminio diff --git a/plugins/hh-geminio/src/main/kotlin/ru/hh/plugins/geminio/ActionsHelper.kt b/plugins/hh-geminio/src/main/kotlin/ru/hh/plugins/geminio/ActionsHelper.kt index 446ffdae..929cf351 100644 --- a/plugins/hh-geminio/src/main/kotlin/ru/hh/plugins/geminio/ActionsHelper.kt +++ b/plugins/hh-geminio/src/main/kotlin/ru/hh/plugins/geminio/ActionsHelper.kt @@ -84,7 +84,9 @@ internal class ActionsHelper { val rootDirectory = File(rootDirPath) if (rootDirectory.exists().not() || rootDirectory.isDirectory.not()) { - HHLogger.d("Templates directory doesn't exists [path: $rootDirPath, isModulesTemplates: $isModulesTemplates]") + HHLogger.d( + "Templates directory doesn't exists [path: $rootDirPath, isModulesTemplates: $isModulesTemplates]" + ) return } diff --git a/plugins/hh-geminio/src/main/kotlin/ru/hh/plugins/geminio/actions/module_template/ExecuteGeminioModuleTemplateAction.kt b/plugins/hh-geminio/src/main/kotlin/ru/hh/plugins/geminio/actions/module_template/ExecuteGeminioModuleTemplateAction.kt index 6d261cab..144ac986 100644 --- a/plugins/hh-geminio/src/main/kotlin/ru/hh/plugins/geminio/actions/module_template/ExecuteGeminioModuleTemplateAction.kt +++ b/plugins/hh-geminio/src/main/kotlin/ru/hh/plugins/geminio/actions/module_template/ExecuteGeminioModuleTemplateAction.kt @@ -11,6 +11,7 @@ import ru.hh.plugins.dialog.sync.showSyncQuestionDialog import ru.hh.plugins.extensions.SPACE import ru.hh.plugins.extensions.UNDERSCORE import ru.hh.plugins.extensions.getSelectedPsiElement +import ru.hh.plugins.extensions.getTargetDirectory import ru.hh.plugins.geminio.actions.module_template.steps.ChooseModulesModelWizardStep import ru.hh.plugins.geminio.models.GeminioRecipeExecutorModel import ru.hh.plugins.geminio.sdk.GeminioSdkFactory @@ -73,7 +74,9 @@ class ExecuteGeminioModuleTemplateAction( HHLogger.d("Recipe successfully parsed!") - val geminioTemplateData = geminioSdk.createGeminioTemplateData(project, geminioRecipe) + val targetDirectory = actionEvent.getTargetDirectory() + + val geminioTemplateData = geminioSdk.createGeminioTemplateData(project, geminioRecipe, targetDirectory) val configureTemplateParametersStepFactory = ConfigureTemplateParametersStepFactory(project) val stepModel = configureTemplateParametersStepFactory.createForNewModule( diff --git a/plugins/hh-geminio/src/main/kotlin/ru/hh/plugins/geminio/actions/template/ExecuteGeminioTemplateAction.kt b/plugins/hh-geminio/src/main/kotlin/ru/hh/plugins/geminio/actions/template/ExecuteGeminioTemplateAction.kt index 48d7ae92..b16ca8ba 100644 --- a/plugins/hh-geminio/src/main/kotlin/ru/hh/plugins/geminio/actions/template/ExecuteGeminioTemplateAction.kt +++ b/plugins/hh-geminio/src/main/kotlin/ru/hh/plugins/geminio/actions/template/ExecuteGeminioTemplateAction.kt @@ -4,15 +4,14 @@ import com.android.tools.idea.model.AndroidModel import com.android.tools.idea.wizard.model.ModelWizard import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent -import com.intellij.openapi.actionSystem.CommonDataKeys import com.intellij.openapi.actionSystem.LangDataKeys import com.intellij.openapi.project.Project -import com.intellij.openapi.vfs.VirtualFile import org.jetbrains.android.facet.AndroidFacet import org.jetbrains.kotlin.idea.core.util.toPsiFile import org.jetbrains.kotlin.idea.util.application.executeWriteCommand import org.jetbrains.kotlin.psi.KtFile import ru.hh.plugins.dialog.sync.showSyncQuestionDialog +import ru.hh.plugins.extensions.getTargetDirectory import ru.hh.plugins.geminio.sdk.GeminioSdkFactory import ru.hh.plugins.geminio.services.templates.ConfigureTemplateParametersStepFactory import ru.hh.plugins.geminio.wizard.StudioWizardDialogFactory @@ -73,7 +72,11 @@ class ExecuteGeminioTemplateAction( stepTitle = actionText, facet = facet, targetDirectory = targetDirectory, - androidStudioTemplate = geminioSdk.createGeminioTemplateData(project, geminioRecipe).androidStudioTemplate + androidStudioTemplate = geminioSdk.createGeminioTemplateData( + project = project, + geminioRecipe = geminioRecipe, + targetDirectory = targetDirectory + ).androidStudioTemplate ) val wizard = ModelWizard.Builder().addStep(stepModel.configureTemplateParametersStep).build().apply { @@ -123,25 +126,6 @@ class ExecuteGeminioTemplateAction( ) } - private fun AnActionEvent.getTargetDirectory(): VirtualFile { - val currentVirtualFile = CommonDataKeys.VIRTUAL_FILE.getData(dataContext) - - return when { - currentVirtualFile == null -> { - throw IllegalStateException("You should select some file for code generation") - } - - currentVirtualFile.isDirectory.not() -> { - // If the user selected a simulated folder entry (eg "Manifests"), there will be no target directory - currentVirtualFile.parent - } - - else -> { - currentVirtualFile - } - } - } - private data class EventData( val project: Project, val androidFacet: AndroidFacet diff --git a/settings.gradle.kts b/settings.gradle.kts index b1dc6881..ec25dbaf 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -35,8 +35,8 @@ pluginManagement { } } +@Suppress("UnstableApiUsage") dependencyResolutionManagement { - @Suppress("UnstableApiUsage") repositories { mavenCentral() gradlePluginPortal() diff --git a/shared/core/utils/src/main/kotlin/ru/hh/plugins/extensions/AnActionEventExt.kt b/shared/core/utils/src/main/kotlin/ru/hh/plugins/extensions/AnActionEventExt.kt index 972b6c51..861981f4 100644 --- a/shared/core/utils/src/main/kotlin/ru/hh/plugins/extensions/AnActionEventExt.kt +++ b/shared/core/utils/src/main/kotlin/ru/hh/plugins/extensions/AnActionEventExt.kt @@ -1,7 +1,28 @@ package ru.hh.plugins.extensions import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.actionSystem.CommonDataKeys import com.intellij.openapi.actionSystem.PlatformDataKeys +import com.intellij.openapi.vfs.VirtualFile import com.intellij.psi.PsiElement fun AnActionEvent.getSelectedPsiElement(): PsiElement? = getData(PlatformDataKeys.PSI_ELEMENT) +@Suppress("detekt.UseCheckOrError") +fun AnActionEvent.getTargetDirectory(): VirtualFile { + val currentVirtualFile = CommonDataKeys.VIRTUAL_FILE.getData(dataContext) + + return when { + currentVirtualFile == null -> { + throw IllegalStateException("You should select some file for code generation") + } + + currentVirtualFile.isDirectory.not() -> { + // If the user selected a simulated folder entry (eg "Manifests"), there will be no target directory + currentVirtualFile.parent + } + + else -> { + currentVirtualFile + } + } +} diff --git a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/GeminioSdk.kt b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/GeminioSdk.kt index b59a8cec..bc595298 100644 --- a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/GeminioSdk.kt +++ b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/GeminioSdk.kt @@ -1,6 +1,7 @@ package ru.hh.plugins.geminio.sdk import com.intellij.openapi.project.Project +import com.intellij.openapi.vfs.VirtualFile import ru.hh.plugins.geminio.sdk.models.GeminioTemplateData import ru.hh.plugins.geminio.sdk.recipe.models.GeminioRecipe @@ -11,5 +12,10 @@ interface GeminioSdk { fun parseYamlRecipe(recipeFilePath: String): GeminioRecipe - fun createGeminioTemplateData(project: Project, geminioRecipe: GeminioRecipe): GeminioTemplateData + fun createGeminioTemplateData( + project: Project, + geminioRecipe: GeminioRecipe, + targetDirectory: VirtualFile, + ): GeminioTemplateData + } diff --git a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/GeminioSdkImpl.kt b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/GeminioSdkImpl.kt index cd3bf054..53ab4fc4 100644 --- a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/GeminioSdkImpl.kt +++ b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/GeminioSdkImpl.kt @@ -1,6 +1,7 @@ package ru.hh.plugins.geminio.sdk import com.intellij.openapi.project.Project +import com.intellij.openapi.vfs.VirtualFile import ru.hh.plugins.geminio.sdk.models.GeminioTemplateData import ru.hh.plugins.geminio.sdk.recipe.models.GeminioRecipe import ru.hh.plugins.geminio.sdk.recipe.models.extensions.toIndentString @@ -26,7 +27,11 @@ internal class GeminioSdkImpl : GeminioSdk { } } - override fun createGeminioTemplateData(project: Project, geminioRecipe: GeminioRecipe): GeminioTemplateData { - return geminioRecipe.toGeminioTemplateData(project) + override fun createGeminioTemplateData( + project: Project, + geminioRecipe: GeminioRecipe, + targetDirectory: VirtualFile + ): GeminioTemplateData { + return geminioRecipe.toGeminioTemplateData(project, targetDirectory) } } diff --git a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/recipe/models/expressions/RecipeExpressionCommand.kt b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/recipe/models/expressions/RecipeExpressionCommand.kt index 69f625c0..dfa166d3 100644 --- a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/recipe/models/expressions/RecipeExpressionCommand.kt +++ b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/recipe/models/expressions/RecipeExpressionCommand.kt @@ -19,6 +19,8 @@ sealed class RecipeExpressionCommand { object RootOut : RecipeExpressionCommand() + object CurrentDirOut : RecipeExpressionCommand() + object ReturnTrue : RecipeExpressionCommand() object ReturnFalse : RecipeExpressionCommand() diff --git a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/recipe/parsers/expressions/RecipeExpressionParser.kt b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/recipe/parsers/expressions/RecipeExpressionParser.kt index 41a1f2dd..8f14d746 100644 --- a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/recipe/parsers/expressions/RecipeExpressionParser.kt +++ b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/recipe/parsers/expressions/RecipeExpressionParser.kt @@ -9,6 +9,7 @@ private const val SRC_OUT_FOLDER_NAME = "srcOut" private const val RES_OUT_FOLDER_NAME = "resOut" private const val MANIFEST_OUT_FOLDER_NAME = "manifestOut" private const val ROOT_OUT_FOLDER_NAME = "rootOut" +private const val CURRENT_DIR_OUT_FOLDER_NAME = "currentDirOut" private const val FIXED_TRUE_VALUE = "true" private const val FIXED_FALSE_VALUE = "false" @@ -85,6 +86,10 @@ internal fun String.toRecipeExpression(sectionName: String): RecipeExpression { RecipeExpressionCommand.RootOut } + CURRENT_DIR_OUT_FOLDER_NAME -> { + RecipeExpressionCommand.CurrentDirOut + } + else -> { RecipeExpressionCommand.Dynamic( parameterId = parameterId, diff --git a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/GeminioRecipeExecutor.kt b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/GeminioRecipeExecutor.kt index 46c4560e..6888e61e 100644 --- a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/GeminioRecipeExecutor.kt +++ b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/GeminioRecipeExecutor.kt @@ -1,24 +1,28 @@ package ru.hh.plugins.geminio.sdk.template.executors import com.android.tools.idea.wizard.template.RecipeExecutor +import com.intellij.openapi.vfs.VirtualFile import ru.hh.plugins.geminio.sdk.recipe.models.GeminioRecipe import ru.hh.plugins.geminio.sdk.recipe.models.commands.RecipeCommand import ru.hh.plugins.geminio.sdk.template.models.GeminioRecipeExecutorData import ru.hh.plugins.utils.kotlin.exhaustive internal fun RecipeExecutor.executeGeminioRecipe( + targetDirectory: VirtualFile, geminioRecipe: GeminioRecipe, executorData: GeminioRecipeExecutorData ) { - executeCommands(geminioRecipe.recipeCommands.commands, executorData) + executeCommands(targetDirectory, geminioRecipe.recipeCommands.commands, executorData) } internal fun RecipeExecutor.executeCommands( + targetDirectory: VirtualFile, commands: List, executorData: GeminioRecipeExecutorData ) { commands.forEach { command -> command.execute( + targetDirectory = targetDirectory, recipeExecutor = this, executorData = executorData ) @@ -26,16 +30,17 @@ internal fun RecipeExecutor.executeCommands( } private fun RecipeCommand.execute( + targetDirectory: VirtualFile, recipeExecutor: RecipeExecutor, executorData: GeminioRecipeExecutorData ) { when (this) { - is RecipeCommand.Instantiate -> recipeExecutor.execute(this, executorData) - is RecipeCommand.InstantiateAndOpen -> recipeExecutor.execute(this, executorData) - is RecipeCommand.Open -> recipeExecutor.execute(this, executorData) - is RecipeCommand.Predicate -> recipeExecutor.execute(this, executorData) + is RecipeCommand.Instantiate -> recipeExecutor.execute(targetDirectory, this, executorData) + is RecipeCommand.InstantiateAndOpen -> recipeExecutor.execute(targetDirectory, this, executorData) + is RecipeCommand.Open -> recipeExecutor.execute(targetDirectory, this, executorData) + is RecipeCommand.Predicate -> recipeExecutor.execute(targetDirectory, this, executorData) is RecipeCommand.AddDependencies -> recipeExecutor.execute(this, executorData) - is RecipeCommand.MkDirs -> recipeExecutor.execute(this, executorData) + is RecipeCommand.MkDirs -> recipeExecutor.execute(targetDirectory, this, executorData) is RecipeCommand.AddGradlePlugins -> recipeExecutor.execute(this, executorData) }.exhaustive } diff --git a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/InstantiateAndOpenCommandExecutor.kt b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/InstantiateAndOpenCommandExecutor.kt index 97b0dc04..57f6d535 100644 --- a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/InstantiateAndOpenCommandExecutor.kt +++ b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/InstantiateAndOpenCommandExecutor.kt @@ -1,25 +1,29 @@ package ru.hh.plugins.geminio.sdk.template.executors import com.android.tools.idea.wizard.template.RecipeExecutor +import com.intellij.openapi.vfs.VirtualFile import ru.hh.plugins.geminio.sdk.recipe.models.commands.RecipeCommand import ru.hh.plugins.geminio.sdk.template.models.GeminioRecipeExecutorData internal fun RecipeExecutor.execute( + targetDirectory: VirtualFile, command: RecipeCommand.InstantiateAndOpen, executorData: GeminioRecipeExecutorData ) { execute( - RecipeCommand.Instantiate( + targetDirectory = targetDirectory, + command = RecipeCommand.Instantiate( from = command.from, to = command.to ), - executorData + executorData = executorData ) execute( - RecipeCommand.Open( + targetDirectory = targetDirectory, + command = RecipeCommand.Open( file = command.to ), - executorData + executorData = executorData ) } diff --git a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/InstantiateCommandExecutor.kt b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/InstantiateCommandExecutor.kt index 7c6c8ca5..9c35a118 100644 --- a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/InstantiateCommandExecutor.kt +++ b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/InstantiateCommandExecutor.kt @@ -1,6 +1,7 @@ package ru.hh.plugins.geminio.sdk.template.executors import com.android.tools.idea.wizard.template.RecipeExecutor +import com.intellij.openapi.vfs.VirtualFile import ru.hh.plugins.geminio.sdk.recipe.models.commands.RecipeCommand import ru.hh.plugins.geminio.sdk.template.mapping.expressions.evaluateString import ru.hh.plugins.geminio.sdk.template.models.GeminioRecipeExecutorData @@ -8,15 +9,18 @@ import ru.hh.plugins.logger.HHLogger import java.io.File internal fun RecipeExecutor.execute( + targetDirectory: VirtualFile, command: RecipeCommand.Instantiate, executorData: GeminioRecipeExecutorData ) = with(executorData) { - val from = command.from.evaluateString(moduleTemplateData, existingParametersMap) - val to = command.to.evaluateString(moduleTemplateData, existingParametersMap) + val from = command.from.evaluateString(targetDirectory, moduleTemplateData, existingParametersMap) + val to = command.to.evaluateString(targetDirectory, moduleTemplateData, existingParametersMap) HHLogger.d("Instantiate command [command: $command, from: $from, to: $to]") if (from == null || to == null) { - throw IllegalArgumentException("Cannot evaluate 'from' or 'to' expressions [command: $command, from: $from, to: $to]") + throw IllegalArgumentException( + "Cannot evaluate 'from' or 'to' expressions [command: $command, from: $from, to: $to]" + ) } val fileText = freemarkerConfiguration.resolveTemplate(from, resolvedParamsMap) save(fileText, File(to)) diff --git a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/MkDirsCommandExecutor.kt b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/MkDirsCommandExecutor.kt index a57f051f..cb6816c9 100644 --- a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/MkDirsCommandExecutor.kt +++ b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/MkDirsCommandExecutor.kt @@ -1,6 +1,7 @@ package ru.hh.plugins.geminio.sdk.template.executors import com.android.tools.idea.wizard.template.RecipeExecutor +import com.intellij.openapi.vfs.VirtualFile import ru.hh.plugins.extensions.EMPTY import ru.hh.plugins.geminio.sdk.recipe.models.commands.MkDirItem import ru.hh.plugins.geminio.sdk.recipe.models.commands.RecipeCommand @@ -9,30 +10,45 @@ import ru.hh.plugins.geminio.sdk.template.models.GeminioRecipeExecutorData import java.io.File internal fun RecipeExecutor.execute( + targetDirectory: VirtualFile, command: RecipeCommand.MkDirs, executorData: GeminioRecipeExecutorData ) { for (rootItem in command.dirs) { - makeDirectories(rootItem, String.EMPTY, executorData) + makeDirectories( + targetDirectory = targetDirectory, + mkDirItem = rootItem, + combinedPath = String.EMPTY, + executorData = executorData + ) } } private fun RecipeExecutor.makeDirectories( + targetDirectory: VirtualFile, mkDirItem: MkDirItem, combinedPath: String, executorData: GeminioRecipeExecutorData ) { val filePath = "$combinedPath/".takeIf { combinedPath.isNotEmpty() }.orEmpty() + requireNotNull( mkDirItem.name.evaluateString( - executorData.moduleTemplateData, - executorData.existingParametersMap + targetDirectory = targetDirectory, + moduleTemplateData = executorData.moduleTemplateData, + existingParametersMap = executorData.existingParametersMap ) ) { - "Recipe execution, 'mkDirs' command: Error with directory name evaluation [mkDirItem: $mkDirItem, combinedPath: $combinedPath, executorData: $executorData]" + """Recipe execution, 'mkDirs' command: Error with directory name evaluation + |[mkDirItem: $mkDirItem, combinedPath: $combinedPath, executorData: $executorData]""" + .trimMargin() } createDirectory(File(filePath)) for (subdirectoryItem in mkDirItem.subDirs) { - makeDirectories(subdirectoryItem, filePath, executorData) + makeDirectories( + targetDirectory = targetDirectory, + mkDirItem = subdirectoryItem, + combinedPath = filePath, + executorData = executorData + ) } } diff --git a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/OpenCommandExecutor.kt b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/OpenCommandExecutor.kt index 66529a60..7e47a2ef 100644 --- a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/OpenCommandExecutor.kt +++ b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/OpenCommandExecutor.kt @@ -1,6 +1,7 @@ package ru.hh.plugins.geminio.sdk.template.executors import com.android.tools.idea.wizard.template.RecipeExecutor +import com.intellij.openapi.vfs.VirtualFile import ru.hh.plugins.geminio.sdk.recipe.models.commands.RecipeCommand import ru.hh.plugins.geminio.sdk.template.mapping.expressions.evaluateString import ru.hh.plugins.geminio.sdk.template.models.GeminioRecipeExecutorData @@ -8,14 +9,17 @@ import ru.hh.plugins.logger.HHLogger import java.io.File internal fun RecipeExecutor.execute( + targetDirectory: VirtualFile, command: RecipeCommand.Open, executorData: GeminioRecipeExecutorData ) = with(executorData) { - val filePath = command.file.evaluateString(moduleTemplateData, existingParametersMap) + val filePath = command.file.evaluateString(targetDirectory, moduleTemplateData, existingParametersMap) HHLogger.d("Open command [filePath: $filePath]") if (filePath == null) { - throw IllegalArgumentException("Cannot find file for Open command [command: $command, evaluated path: $filePath]") + throw IllegalArgumentException( + "Cannot find file for Open command [command: $command, evaluated path: $filePath]" + ) } open(File(filePath)) diff --git a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/PredicateCommandExecutor.kt b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/PredicateCommandExecutor.kt index d4342988..1693d2c7 100644 --- a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/PredicateCommandExecutor.kt +++ b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/executors/PredicateCommandExecutor.kt @@ -1,12 +1,14 @@ package ru.hh.plugins.geminio.sdk.template.executors import com.android.tools.idea.wizard.template.RecipeExecutor +import com.intellij.openapi.vfs.VirtualFile import ru.hh.plugins.geminio.sdk.recipe.models.commands.RecipeCommand import ru.hh.plugins.geminio.sdk.template.mapping.expressions.evaluateBoolean import ru.hh.plugins.geminio.sdk.template.models.GeminioRecipeExecutorData import ru.hh.plugins.logger.HHLogger internal fun RecipeExecutor.execute( + targetDirectory: VirtualFile, command: RecipeCommand.Predicate, executorData: GeminioRecipeExecutorData ) = with(executorData) { @@ -16,6 +18,7 @@ internal fun RecipeExecutor.execute( if (validIfExpression.evaluateBoolean(existingParametersMap)) { HHLogger.d("\tStart executing commands [validIf == true]") executeCommands( + targetDirectory = targetDirectory, commands = command.commands, executorData = executorData ) @@ -23,6 +26,7 @@ internal fun RecipeExecutor.execute( // Skip predicate command HHLogger.d("\tSkip commands execution [validIf == false], try to execute 'elseCommands' if exists") executeCommands( + targetDirectory = targetDirectory, commands = command.elseCommands, executorData = executorData ) diff --git a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/mapping/GeminioRecipeMapper.kt b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/mapping/GeminioRecipeMapper.kt index 17a54470..7c652199 100644 --- a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/mapping/GeminioRecipeMapper.kt +++ b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/mapping/GeminioRecipeMapper.kt @@ -3,6 +3,7 @@ package ru.hh.plugins.geminio.sdk.template.mapping import com.android.tools.idea.wizard.template.ModuleTemplateData import com.android.tools.idea.wizard.template.template import com.intellij.openapi.project.Project +import com.intellij.openapi.vfs.VirtualFile import ru.hh.plugins.freemarker_wrapper.FreemarkerConfiguration import ru.hh.plugins.geminio.sdk.GeminioAdditionalParamsStore import ru.hh.plugins.geminio.sdk.GeminioSdkConstants @@ -21,7 +22,8 @@ import ru.hh.plugins.geminio.sdk.template.models.GeminioRecipeExecutorData * Mapping from [ru.hh.plugins.geminio.sdk.recipe.models.GeminioRecipe] * into [ru.hh.plugins.geminio.sdk.models.GeminioTemplateData]. */ -internal fun GeminioRecipe.toGeminioTemplateData(project: Project): GeminioTemplateData { +@Suppress("detekt.LongMethod") +internal fun GeminioRecipe.toGeminioTemplateData(project: Project, targetDirectory: VirtualFile): GeminioTemplateData { val geminioRecipe = this val existingParametersMap = mutableMapOf() @@ -36,6 +38,7 @@ internal fun GeminioRecipe.toGeminioTemplateData(project: Project): GeminioTempl recipe = { templateData -> val moduleTemplateData = templateData as ModuleTemplateData executeGeminioRecipe( + targetDirectory = targetDirectory, geminioRecipe = geminioRecipe, executorData = GeminioRecipeExecutorData( project = project, @@ -45,7 +48,7 @@ internal fun GeminioRecipe.toGeminioTemplateData(project: Project): GeminioTempl resolvedParamsMap = existingParametersMap.asIterable().associate { entry -> entry.key to entry.value.value }.plus( - getHardcodedParamsMap(moduleTemplateData, existingParametersMap) + getHardcodedParamsMap(targetDirectory, moduleTemplateData, existingParametersMap) ).plus( paramsStore ), @@ -69,6 +72,7 @@ internal fun GeminioRecipe.toGeminioTemplateData(project: Project): GeminioTempl } private fun getHardcodedParamsMap( + targetDirectory: VirtualFile, moduleTemplateData: ModuleTemplateData, existingParametersMap: Map ): Map { @@ -85,9 +89,15 @@ private fun getHardcodedParamsMap( } } + var currentDirPackageName = targetDirectory.path.replace("/", ".") + currentDirPackageName = currentDirPackageName.substring( + currentDirPackageName.indexOf(packageName) + ) + return mapOf( HardcodedParams.PACKAGE_NAME to packageName, HardcodedParams.APPLICATION_PACKAGE to applicationPackage, + HardcodedParams.CURRENT_DIR_PACKAGE_NAME to currentDirPackageName ) } @@ -101,4 +111,9 @@ private object HardcodedParams { * Package name from current gradle module. */ const val APPLICATION_PACKAGE = "applicationPackage" + + /** + * Package name from current directory. + */ + const val CURRENT_DIR_PACKAGE_NAME = "currentDirPackageName" } diff --git a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/mapping/expressions/BooleanRecipeExpressionMapper.kt b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/mapping/expressions/BooleanRecipeExpressionMapper.kt index aeabda8c..dae714a3 100644 --- a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/mapping/expressions/BooleanRecipeExpressionMapper.kt +++ b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/mapping/expressions/BooleanRecipeExpressionMapper.kt @@ -55,6 +55,7 @@ private fun RecipeExpressionCommand.resolveBooleanValue( RecipeExpressionCommand.SrcOut, RecipeExpressionCommand.ResOut, RecipeExpressionCommand.ManifestOut, + RecipeExpressionCommand.CurrentDirOut, RecipeExpressionCommand.RootOut -> { throw IllegalArgumentException("Unexpected command for boolean parameter [$this]") } diff --git a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/mapping/expressions/StringRecipeExpressionMapper.kt b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/mapping/expressions/StringRecipeExpressionMapper.kt index 17e8a5c1..c1602d18 100644 --- a/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/mapping/expressions/StringRecipeExpressionMapper.kt +++ b/shared/feature/geminio-sdk/src/main/kotlin/ru/hh/plugins/geminio/sdk/template/mapping/expressions/StringRecipeExpressionMapper.kt @@ -8,9 +8,11 @@ import com.android.tools.idea.wizard.template.fragmentToLayout import com.android.tools.idea.wizard.template.layoutToActivity import com.android.tools.idea.wizard.template.layoutToFragment import com.android.tools.idea.wizard.template.underscoreToCamelCase +import com.intellij.openapi.vfs.VirtualFile import ru.hh.plugins.extensions.EMPTY import ru.hh.plugins.geminio.sdk.recipe.models.expressions.RecipeExpression import ru.hh.plugins.geminio.sdk.recipe.models.expressions.RecipeExpressionCommand +import ru.hh.plugins.geminio.sdk.recipe.models.expressions.RecipeExpressionCommand.CurrentDirOut import ru.hh.plugins.geminio.sdk.recipe.models.expressions.RecipeExpressionCommand.Dynamic import ru.hh.plugins.geminio.sdk.recipe.models.expressions.RecipeExpressionCommand.Fixed import ru.hh.plugins.geminio.sdk.recipe.models.expressions.RecipeExpressionCommand.ManifestOut @@ -58,6 +60,7 @@ internal fun RecipeExpression.evaluateString( * into [ru.hh.plugins.geminio.sdk.template.aliases.AndroidStudioTemplateParameterStringLambda]. */ internal fun RecipeExpression.evaluateString( + targetDirectory: VirtualFile, moduleTemplateData: ModuleTemplateData, existingParametersMap: Map ): String? { @@ -66,7 +69,13 @@ internal fun RecipeExpression.evaluateString( val result = StringBuilder() for (command in commands) { - result.append(command.toStringValue(moduleTemplateData, existingParametersMap)) + result.append( + command.toStringValue( + targetDirectory = targetDirectory, + moduleTemplateData = moduleTemplateData, + existingParametersMap = existingParametersMap + ) + ) } return result.toString().takeIf { it.isNotEmpty() } @@ -83,6 +92,7 @@ private fun RecipeExpressionCommand.toStringValue( ResOut, ManifestOut, RootOut, + CurrentDirOut, ReturnTrue, ReturnFalse -> throw IllegalArgumentException("Unexpected command for string parameter [$this]") @@ -90,6 +100,7 @@ private fun RecipeExpressionCommand.toStringValue( } private fun RecipeExpressionCommand.toStringValue( + targetDirectory: VirtualFile, moduleTemplateData: ModuleTemplateData, existingParametersMap: Map ): String { @@ -103,6 +114,13 @@ private fun RecipeExpressionCommand.toStringValue( ResOut -> "${resOut.absolutePath}/" ManifestOut -> "${manifestOut.absolutePath}/" RootOut -> "${rootOut.absolutePath}/" + CurrentDirOut -> { + if (targetDirectory.isDirectory) { + targetDirectory.path + } else { + targetDirectory.parent.path + } + } ReturnTrue, ReturnFalse -> throw IllegalArgumentException("Unexpected command for string value [$this]") diff --git a/shared/feature/geminio-sdk/src/test/kotlin/ru/hh/plugins/geminio/sdk/recipe/expressions/GeminioRecipeBooleanExpressionSpec.kt b/shared/feature/geminio-sdk/src/test/kotlin/ru/hh/plugins/geminio/sdk/recipe/expressions/GeminioRecipeBooleanExpressionSpec.kt index 1f2a74bc..009e3353 100644 --- a/shared/feature/geminio-sdk/src/test/kotlin/ru/hh/plugins/geminio/sdk/recipe/expressions/GeminioRecipeBooleanExpressionSpec.kt +++ b/shared/feature/geminio-sdk/src/test/kotlin/ru/hh/plugins/geminio/sdk/recipe/expressions/GeminioRecipeBooleanExpressionSpec.kt @@ -1,3 +1,5 @@ +@file:Suppress("detekt.Indentation") + package ru.hh.plugins.geminio.sdk.recipe.expressions import io.kotest.assertions.throwables.shouldThrow diff --git a/shared/feature/geminio-sdk/src/test/kotlin/ru/hh/plugins/geminio/sdk/recipe/expressions/GeminioRecipeStringExpressionSpec.kt b/shared/feature/geminio-sdk/src/test/kotlin/ru/hh/plugins/geminio/sdk/recipe/expressions/GeminioRecipeStringExpressionSpec.kt index a71c52ba..f2fee72a 100644 --- a/shared/feature/geminio-sdk/src/test/kotlin/ru/hh/plugins/geminio/sdk/recipe/expressions/GeminioRecipeStringExpressionSpec.kt +++ b/shared/feature/geminio-sdk/src/test/kotlin/ru/hh/plugins/geminio/sdk/recipe/expressions/GeminioRecipeStringExpressionSpec.kt @@ -1,3 +1,5 @@ +@file:Suppress("detekt.Indentation") + package ru.hh.plugins.geminio.sdk.recipe.expressions import io.kotest.assertions.throwables.shouldThrow