Skip to content

Commit 3172c6e

Browse files
authored
support multiplatform module types (#76)
1 parent 941154a commit 3172c6e

File tree

13 files changed

+1082
-44
lines changed

13 files changed

+1082
-44
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Module Maker Changelog
22

3+
## [1.1.0]
4+
- Support Multiplatform modules
5+
36
## [1.0.26]
47
- Platform updates
58

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pluginGroup = com.joetr.modulemaker
44
pluginName = ModuleMaker
55
pluginRepositoryUrl = https://github.com/j-roskopf/ModuleMakerPlugin
66
# SemVer format -> https://semver.org
7-
pluginVersion = 1.0.26
7+
pluginVersion = 1.1.0
88

99
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
1010
pluginSinceBuild = 222

src/main/kotlin/com/joetr/modulemaker/ModuleMakerDialogWrapper.kt

Lines changed: 99 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package com.joetr.modulemaker
22

3+
import androidx.compose.animation.AnimatedVisibility
34
import androidx.compose.foundation.layout.Column
5+
import androidx.compose.foundation.layout.ExperimentalLayoutApi
6+
import androidx.compose.foundation.layout.FlowRow
47
import androidx.compose.foundation.layout.Row
58
import androidx.compose.foundation.layout.fillMaxSize
69
import androidx.compose.foundation.layout.fillMaxWidth
@@ -21,6 +24,7 @@ import androidx.compose.material.Text
2124
import androidx.compose.material.icons.Icons
2225
import androidx.compose.material.icons.filled.Info
2326
import androidx.compose.runtime.Composable
27+
import androidx.compose.runtime.mutableStateListOf
2428
import androidx.compose.runtime.mutableStateOf
2529
import androidx.compose.runtime.remember
2630
import androidx.compose.ui.Alignment
@@ -53,12 +57,13 @@ import javax.swing.Action
5357
import javax.swing.JComponent
5458

5559
private const val WINDOW_WIDTH = 840
56-
private const val WINDOW_HEIGHT = 600
60+
private const val WINDOW_HEIGHT = 800
5761
private const val FILE_TREE_WIDTH = 300
5862
private const val CONFIGURATION_PANEL_WIDTH = 540
5963

6064
const val ANDROID = "Android"
61-
const val KOTLIN = "Kotlin"
65+
const val MULTIPLATFORM = "Multiplatform"
66+
const val KOTLIN = "Kotlin / JVM"
6267

6368
private const val DEFAULT_MODULE_NAME = ":repository:database (as an example)"
6469
private const val DEFAULT_SRC_VALUE = "EMPTY"
@@ -82,8 +87,10 @@ class ModuleMakerDialogWrapper(
8287
private val addReadme = mutableStateOf(preferenceService.preferenceState.addReadme)
8388
private val addGitIgnore = mutableStateOf(preferenceService.preferenceState.addGitIgnore)
8489
private val moduleTypeSelection = mutableStateOf(ANDROID)
90+
private val platformTypeSelection = mutableStateOf(ANDROID)
8591
private val moduleName = mutableStateOf("")
8692
private val packageName = mutableStateOf(preferenceService.preferenceState.packageName)
93+
private val sourceSets = mutableStateListOf<String>()
8794

8895
// Segment's write key isn't really a secret
8996
private var analytics: Analytics = Analytics("CNghGjhOHipwGB9YdWMBwkMTJbRFtizc") {
@@ -121,7 +128,8 @@ class ModuleMakerDialogWrapper(
121128
modifier = Modifier.height(startingHeight.value.dp).width(fileTreeWidth.value.dp)
122129
)
123130
ConfigurationPanel(
124-
modifier = Modifier.height(startingHeight.value.dp).width(configurationPanelWidth.value.dp)
131+
modifier = Modifier.height(startingHeight.value.dp)
132+
.width(configurationPanelWidth.value.dp)
125133
)
126134
}
127135
}
@@ -222,6 +230,7 @@ class ModuleMakerDialogWrapper(
222230
)
223231
}
224232

