Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f9e1919
Start on fabric project creator
Earthcomputer Jun 29, 2020
0a60394
Rename gradle steps
Earthcomputer Jun 29, 2020
454e5d7
Smart mode fixes
Earthcomputer Jun 30, 2020
25b30e2
Fix entrypoint generation
Earthcomputer Jun 30, 2020
82a13cc
Fix formatting
Earthcomputer Jun 30, 2020
376c479
Fix license headers in template descriptions
Earthcomputer Jun 30, 2020
7cd3388
Fix template licenses again
Earthcomputer Jun 30, 2020
49f6c07
Fix formatting again
Earthcomputer Jun 30, 2020
e891235
Fix licenses not being written
Earthcomputer Jul 1, 2020
d10d863
Fix dropdown for entrypoint type column
Earthcomputer Jul 1, 2020
d443202
Fix formatting (again)
Earthcomputer Jul 1, 2020
dd59f84
Entrypoint fixes
Earthcomputer Jul 2, 2020
1073705
Fix formatting of fabric.mod.json
Earthcomputer Jul 2, 2020
5010bfd
fabric.mod.json references and basic validation inspection
Earthcomputer Jul 2, 2020
cf2ef3f
Add multi-module fabric support
Earthcomputer Jul 2, 2020
86e06e6
Fix licenses (why does intellij do this)
Earthcomputer Jul 2, 2020
e61f6cc
Update src/main/resources/fileTemplates/j2ee/fabric/fabric_mixins.jso…
Earthcomputer Jul 3, 2020
c32a006
Update default gradle versions
Earthcomputer Jul 3, 2020
c1eb2fa
Fix semver parsing for snapshots
Earthcomputer Jul 3, 2020
d40985e
Formatting
Earthcomputer Jul 3, 2020
19ac4cb
Show plugin icon by using EntryPointReferences
Earthcomputer Jul 3, 2020
797887f
Apply review suggestions
Earthcomputer Jul 3, 2020
7520a9a
Add fabric to readme
Earthcomputer Jul 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ repositories {
maven("https://repo.spongepowered.org/maven")
maven("https://jetbrains.bintray.com/intellij-third-party-dependencies")
maven("https://repo.gradle.org/gradle/libs-releases-local/")
maven("https://maven.extracraftx.com")
}

