Skip to content

Commit 452eee7

Browse files
committed
Add core functionality for module generator
1 parent b37abce commit 452eee7

45 files changed

Lines changed: 3025 additions & 202 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,40 @@
1-
.DS_Store
2-
.gradle
3-
.idea
1+
# IntelliJ IDEA
2+
.idea/
3+
/.idea/
4+
*.iml
5+
*.ipr
6+
*.iws
7+
out/
48
.intellijPlatform
5-
.kotlin
6-
.qodana
7-
build
9+
10+
# Gradle
11+
.gradle/
12+
build/
13+
!gradle-wrapper.jar
14+
15+
# Kotlin
16+
*.kotlin_module
17+
18+
# OS
19+
.DS_Store
20+
Thumbs.db
21+
22+
# Plugin build
23+
/distributions/
24+
25+
# Test data
26+
/testData/
27+
28+
# Logs
29+
*.log
30+
31+
# Temporary files
32+
*.tmp
33+
*.bak
34+
*.swp
35+
*~
36+
37+
# Plugin signing certificates (NEVER commit these!)
38+
*.pem
39+
*.crt
40+
/signing

CHANGELOG.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
<!-- Keep a Changelog guide -> https://keepachangelog.com -->
2-
3-
# kmp-module-generator Changelog
1+
# Changelog
42

53
## [Unreleased]
4+
5+
## [0.0.1] - 2025-10-26
6+
67
### Added
7-
- Initial scaffold created from [IntelliJ Platform Plugin Template](https://github.com/JetBrains/intellij-platform-plugin-template)
8+
9+
- 🎨 **FreeMarker template system** - create module templates as simple text files
10+
- 🖥️ **Visual template wizards** - create and edit templates through intuitive UI
11+
- 📂 **Configurable template storage** - use custom folder or default `.idea/kmp-templates/`
12+
13+
[Unreleased]: https://github.com/NonoxyS/kmp-module-generator/compare/v0.0.1...HEAD
14+
[0.0.1]: https://github.com/NonoxyS/kmp-module-generator/commits/v0.0.1

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Andrey Dobrov
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

Lines changed: 253 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,267 @@
1-
# kmp-module-generator
2-
3-
![Build](https://github.com/NonoxyS/kmp-module-generator/workflows/Build/badge.svg)
4-
[![Version](https://img.shields.io/jetbrains/plugin/v/MARKETPLACE_ID.svg)](https://plugins.jetbrains.com/plugin/MARKETPLACE_ID)
5-
[![Downloads](https://img.shields.io/jetbrains/plugin/d/MARKETPLACE_ID.svg)](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
192

203
<!-- 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.
225

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
2612
<!-- Plugin description end -->
2713

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>`
29248

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
36250

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+
- Баг-фиксы
38255

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
41257

42-
- Manually:
258+
MIT License
43259

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
46261

262+
- Issues: https://github.com/NonoxyS/kmp-module-generator/issues
263+
- Discussions: https://github.com/NonoxyS/kmp-module-generator/discussions
47264

48265
---
49-
Plugin based on the [IntelliJ Platform Plugin Template][template].
50266

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

Comments
 (0)