233+
@OptIn(ExperimentalLayoutApi::class)
225234
@Composable
226235
private fun ConfigurationPanel(
227236
modifier: Modifier = Modifier
@@ -295,6 +304,7 @@ class ModuleMakerDialogWrapper(
295304
val radioOptions = listOf(ANDROID, KOTLIN)
296305
val moduleTypeSelectionState = remember { moduleTypeSelection }
297306
Column {
307+
Text("Module Type")
298308
radioOptions.forEach { text ->
299309
Row(
300310
modifier = Modifier.selectable(
@@ -324,6 +334,85 @@ class ModuleMakerDialogWrapper(
324334
}
325335
}
326336

337+
val platformTypeRadioOptions = listOf(ANDROID, MULTIPLATFORM)
338+
val platformTypeRadioOptionsState = remember { platformTypeSelection }
339+
Column {
340+
Text("Platform Type")
341+
platformTypeRadioOptions.forEach { text ->
342+
Row(
343+
modifier = Modifier.selectable(
344+
selected = (text == platformTypeRadioOptionsState.value),
345+
onClick = {
346+
platformTypeRadioOptionsState.value = text
347+
}
348+
).padding(end = 16.dp),
349+
verticalAlignment = Alignment.CenterVertically
350+
) {
351+
RadioButton(
352+
colors = RadioButtonDefaults.colors(
353+
selectedColor = MaterialTheme.colors.primary,
354+
unselectedColor = MaterialTheme.colors.primaryVariant
355+
),
356+
selected = (text == platformTypeRadioOptionsState.value),
357+
onClick = {
358+
platformTypeRadioOptionsState.value = text
359+
}
360+
)
361+
Text(
362+
text = text,
363+
style = MaterialTheme.typography.body1.merge(),
364+
modifier = Modifier.padding(start = 8.dp)
365+
)
366+
}
367+
}
368+
369+
val selectedSourceSets = remember {
370+
sourceSets
371+
}
372+
373+
AnimatedVisibility(
374+
platformTypeSelection.value == MULTIPLATFORM
375+
) {
376+
Column {
377+
Text(modifier = Modifier.padding(vertical = 8.dp), text = "Selected Source Sets: ${selectedSourceSets.joinToString(separator = ", ")}")
378+
379+
FlowRow(Modifier.padding(vertical = 8.dp)) {
380+
kotlinMultiplatformSourceSets.forEach { sourceSet ->
381+
LabelledCheckbox(
382+
label = sourceSet,
383+
checked = selectedSourceSets.contains(sourceSet),
384+
onCheckedChange = {
385+
if (it) {
386+
selectedSourceSets.add(sourceSet)
387+
} else {
388+
selectedSourceSets.remove(sourceSet)
389+
}
390+
}
391+
)
392+
}
393+
}
394+
395+
Text("Test Source Sets")
396+
397+
FlowRow(Modifier.padding(vertical = 8.dp)) {
398+
kotlinMultiplatformTestSourceSets.forEach { sourceSet ->
399+
LabelledCheckbox(
400+
label = sourceSet,
401+
checked = selectedSourceSets.contains(sourceSet),
402+
onCheckedChange = {
403+
if (it) {
404+
selectedSourceSets.add(sourceSet)
405+
} else {
406+
selectedSourceSets.remove(sourceSet)
407+
}
408+
}
409+
)
410+
}
411+
}
412+
}
413+
}
414+
}
415+
327416
val packageNameState = remember { packageName }
328417
OutlinedTextField(
329418
label = { Text("Package Name") },
@@ -420,7 +509,9 @@ class ModuleMakerDialogWrapper(
420509
packageName = packageName.value,
421510
addReadme = addReadme.value,
422511
addGitIgnore = addGitIgnore.value,
423-
previewMode = previewMode
512+
previewMode = previewMode,
513+
platformType = platformTypeSelection.value,
514+
sourceSets = sourceSets.toList()
424515
)
425516

426517
return filesCreated
@@ -476,3 +567,7 @@ class ModuleMakerDialogWrapper(
476567
return path.split(File.separator).last()
477568
}
478569
}
570+
571+
/*
572+
kotlin multiplatform template in settings
573+
create folders for each source set*/
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyrightest (c) 2025 Joseph Roskopf
3+
*/
4+
5+
package com.joetr.modulemaker
6+
7+
val kotlinMultiplatformSourceSets = listOf(
8+
// Main Source Sets
9+
"commonMain",
10+
"androidMain",
11+
"jvmMain",
12+
"nativeMain",
13+
"iosMain",
14+
"jsMain",
15+
"wasmJsMain",
16+
"iosArm64Main",
17+
"iosX64Main",
18+
"iosSimulatorArm64Main",
19+
"macosMain",
20+
"macosX64Main",
21+
"macosArm64Main",
22+
"linuxMain",
23+
"linuxX64Main",
24+
"linuxArm64Main",
25+
"mingwMain",
26+
"mingwX64Main",
27+
"tvosMain",
28+
"tvosArm64Main",
29+
"tvosX64Main",
30+
"tvosSimulatorArm64Main",
31+
"watchosMain",
32+
"watchosArm32Main",
33+
"watchosArm64Main",
34+
"watchosX64Main",
35+
"watchosSimulatorArm64Main"
36+
)
37+
38+
val kotlinMultiplatformTestSourceSets = listOf(
39+
"commonTest",
40+
"androidTest",
41+
"jvmTest",
42+
"nativeTest",
43+
"iosTest",
44+
"jsTest",
45+
"wasmTest",
46+
"iosArm64Test",
47+
"iosX64Test",
48+
"iosSimulatorArm64Test",
49+
"macosTest",
50+
"macosX64Test",
51+
"macosArm64Test",
52+
"linuxTest",
53+
"linuxX64Test",
54+
"linuxArm64Test",
55+
"mingwTest",
56+
"mingwX64Test",
57+
"tvosTest",
58+
"tvosArm64Test",
59+
"tvosX64Test",
60+
"tvosSimulatorArm64Test",
61+
"watchosTest",
62+
"watchosArm32Test",
63+
"watchosArm64Test",
64+
"watchosX64Test",
65+
"watchosSimulatorArm64Test"
66+
)

0 commit comments

Comments
 (0)