dependencies {
Expand All @@ -86,6 +87,8 @@ dependencies {
}
compileOnly("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion")

implementation("com.extracraftx.minecraft:TemplateMakerFabric:0.3.0")

jflex("org.jetbrains.idea:jflex:1.7.0-b7f882a")
jflexSkeleton("org.jetbrains.idea:jflex:1.7.0-c1fdf11:idea@skeleton")
grammarKit("org.jetbrains.idea:grammar-kit:1.5.1")
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ Supported Platforms
- [![Bukkit Icon](src/main/resources/assets/icons/platform/Bukkit.png?raw=true) **Bukkit**](https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse) ([![Spigot Icon](src/main/resources/assets/icons/platform/Spigot.png?raw=true) Spigot](https://spigotmc.org/) and [![Paper Icon](src/main/resources/assets/icons/platform/Paper.png?raw=true) Paper](https://papermc.io/))
- [![Sponge Icon](src/main/resources/assets/icons/platform/Sponge_dark.png?raw=true) **Sponge**](https://www.spongepowered.org/)
- [![Forge Icon](src/main/resources/assets/icons/platform/Forge.png?raw=true) **Minecraft Forge**](http://minecraftforge.net/forum)
- [![Fabric Icon](src/main/resources/assets/icons/platform/Fabric.png?raw=true) **Fabric**](https://fabricmc.net)
- [![LiteLoader Icon](src/main/resources/assets/icons/platform/LiteLoader.png?raw=true) **LiteLoader**](http://www.liteloader.com/)
- [![MCP Icon](src/main/resources/assets/icons/platform/MCP.png?raw=true) **MCP**](http://www.modcoderpack.com/)
- [![Mixins Icon](src/main/resources/assets/icons/platform/Mixins_dark.png?raw=true) **Mixins**](https://github.com/SpongePowered/Mixin)
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/com/demonwav/mcdev/asset/PlatformAssets.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ object PlatformAssets : Assets() {
val FORGE_ICON = loadIcon("/assets/icons/platform/Forge.png")
val FORGE_ICON_2X = loadIcon("/assets/icons/platform/Forge@2x.png")

val FABRIC_ICON = loadIcon("/assets/icons/platform/Fabric.png")
val FABRIC_ICON_2X = loadIcon("/assets/icons/platform/Fabric@2x.png")

val SPONGE_ICON = loadIcon("/assets/icons/platform/Sponge.png")
val SPONGE_ICON_2X = loadIcon("/assets/icons/platform/Sponge@2x.png")
val SPONGE_ICON_DARK = loadIcon("/assets/icons/platform/Sponge_dark.png")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.demonwav.mcdev.asset.PlatformAssets
import com.demonwav.mcdev.platform.MinecraftModuleType
import com.demonwav.mcdev.platform.bukkit.creator.BukkitProjectSettingsWizard
import com.demonwav.mcdev.platform.bungeecord.creator.BungeeCordProjectSettingsWizard
import com.demonwav.mcdev.platform.fabric.creator.FabricProjectSettingsWizard
import com.demonwav.mcdev.platform.forge.creator.ForgeProjectSettingsWizard
import com.demonwav.mcdev.platform.liteloader.creator.LiteLoaderProjectSettingsWizard
import com.demonwav.mcdev.platform.sponge.creator.SpongeProjectSettingsWizard
Expand Down Expand Up @@ -107,6 +108,7 @@ class MinecraftModuleBuilder : JavaModuleBuilder() {
BukkitProjectSettingsWizard(creator),
SpongeProjectSettingsWizard(creator),
ForgeProjectSettingsWizard(creator),
FabricProjectSettingsWizard(creator),
LiteLoaderProjectSettingsWizard(creator),
VelocityProjectSettingsWizard(creator),
BungeeCordProjectSettingsWizard(creator)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package com.demonwav.mcdev.creator

import com.demonwav.mcdev.creator.buildsystem.BuildSystem
import com.demonwav.mcdev.creator.exception.SetupException
import com.demonwav.mcdev.util.toPackageName
import com.intellij.ide.util.projectWizard.ModuleWizardStep
import com.intellij.openapi.ui.MessageType
import com.intellij.openapi.ui.popup.Balloon
Expand Down Expand Up @@ -48,8 +49,8 @@ abstract class MinecraftModuleWizardStep : ModuleWizardStep() {
name: String,
classNameModifier: (String) -> String = { it }
): String {
val packageNameStart = buildSystem.groupId.replace("-", "").toLowerCase()
val packageNameEnd = buildSystem.artifactId.replace("-", "").toLowerCase()
val packageNameStart = buildSystem.groupId.toPackageName()
val packageNameEnd = buildSystem.artifactId.toPackageName()
val className = classNameModifier(name.replace(" ", ""))
return "$packageNameStart.$packageNameEnd.$className"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class MinecraftProjectCreator {
return
}
config.type.type.performCreationSettingSetup(module.project)
CreatorStep.runAllReformats()
} else {
val types = configs.map { it.type }
newLog(build.javaClass.name + "::multiModuleBaseSteps", workLog).let { log ->
Expand All @@ -109,6 +110,8 @@ class MinecraftProjectCreator {
}
}

val postMultiModuleAwares = mutableListOf<PostMultiModuleAware>()

for (config in configs) {
val log = newLog(config, workLog)

Expand All @@ -117,10 +120,14 @@ class MinecraftProjectCreator {
val dir = Files.createDirectories(root.resolve(newArtifactId))

val newBuild = build.createSub(newArtifactId)
if (!newBuild.buildCreator(config, dir, module).getMultiModuleSteps(root).run(indicator, log)) {
val creator = newBuild.buildCreator(config, dir, module)
if (!creator.getMultiModuleSteps(root).run(indicator, log)) {
return
}
config.type.type.performCreationSettingSetup(module.project)
if (creator is PostMultiModuleAware) {
postMultiModuleAwares += creator
}
}

val commonArtifactId = "${build.artifactId}-common"
Expand All @@ -138,6 +145,13 @@ class MinecraftProjectCreator {
newLog(build.javaClass.name + "::multiModuleBaseFinalizer", workLog).let { log ->
build.multiModuleBaseFinalizer(module, root).run(indicator, log)
}

for (postMultiModuleAware in postMultiModuleAwares) {
val log = newLog(postMultiModuleAware, workLog)
if (!postMultiModuleAware.getPostMultiModuleSteps(root).run(indicator, log)) {
return
}
}
}

// Tell IntelliJ about everything we've done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.demonwav.mcdev.creator.buildsystem.BuildSystemType
import com.demonwav.mcdev.platform.PlatformType
import com.demonwav.mcdev.platform.bukkit.creator.BukkitProjectConfig
import com.demonwav.mcdev.platform.bungeecord.creator.BungeeCordProjectConfig
import com.demonwav.mcdev.platform.fabric.creator.FabricProjectConfig
import com.demonwav.mcdev.platform.forge.creator.ForgeProjectConfig
import com.demonwav.mcdev.platform.liteloader.creator.LiteLoaderProjectConfig
import com.demonwav.mcdev.platform.sponge.creator.SpongeProjectConfig
Expand All @@ -41,6 +42,7 @@ class PlatformChooserWizardStep(private val creator: MinecraftProjectCreator) :
private lateinit var paperPluginCheckBox: JCheckBox
private lateinit var spongePluginCheckBox: JCheckBox
private lateinit var forgeModCheckBox: JCheckBox
private lateinit var fabricModCheckBox: JCheckBox
private lateinit var bungeeCordPluginCheckBox: JCheckBox
private lateinit var waterfallPluginCheckBox: JCheckBox
private lateinit var velocityPluginCheckBox: JCheckBox
Expand Down Expand Up @@ -117,6 +119,7 @@ class PlatformChooserWizardStep(private val creator: MinecraftProjectCreator) :
paperPluginCheckBox.isSelected ||
spongePluginCheckBox.isSelected ||
forgeModCheckBox.isSelected ||
fabricModCheckBox.isSelected ||
liteLoaderModCheckBox.isSelected ||
bungeeCordPluginCheckBox.isSelected ||
waterfallPluginCheckBox.isSelected ||
Expand Down Expand Up @@ -145,6 +148,10 @@ class PlatformChooserWizardStep(private val creator: MinecraftProjectCreator) :
result += ForgeProjectConfig()
}

if (fabricModCheckBox.isSelected) {
result += FabricProjectConfig()
}

if (liteLoaderModCheckBox.isSelected) {
result += LiteLoaderProjectConfig()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<properties/>
<border type="empty"/>
<children>
<grid id="c580e" binding="chooserPanel" layout-manager="GridLayoutManager" row-count="10" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="5" vgap="5">
<grid id="c580e" binding="chooserPanel" layout-manager="GridLayoutManager" row-count="11" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="5" vgap="5">
<margin top="2" left="10" bottom="10" right="10"/>
<constraints/>
<properties/>
Expand Down Expand Up @@ -90,7 +90,7 @@
</component>
<component id="ef19b" class="javax.swing.JLabel">
<constraints>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<icon value="assets/icons/platform/BungeeCord@2x.png"/>
Expand Down Expand Up @@ -140,15 +140,15 @@
</component>
<component id="51426" class="javax.swing.JCheckBox" binding="bungeeCordPluginCheckBox">
<constraints>
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="8" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="BungeeCord Plugin"/>
</properties>
</component>
<component id="a965" class="javax.swing.JLabel">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<icon value="assets/icons/platform/LiteLoader@2x.png"/>
Expand All @@ -157,15 +157,15 @@
</component>
<component id="5a8c1" class="javax.swing.JCheckBox" binding="liteLoaderModCheckBox" default-binding="true">
<constraints>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="LiteLoader Mod"/>
</properties>
</component>
<component id="87b9d" class="javax.swing.JLabel">
<constraints>
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="true"/>
Expand All @@ -176,7 +176,7 @@
</component>
<component id="405e" class="javax.swing.JLabel">
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="true"/>
Expand All @@ -187,25 +187,42 @@
</component>
<component id="55507" class="javax.swing.JCheckBox" binding="waterfallPluginCheckBox">
<constraints>
<grid row="8" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Waterfall Plugin"/>
</properties>
</component>
<component id="93e0" class="javax.swing.JCheckBox" binding="velocityPluginCheckBox">
<constraints>
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Velocity Plugin"/>
</properties>
</component>
<vspacer id="d9ec2">
<constraints>
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="10" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="e8c19" class="javax.swing.JLabel">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<icon value="assets/icons/platform/Fabric@2x.png"/>
<text value=""/>
</properties>
</component>
<component id="40b19" class="javax.swing.JCheckBox" binding="fabricModCheckBox">
<constraints>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Fabric Mod"/>
</properties>
</component>
</children>
</grid>
</children>
Expand Down
18 changes: 17 additions & 1 deletion src/main/kotlin/com/demonwav/mcdev/creator/ProjectCreator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ abstract class BaseProjectCreator(
protected val project
get() = rootModule.project

protected fun createJavaClassStep(qualifiedClassName: String, mapper: JavaClassTextMapper): BasicJavaClassStep {
protected fun createJavaClassStep(
qualifiedClassName: String,
mapper: JavaClassTextMapper
): BasicJavaClassStep {
val (packageName, className) = splitPackage(qualifiedClassName)
val classText = mapper(packageName, className)
return BasicJavaClassStep(project, buildSystem, qualifiedClassName, classText)
Expand All @@ -66,3 +69,16 @@ abstract class BaseProjectCreator(
return packageName to className
}
}

/**
* Implement this interface on your [ProjectCreator] if you need to do extra setup work after all modules are built
* and the project is imported, e.g. if some of the creation needs to be done in smart mode. Only gets used in
* multi-project builds; single-module builds are expected to run these tasks themselves in the correct order, such
* that they happen after the project is imported.
*
* Note: just because this interface can be used to utilize smart mode, doesn't mean that the steps will be called in
* smart mode. If a step needs smart mode, it should wait for it itself.
*/
interface PostMultiModuleAware {
fun getPostMultiModuleSteps(projectBaseDir: Path): Iterable<CreatorStep>
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class GradleBuildSystem(
val files = GradleFiles(buildText, propText, settingsText)

return listOf(
BasicGradleStep(project, rootDirectory, this, files),
GradleSetupStep(project, rootDirectory, this, files),
GradleWrapperStep(project, rootDirectory, this)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.demonwav.mcdev.creator.CreatorStep.Companion.writeText
import com.demonwav.mcdev.creator.buildsystem.BuildSystem
import com.demonwav.mcdev.creator.buildsystem.BuildSystemTemplate
import com.demonwav.mcdev.creator.buildsystem.BuildSystemType
import com.demonwav.mcdev.creator.buildsystem.DirectorySet
import com.demonwav.mcdev.util.asPrimitiveType
import com.demonwav.mcdev.util.findDeclaredField
import com.demonwav.mcdev.util.invokeDeclaredMethod
Expand Down Expand Up @@ -51,7 +52,47 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression

class BasicGradleStep(
class SimpleGradleSetupStep(
private val project: Project,
private val rootDirectory: Path,
private val buildSystem: BuildSystem,
private val gradleFiles: GradleFiles<String>
) : CreatorStep {

override fun runStep(indicator: ProgressIndicator) {
runWriteTask {
buildSystem.directories =
DirectorySet.create(rootDirectory)
val (buildGradle, gradleProp, settingsGradle) = setupGradleFiles(
rootDirectory,
gradleFiles
)

val psiManager = PsiManager.getInstance(project)
writeText(
buildGradle,
gradleFiles.buildGradle,
psiManager
)
if (gradleProp != null && gradleFiles.gradleProperties != null) {
writeText(
gradleProp,
gradleFiles.gradleProperties,
psiManager
)
}
if (settingsGradle != null && gradleFiles.settingsGradle != null) {
writeText(
settingsGradle,
gradleFiles.settingsGradle,
psiManager
)
}
}
}
}

class GradleSetupStep(
private val project: Project,
private val rootDirectory: Path,
private val buildSystem: BuildSystem,
Expand Down
Loading