|
1 | | -# kmp-module-generator |
2 | | - |
3 | | - |
4 | | -[](https://plugins.jetbrains.com/plugin/MARKETPLACE_ID) |
5 | | -[](https://plugins.jetbrains.com/plugin/MARKETPLACE_ID) |
6 | | - |
7 | | -## Template ToDo list |
8 | | -- [x] Create a new [IntelliJ Platform Plugin Template][template] project. |
9 | | -- [ ] Get familiar with the [template documentation][template]. |
10 | | -- [ ] Adjust the [pluginGroup](./gradle.properties) and [pluginName](./gradle.properties), as well as the [id](./src/main/resources/META-INF/plugin.xml) and [sources package](./src/main/kotlin). |
11 | | -- [ ] Adjust the plugin description in `README` (see [Tips][docs:plugin-description]) |
12 | | -- [ ] Review the [Legal Agreements](https://plugins.jetbrains.com/docs/marketplace/legal-agreements.html?from=IJPluginTemplate). |
13 | | -- [ ] [Publish a plugin manually](https://plugins.jetbrains.com/docs/intellij/publishing-plugin.html?from=IJPluginTemplate) for the first time. |
14 | | -- [ ] Set the `MARKETPLACE_ID` in the above README badges. You can obtain it once the plugin is published to JetBrains Marketplace. |
15 | | -- [ ] Set the [Plugin Signing](https://plugins.jetbrains.com/docs/intellij/plugin-signing.html?from=IJPluginTemplate) related [secrets](https://github.com/JetBrains/intellij-platform-plugin-template#environment-variables). |
16 | | -- [ ] Set the [Deployment Token](https://plugins.jetbrains.com/docs/marketplace/plugin-upload.html?from=IJPluginTemplate). |
17 | | -- [ ] Click the <kbd>Watch</kbd> button on the top of the [IntelliJ Platform Plugin Template][template] to be notified about releases containing new features and fixes. |
18 | | -- [ ] Configure the [CODECOV_TOKEN](https://docs.codecov.com/docs/quick-start) secret for automated test coverage reports on PRs |
| 1 | +# KMP Module Generator |
19 | 2 |
|
20 | 3 | <!-- Plugin description --> |
21 | | -This Fancy IntelliJ Platform Plugin is going to be your implementation of the brilliant ideas that you have. |
| 4 | +A powerful plugin for IntelliJ IDEA and Android Studio that automates Kotlin Multiplatform and Android module creation using customizable FreeMarker templates. |
22 | 5 |
|
23 | | -This specific section is a source for the [plugin.xml](/src/main/resources/META-INF/plugin.xml) file which will be extracted by the [Gradle](/build.gradle.kts) during the build process. |
24 | | - |
25 | | -To keep everything working, do not remove `<!-- ... -->` sections. |
| 6 | +**Key Features:** |
| 7 | +- FreeMarker-based templates - create templates as simple text files |
| 8 | +- Visual template wizards - intuitive UI for creating and editing templates |
| 9 | +- Automatic settings.gradle updates |
| 10 | +- Preview module structure before generation |
| 11 | +- Configurable template storage for team sharing |
26 | 12 | <!-- Plugin description end --> |
27 | 13 |
|
28 | | -## Installation |
| 14 | +## 🚀 Основные возможности |
| 15 | + |
| 16 | +- **FreeMarker шаблоны** - создавайте и редактируйте шаблоны как обычные файлы |
| 17 | +- **Визуальный UI** - создавайте и редактируйте шаблоны через удобный интерфейс |
| 18 | +- **Автоматическая интеграция** - обновление settings.gradle |
| 19 | +- **Предпросмотр** - см. структуру перед генерацией |
| 20 | +- **Настраиваемое хранилище** - используйте общую папку шаблонов для всех проектов |
| 21 | + |
| 22 | +## 📦 Установка |
| 23 | + |
| 24 | +### Из JetBrains Marketplace |
| 25 | +``` |
| 26 | +Settings → Plugins → Marketplace → "KMP Module Generator" → Install |
| 27 | +``` |
| 28 | + |
| 29 | +### Из исходников |
| 30 | +```bash |
| 31 | +./gradlew buildPlugin |
| 32 | +# Файл будет в build/distributions/ |
| 33 | +``` |
| 34 | + |
| 35 | +## 🎯 Быстрый старт |
| 36 | + |
| 37 | +1. **Создать свой первый шаблон** |
| 38 | + ``` |
| 39 | + Правый клик на папке → New → Generate Module → New Template... |
| 40 | + ``` |
| 41 | + |
| 42 | +2. **Сгенерировать модуль из шаблона** |
| 43 | + ``` |
| 44 | + Правый клик на папке → New → Generate Module → From Template... |
| 45 | + ``` |
| 46 | + |
| 47 | +3. **Редактировать существующий шаблон** |
| 48 | + ``` |
| 49 | + Правый клик на папке → New → Generate Module → Edit Template... |
| 50 | + ``` |
| 51 | + |
| 52 | +## ⚙️ Настройка папки с шаблонами |
| 53 | + |
| 54 | +По умолчанию шаблоны хранятся в `.idea/kmp-templates/` вашего проекта. |
| 55 | + |
| 56 | +**Изменить папку:** |
| 57 | +``` |
| 58 | +Settings → Tools → KMP Module Templates |
| 59 | +→ ☑ Use custom template folder |
| 60 | +→ Выберите папку |
| 61 | +→ Нажмите "Open Templates Folder" для быстрого доступа |
| 62 | +``` |
| 63 | + |
| 64 | +**Зачем это нужно:** |
| 65 | +- Общая папка для всех проектов |
| 66 | +- Шаблоны вне репозитория |
| 67 | +- Подключение внешней библиотеки шаблонов |
| 68 | +- Удобное управление через проводник |
| 69 | + |
| 70 | +## 📝 Создание своих шаблонов |
| 71 | + |
| 72 | +### Структура шаблона |
| 73 | + |
| 74 | +``` |
| 75 | +<папка-с-шаблонами>/my-template/ |
| 76 | +├── template.xml # Конфигурация |
| 77 | +├── root/ # Файлы для генерации |
| 78 | +│ ├── build.gradle.kts.ftl |
| 79 | +│ └── src/ |
| 80 | +│ └── main/ |
| 81 | +│ └── kotlin/ |
| 82 | +│ └── ${packagePath}/ |
| 83 | +│ └── MyClass.kt.ftl |
| 84 | +``` |
| 85 | + |
| 86 | +### template.xml |
| 87 | + |
| 88 | +```xml |
| 89 | +<?xml version="1.0"?> |
| 90 | +<template> |
| 91 | + <id>my-template</id> |
| 92 | + <name>My Custom Template</name> |
| 93 | + <description>What this template does</description> |
| 94 | + |
| 95 | + <parameters> |
| 96 | + <parameter name="moduleName"> |
| 97 | + <displayName>Module Name</displayName> |
| 98 | + <description>Name of the module</description> |
| 99 | + <type>TEXT</type> |
| 100 | + <required>true</required> |
| 101 | + </parameter> |
| 102 | + |
| 103 | + <parameter name="packageName"> |
| 104 | + <displayName>Package Name</displayName> |
| 105 | + <type>PACKAGE</type> |
| 106 | + <required>true</required> |
| 107 | + </parameter> |
| 108 | + |
| 109 | + <parameter name="useCompose"> |
| 110 | + <displayName>Use Jetpack Compose</displayName> |
| 111 | + <type>BOOLEAN</type> |
| 112 | + <default>true</default> |
| 113 | + </parameter> |
| 114 | + </parameters> |
| 115 | +</template> |
| 116 | +``` |
| 117 | + |
| 118 | +### Файлы .ftl |
| 119 | + |
| 120 | +FreeMarker шаблоны с полной поддержкой условий и циклов: |
| 121 | + |
| 122 | +**build.gradle.kts.ftl:** |
| 123 | +```kotlin |
| 124 | +plugins { |
| 125 | + kotlin("android") |
| 126 | +<#if useCompose == "true"> |
| 127 | + id("org.jetbrains.compose") |
| 128 | +</#if> |
| 129 | +} |
| 130 | + |
| 131 | +android { |
| 132 | + namespace = "${packageName}" |
| 133 | + compileSdk = 34 |
| 134 | + |
| 135 | +<#if useCompose == "true"> |
| 136 | + buildFeatures { |
| 137 | + compose = true |
| 138 | + } |
| 139 | +</#if> |
| 140 | +} |
| 141 | + |
| 142 | +dependencies { |
| 143 | + implementation("org.jetbrains.kotlin:kotlin-stdlib") |
| 144 | +<#if useCompose == "true"> |
| 145 | + implementation("androidx.compose.ui:ui:1.5.4") |
| 146 | + implementation("androidx.compose.material3:material3:1.1.2") |
| 147 | +</#if> |
| 148 | +} |
| 149 | +``` |
| 150 | + |
| 151 | +**MyClass.kt.ftl:** |
| 152 | +```kotlin |
| 153 | +package ${packageName} |
| 154 | + |
| 155 | +<#if useCompose == "true"> |
| 156 | +import androidx.compose.runtime.Composable |
| 157 | + |
| 158 | +@Composable |
| 159 | +fun MyScreen() { |
| 160 | + // Compose UI here |
| 161 | +} |
| 162 | +<#else> |
| 163 | +class MyClass { |
| 164 | + fun doSomething() { |
| 165 | + println("Hello from ${moduleName}!") |
| 166 | + } |
| 167 | +} |
| 168 | +</#if> |
| 169 | +``` |
| 170 | + |
| 171 | +## 🎨 Возможности FreeMarker |
| 172 | + |
| 173 | +### Переменные |
| 174 | +``` |
| 175 | +${variableName} - Вставка переменной |
| 176 | +${packagePath} - Автоматически из packageName (com/example/app) |
| 177 | +``` |
| 178 | + |
| 179 | +### Условия |
| 180 | +```ftl |
| 181 | +<#if condition == "true"> |
| 182 | + // код если true |
| 183 | +<#elseif otherCondition> |
| 184 | + // код если другое |
| 185 | +<#else> |
| 186 | + // иначе |
| 187 | +</#if> |
| 188 | +``` |
| 189 | + |
| 190 | +### Циклы |
| 191 | +```ftl |
| 192 | +<#list items as item> |
| 193 | + implementation("${item}") |
| 194 | +</#list> |
| 195 | +``` |
| 196 | + |
| 197 | +### Функции |
| 198 | +```ftl |
| 199 | +${moduleName?cap_first} - Первая буква заглавная |
| 200 | +${packageName?replace(".", "/")} - Замена символов |
| 201 | +``` |
| 202 | + |
| 203 | +## 📚 Примеры шаблонов |
| 204 | + |
| 205 | +Смотрите готовые примеры в папке `template-examples/`: |
| 206 | + |
| 207 | +- **kmp-module** - Kotlin Multiplatform модуль с Android/iOS |
| 208 | +- Используйте эти примеры как основу для своих шаблонов |
| 209 | + |
| 210 | +## 🎨 Создание шаблонов через UI |
| 211 | + |
| 212 | +**New Template...** - создаёт новый шаблон через визард: |
| 213 | +- Указываете ID, имя и описание |
| 214 | +- Добавляете параметры (moduleName, packageName и т.д.) |
| 215 | +- Плагин создаёт структуру папок и `template.xml` |
| 216 | +- Дальше редактируете .ftl файлы вручную |
| 217 | + |
| 218 | +**Edit Template...** - редактирует существующий: |
| 219 | +- Выбираете шаблон из списка |
| 220 | +- Изменяете имя, описание, параметры |
| 221 | +- Сохраняете изменения в `template.xml` |
| 222 | + |
| 223 | +## ⚙️ Типы параметров |
| 224 | + |
| 225 | +| Тип | Описание | Пример | |
| 226 | +|-----|----------|--------| |
| 227 | +| `TEXT` | Обычный текст | Module name | |
| 228 | +| `PACKAGE` | Имя пакета | com.example.app | |
| 229 | +| `BOOLEAN` | Да/Нет | true/false | |
| 230 | +| `NUMBER` | Число | 24 | |
| 231 | + |
| 232 | +## 🎯 Использование в команде |
| 233 | + |
| 234 | +1. Создайте шаблоны в `.idea/kmp-templates/` |
| 235 | +2. Закоммитьте их в репозиторий |
| 236 | +3. Вся команда использует одинаковые шаблоны |
| 237 | +4. Изменения шаблонов = просто изменение файлов |
| 238 | + |
| 239 | +## 📖 Документация FreeMarker |
| 240 | + |
| 241 | +Полная документация: https://freemarker.apache.org/docs/ |
| 242 | + |
| 243 | +Основные возможности: |
| 244 | +- Условия: `<#if>`, `<#elseif>`, `<#else>` |
| 245 | +- Циклы: `<#list>`, `<#items>` |
| 246 | +- Функции: `?upper_case`, `?lower_case`, `?cap_first`, `?replace` |
| 247 | +- Макросы: `<#macro>`, `<#nested>` |
29 | 248 |
|
30 | | -- Using the IDE built-in plugin system: |
31 | | - |
32 | | - <kbd>Settings/Preferences</kbd> > <kbd>Plugins</kbd> > <kbd>Marketplace</kbd> > <kbd>Search for "kmp-module-generator"</kbd> > |
33 | | - <kbd>Install</kbd> |
34 | | - |
35 | | -- Using JetBrains Marketplace: |
| 249 | +## 🤝 Contributing |
36 | 250 |
|
37 | | - Go to [JetBrains Marketplace](https://plugins.jetbrains.com/plugin/MARKETPLACE_ID) and install it by clicking the <kbd>Install to ...</kbd> button in case your IDE is running. |
| 251 | +Pull requests приветствуются! Особенно: |
| 252 | +- Новые шаблоны |
| 253 | +- Улучшения UI |
| 254 | +- Баг-фиксы |
38 | 255 |
|
39 | | - You can also download the [latest release](https://plugins.jetbrains.com/plugin/MARKETPLACE_ID/versions) from JetBrains Marketplace and install it manually using |
40 | | - <kbd>Settings/Preferences</kbd> > <kbd>Plugins</kbd> > <kbd>⚙️</kbd> > <kbd>Install plugin from disk...</kbd> |
| 256 | +## 📄 License |
41 | 257 |
|
42 | | -- Manually: |
| 258 | +MIT License |
43 | 259 |
|
44 | | - Download the [latest release](https://github.com/NonoxyS/kmp-module-generator/releases/latest) and install it manually using |
45 | | - <kbd>Settings/Preferences</kbd> > <kbd>Plugins</kbd> > <kbd>⚙️</kbd> > <kbd>Install plugin from disk...</kbd> |
| 260 | +## 🔗 Links |
46 | 261 |
|
| 262 | +- Issues: https://github.com/NonoxyS/kmp-module-generator/issues |
| 263 | +- Discussions: https://github.com/NonoxyS/kmp-module-generator/discussions |
47 | 264 |
|
48 | 265 | --- |
49 | | -Plugin based on the [IntelliJ Platform Plugin Template][template]. |
50 | 266 |
|
51 | | -[template]: https://github.com/JetBrains/intellij-platform-plugin-template |
52 | | -[docs:plugin-description]: https://plugins.jetbrains.com/docs/intellij/plugin-user-experience.html#plugin-description-and-presentation |
| 267 | +**Сделано с ❤️ для Kotlin Multiplatform community** |
0 commit comments