From f9e1919419b78422e702af971b0bee5d9b974685 Mon Sep 17 00:00:00 2001 From: Joe Date: Mon, 29 Jun 2020 12:57:08 +0100 Subject: [PATCH 01/23] Start on fabric project creator --- build.gradle.kts | 3 + .../demonwav/mcdev/asset/PlatformAssets.kt | 3 + .../mcdev/creator/MinecraftModuleBuilder.kt | 2 + .../creator/MinecraftModuleWizardStep.kt | 5 +- .../creator/PlatformChooserWizardStep.kt | 7 + .../creator/ProjectChooserWizardStep.form | 37 +- .../demonwav/mcdev/creator/ProjectCreator.kt | 5 +- .../mcdev/creator/field-validation.kt | 48 +- .../mcdev/facet/MinecraftFacetEditorTab.form | 85 +- .../mcdev/facet/MinecraftFacetEditorTab.kt | 25 +- .../mcdev/facet/MinecraftLibraryKinds.kt | 2 + .../demonwav/mcdev/platform/PlatformType.kt | 4 + .../mcdev/platform/fabric/EntryPoint.kt | 34 + .../platform/fabric/FabricFileIconProvider.kt | 38 + .../mcdev/platform/fabric/FabricModule.kt | 54 ++ .../mcdev/platform/fabric/FabricModuleType.kt | 32 + .../fabric/creator/FabricProjectConfig.kt | 65 ++ .../fabric/creator/FabricProjectCreator.kt | 418 +++++++++ .../creator/FabricProjectSettingsWizard.form | 385 ++++++++ .../creator/FabricProjectSettingsWizard.kt | 400 ++++++++ .../platform/fabric/creator/FabricTemplate.kt | 129 +++ .../fabric/framework/FabricLibraryKind.kt | 15 + .../framework/FabricPresentationProvider.kt | 39 + .../platform/fabric/util/FabricConstants.kt | 22 + .../forge/creator/ForgeProjectCreator.kt | 14 +- .../creator/LiteLoaderProjectCreator.kt | 6 +- .../kotlin/com/demonwav/mcdev/util/License.kt | 28 + .../demonwav/mcdev/util/MinecraftTemplates.kt | 22 + .../demonwav/mcdev/util/SemanticVersion.kt | 25 +- .../com/demonwav/mcdev/util/class-utils.kt | 21 + .../kotlin/com/demonwav/mcdev/util/utils.kt | 27 +- src/main/resources/META-INF/plugin.xml | 5 + .../assets/icons/platform/Fabric.png | Bin 0 -> 394 bytes .../assets/icons/platform/Fabric@2x.png | Bin 0 -> 449 bytes .../j2ee/fabric/fabric_build.gradle.ft | 79 ++ .../j2ee/fabric/fabric_build.gradle.html | 15 + .../j2ee/fabric/fabric_gradle.properties.ft | 19 + .../j2ee/fabric/fabric_gradle.properties.html | 15 + .../j2ee/fabric/fabric_mixins.json.ft | 13 + .../j2ee/fabric/fabric_mixins.json.html | 15 + .../j2ee/fabric/fabric_mod.json.ft | 31 + .../j2ee/fabric/fabric_mod.json.html | 15 + .../j2ee/fabric/fabric_settings.gradle.ft | 10 + .../j2ee/fabric/fabric_settings.gradle.html | 15 + .../fileTemplates/j2ee/licenses/AGPL-3.0.ft | 633 +++++++++++++ .../fileTemplates/j2ee/licenses/AGPL-3.0.html | 15 + .../j2ee/licenses/All-Rights-Reserved.ft | 2 + .../j2ee/licenses/All-Rights-Reserved.html | 15 + .../fileTemplates/j2ee/licenses/Apache-2.0.ft | 13 + .../j2ee/licenses/Apache-2.0.html | 15 + .../j2ee/licenses/BSD-2-Clause-FreeBSD.ft | 26 + .../j2ee/licenses/BSD-2-Clause-FreeBSD.html | 15 + .../j2ee/licenses/BSD-3-Clause.ft | 26 + .../j2ee/licenses/BSD-3-Clause.html | 15 + .../fileTemplates/j2ee/licenses/GPL-3.0.ft | 694 ++++++++++++++ .../fileTemplates/j2ee/licenses/GPL-3.0.html | 15 + .../fileTemplates/j2ee/licenses/ISC.ft | 15 + .../fileTemplates/j2ee/licenses/ISC.html | 15 + .../fileTemplates/j2ee/licenses/LGPL-3.0.ft | 859 ++++++++++++++++++ .../fileTemplates/j2ee/licenses/LGPL-3.0.html | 15 + .../fileTemplates/j2ee/licenses/MIT.ft | 21 + .../fileTemplates/j2ee/licenses/MIT.html | 15 + .../fileTemplates/j2ee/licenses/MPL-2.0.ft | 380 ++++++++ .../fileTemplates/j2ee/licenses/MPL-2.0.html | 15 + .../fileTemplates/j2ee/licenses/unlicense.ft | 26 + .../j2ee/licenses/unlicense.html | 15 + 66 files changed, 5015 insertions(+), 77 deletions(-) create mode 100644 src/main/kotlin/com/demonwav/mcdev/platform/fabric/EntryPoint.kt create mode 100644 src/main/kotlin/com/demonwav/mcdev/platform/fabric/FabricFileIconProvider.kt create mode 100644 src/main/kotlin/com/demonwav/mcdev/platform/fabric/FabricModule.kt create mode 100644 src/main/kotlin/com/demonwav/mcdev/platform/fabric/FabricModuleType.kt create mode 100644 src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectConfig.kt create mode 100644 src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt create mode 100644 src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.form create mode 100644 src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt create mode 100644 src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricTemplate.kt create mode 100644 src/main/kotlin/com/demonwav/mcdev/platform/fabric/framework/FabricLibraryKind.kt create mode 100644 src/main/kotlin/com/demonwav/mcdev/platform/fabric/framework/FabricPresentationProvider.kt create mode 100644 src/main/kotlin/com/demonwav/mcdev/platform/fabric/util/FabricConstants.kt create mode 100644 src/main/kotlin/com/demonwav/mcdev/util/License.kt create mode 100644 src/main/resources/assets/icons/platform/Fabric.png create mode 100644 src/main/resources/assets/icons/platform/Fabric@2x.png create mode 100644 src/main/resources/fileTemplates/j2ee/fabric/fabric_build.gradle.ft create mode 100644 src/main/resources/fileTemplates/j2ee/fabric/fabric_build.gradle.html create mode 100644 src/main/resources/fileTemplates/j2ee/fabric/fabric_gradle.properties.ft create mode 100644 src/main/resources/fileTemplates/j2ee/fabric/fabric_gradle.properties.html create mode 100644 src/main/resources/fileTemplates/j2ee/fabric/fabric_mixins.json.ft create mode 100644 src/main/resources/fileTemplates/j2ee/fabric/fabric_mixins.json.html create mode 100644 src/main/resources/fileTemplates/j2ee/fabric/fabric_mod.json.ft create mode 100644 src/main/resources/fileTemplates/j2ee/fabric/fabric_mod.json.html create mode 100644 src/main/resources/fileTemplates/j2ee/fabric/fabric_settings.gradle.ft create mode 100644 src/main/resources/fileTemplates/j2ee/fabric/fabric_settings.gradle.html create mode 100644 src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.ft create mode 100644 src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.html create mode 100644 src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.ft create mode 100644 src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.html create mode 100644 src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.ft create mode 100644 src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.html create mode 100644 src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.ft create mode 100644 src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.html create mode 100644 src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.ft create mode 100644 src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.html create mode 100644 src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.ft create mode 100644 src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.html create mode 100644 src/main/resources/fileTemplates/j2ee/licenses/ISC.ft create mode 100644 src/main/resources/fileTemplates/j2ee/licenses/ISC.html create mode 100644 src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.ft create mode 100644 src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.html create mode 100644 src/main/resources/fileTemplates/j2ee/licenses/MIT.ft create mode 100644 src/main/resources/fileTemplates/j2ee/licenses/MIT.html create mode 100644 src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.ft create mode 100644 src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.html create mode 100644 src/main/resources/fileTemplates/j2ee/licenses/unlicense.ft create mode 100644 src/main/resources/fileTemplates/j2ee/licenses/unlicense.html diff --git a/build.gradle.kts b/build.gradle.kts index 4f6143801..7db76c7c8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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 { @@ -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") diff --git a/src/main/kotlin/com/demonwav/mcdev/asset/PlatformAssets.kt b/src/main/kotlin/com/demonwav/mcdev/asset/PlatformAssets.kt index d6b9e4b44..e4bfe8402 100644 --- a/src/main/kotlin/com/demonwav/mcdev/asset/PlatformAssets.kt +++ b/src/main/kotlin/com/demonwav/mcdev/asset/PlatformAssets.kt @@ -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") diff --git a/src/main/kotlin/com/demonwav/mcdev/creator/MinecraftModuleBuilder.kt b/src/main/kotlin/com/demonwav/mcdev/creator/MinecraftModuleBuilder.kt index 3e1be86cd..d69aeb492 100644 --- a/src/main/kotlin/com/demonwav/mcdev/creator/MinecraftModuleBuilder.kt +++ b/src/main/kotlin/com/demonwav/mcdev/creator/MinecraftModuleBuilder.kt @@ -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 @@ -107,6 +108,7 @@ class MinecraftModuleBuilder : JavaModuleBuilder() { BukkitProjectSettingsWizard(creator), SpongeProjectSettingsWizard(creator), ForgeProjectSettingsWizard(creator), + FabricProjectSettingsWizard(creator), LiteLoaderProjectSettingsWizard(creator), VelocityProjectSettingsWizard(creator), BungeeCordProjectSettingsWizard(creator) diff --git a/src/main/kotlin/com/demonwav/mcdev/creator/MinecraftModuleWizardStep.kt b/src/main/kotlin/com/demonwav/mcdev/creator/MinecraftModuleWizardStep.kt index 5ce30547d..7a18f0430 100644 --- a/src/main/kotlin/com/demonwav/mcdev/creator/MinecraftModuleWizardStep.kt +++ b/src/main/kotlin/com/demonwav/mcdev/creator/MinecraftModuleWizardStep.kt @@ -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 @@ -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" } diff --git a/src/main/kotlin/com/demonwav/mcdev/creator/PlatformChooserWizardStep.kt b/src/main/kotlin/com/demonwav/mcdev/creator/PlatformChooserWizardStep.kt index 6caa91272..f2311040e 100644 --- a/src/main/kotlin/com/demonwav/mcdev/creator/PlatformChooserWizardStep.kt +++ b/src/main/kotlin/com/demonwav/mcdev/creator/PlatformChooserWizardStep.kt @@ -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 @@ -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 @@ -117,6 +119,7 @@ class PlatformChooserWizardStep(private val creator: MinecraftProjectCreator) : paperPluginCheckBox.isSelected || spongePluginCheckBox.isSelected || forgeModCheckBox.isSelected || + fabricModCheckBox.isSelected || liteLoaderModCheckBox.isSelected || bungeeCordPluginCheckBox.isSelected || waterfallPluginCheckBox.isSelected || @@ -145,6 +148,10 @@ class PlatformChooserWizardStep(private val creator: MinecraftProjectCreator) : result += ForgeProjectConfig() } + if (fabricModCheckBox.isSelected) { + result += FabricProjectConfig() + } + if (liteLoaderModCheckBox.isSelected) { result += LiteLoaderProjectConfig() } diff --git a/src/main/kotlin/com/demonwav/mcdev/creator/ProjectChooserWizardStep.form b/src/main/kotlin/com/demonwav/mcdev/creator/ProjectChooserWizardStep.form index c09583e54..2e7ba0489 100644 --- a/src/main/kotlin/com/demonwav/mcdev/creator/ProjectChooserWizardStep.form +++ b/src/main/kotlin/com/demonwav/mcdev/creator/ProjectChooserWizardStep.form @@ -28,7 +28,7 @@ - + @@ -90,7 +90,7 @@ - + @@ -140,7 +140,7 @@ - + @@ -148,7 +148,7 @@ - + @@ -157,7 +157,7 @@ - + @@ -165,7 +165,7 @@ - + @@ -176,7 +176,7 @@ - + @@ -187,7 +187,7 @@ - + @@ -195,7 +195,7 @@ - + @@ -203,9 +203,26 @@ - + + + + + + + + + + + + + + + + + + diff --git a/src/main/kotlin/com/demonwav/mcdev/creator/ProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/creator/ProjectCreator.kt index 37434dd73..3b466547e 100644 --- a/src/main/kotlin/com/demonwav/mcdev/creator/ProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/creator/ProjectCreator.kt @@ -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) diff --git a/src/main/kotlin/com/demonwav/mcdev/creator/field-validation.kt b/src/main/kotlin/com/demonwav/mcdev/creator/field-validation.kt index 7c7e7538e..9856de0be 100644 --- a/src/main/kotlin/com/demonwav/mcdev/creator/field-validation.kt +++ b/src/main/kotlin/com/demonwav/mcdev/creator/field-validation.kt @@ -29,26 +29,7 @@ enum class ValidatedFieldType { }, CLASS_NAME { override fun validate(field: JTextField) { - // default package - if (!field.text.contains('.')) { - throw InvalidClassNameException(field) - } - val fieldNameSplit = field.text.split('.') - // crazy dots - if (fieldNameSplit.any { it.isBlank() } || field.text.first() == '.' || field.text.last() == '.') { - throw InvalidClassNameException(field) - } - // invalid character - if ( - fieldNameSplit.any { part -> - !part.first().isJavaIdentifierStart() || - !part.asSequence().drop(1).all { it.isJavaIdentifierPart() } - } - ) { - throw InvalidClassNameException(field) - } - // keyword identifier - if (fieldNameSplit.any { javaKeywords.contains(it) }) { + if (!isValidClassName(field.text)) { throw InvalidClassNameException(field) } } @@ -64,6 +45,33 @@ enum class ValidatedFieldType { abstract fun validate(field: JTextField) } +fun isValidClassName(className: String): Boolean { + // default package + if (!className.contains('.')) { + return false + } + val fieldNameSplit = className.split('.') + // crazy dots + if (fieldNameSplit.any { it.isBlank() } || className.first() == '.' || className.last() == '.') { + return false + } + // invalid character + if ( + fieldNameSplit.any { part -> + !part.first().isJavaIdentifierStart() || + !part.asSequence().drop(1).all { it.isJavaIdentifierPart() } + } + ) { + return false + } + // keyword identifier + if (fieldNameSplit.any { javaKeywords.contains(it) }) { + return false + } + + return true +} + private val listPattern = Regex("""(\s*(\w+)\s*(,\s*\w+\s*)*,?|\[?\s*(\w+)\s*(,\s*\w+\s*)*])?""") private val javaKeywords = setOf( "abstract", diff --git a/src/main/kotlin/com/demonwav/mcdev/facet/MinecraftFacetEditorTab.form b/src/main/kotlin/com/demonwav/mcdev/facet/MinecraftFacetEditorTab.form index 536609e28..3ab91be2f 100644 --- a/src/main/kotlin/com/demonwav/mcdev/facet/MinecraftFacetEditorTab.form +++ b/src/main/kotlin/com/demonwav/mcdev/facet/MinecraftFacetEditorTab.form @@ -1,6 +1,6 @@
- + @@ -23,7 +23,7 @@ - + @@ -73,7 +73,7 @@ - + @@ -82,7 +82,7 @@ - + @@ -91,7 +91,7 @@ - + @@ -100,7 +100,7 @@ - + @@ -149,7 +149,7 @@ - + @@ -157,7 +157,7 @@ - + @@ -165,7 +165,7 @@ - + @@ -173,7 +173,7 @@ - + @@ -245,7 +245,7 @@ - + @@ -254,7 +254,7 @@ - + @@ -264,7 +264,7 @@ - + @@ -274,7 +274,7 @@ - + @@ -329,7 +329,7 @@ - + @@ -338,7 +338,7 @@ - + @@ -347,7 +347,7 @@ - + @@ -356,7 +356,7 @@ - + @@ -365,7 +365,7 @@ - + @@ -373,7 +373,7 @@ - + @@ -381,7 +381,7 @@ - + @@ -390,7 +390,7 @@ - + @@ -399,7 +399,7 @@ - + @@ -408,7 +408,7 @@ - + @@ -417,7 +417,7 @@ - + @@ -426,13 +426,46 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/kotlin/com/demonwav/mcdev/facet/MinecraftFacetEditorTab.kt b/src/main/kotlin/com/demonwav/mcdev/facet/MinecraftFacetEditorTab.kt index 5082bd487..582d1627d 100644 --- a/src/main/kotlin/com/demonwav/mcdev/facet/MinecraftFacetEditorTab.kt +++ b/src/main/kotlin/com/demonwav/mcdev/facet/MinecraftFacetEditorTab.kt @@ -33,6 +33,8 @@ class MinecraftFacetEditorTab(private val configuration: MinecraftFacetConfigura private lateinit var spongeAutoCheckBox: JCheckBox private lateinit var forgeEnabledCheckBox: JCheckBox private lateinit var forgeAutoCheckBox: JCheckBox + private lateinit var fabricEnabledCheckBox: JCheckBox + private lateinit var fabricAutoCheckBox: JCheckBox private lateinit var liteloaderEnabledCheckBox: JCheckBox private lateinit var liteloaderAutoCheckBox: JCheckBox private lateinit var mcpEnabledCheckBox: JCheckBox @@ -57,6 +59,7 @@ class MinecraftFacetEditorTab(private val configuration: MinecraftFacetConfigura paperEnabledCheckBox, spongeEnabledCheckBox, forgeEnabledCheckBox, + fabricEnabledCheckBox, liteloaderEnabledCheckBox, mcpEnabledCheckBox, mixinEnabledCheckBox, @@ -73,6 +76,7 @@ class MinecraftFacetEditorTab(private val configuration: MinecraftFacetConfigura paperAutoCheckBox, spongeAutoCheckBox, forgeAutoCheckBox, + fabricAutoCheckBox, liteloaderAutoCheckBox, mcpAutoCheckBox, mixinAutoCheckBox, @@ -135,6 +139,7 @@ class MinecraftFacetEditorTab(private val configuration: MinecraftFacetConfigura } forgeEnabledCheckBox.addActionListener { also(forgeEnabledCheckBox, mcpEnabledCheckBox) } + fabricEnabledCheckBox.addActionListener { also(fabricEnabledCheckBox, mixinEnabledCheckBox, mcpEnabledCheckBox) } liteloaderEnabledCheckBox.addActionListener { also(liteloaderEnabledCheckBox, mcpEnabledCheckBox) } mixinEnabledCheckBox.addActionListener { also(mixinEnabledCheckBox, mcpEnabledCheckBox) } @@ -255,7 +260,8 @@ class MinecraftFacetEditorTab(private val configuration: MinecraftFacetConfigura private const val PAPER = SPIGOT + 1 private const val SPONGE = PAPER + 1 private const val FORGE = SPONGE + 1 - private const val LITELOADER = FORGE + 1 + private const val FABRIC = FORGE + 1 + private const val LITELOADER = FABRIC + 1 private const val MCP = LITELOADER + 1 private const val MIXIN = MCP + 1 private const val BUNGEECORD = MIXIN + 1 @@ -268,6 +274,7 @@ class MinecraftFacetEditorTab(private val configuration: MinecraftFacetConfigura PlatformType.PAPER, PlatformType.SPONGE, PlatformType.FORGE, + PlatformType.FABRIC, PlatformType.LITELOADER, PlatformType.MCP, PlatformType.MIXIN, @@ -276,7 +283,19 @@ class MinecraftFacetEditorTab(private val configuration: MinecraftFacetConfigura PlatformType.VELOCITY ) - private val indexes = - intArrayOf(BUKKIT, SPIGOT, PAPER, SPONGE, FORGE, LITELOADER, MCP, MIXIN, BUNGEECORD, WATERFALL, VELOCITY) + private val indexes = intArrayOf( + BUKKIT, + SPIGOT, + PAPER, + SPONGE, + FORGE, + FABRIC, + LITELOADER, + MCP, + MIXIN, + BUNGEECORD, + WATERFALL, + VELOCITY + ) } } diff --git a/src/main/kotlin/com/demonwav/mcdev/facet/MinecraftLibraryKinds.kt b/src/main/kotlin/com/demonwav/mcdev/facet/MinecraftLibraryKinds.kt index 0b14e564a..0e097140f 100644 --- a/src/main/kotlin/com/demonwav/mcdev/facet/MinecraftLibraryKinds.kt +++ b/src/main/kotlin/com/demonwav/mcdev/facet/MinecraftLibraryKinds.kt @@ -15,6 +15,7 @@ import com.demonwav.mcdev.platform.bukkit.framework.PAPER_LIBRARY_KIND import com.demonwav.mcdev.platform.bukkit.framework.SPIGOT_LIBRARY_KIND import com.demonwav.mcdev.platform.bungeecord.framework.BUNGEECORD_LIBRARY_KIND import com.demonwav.mcdev.platform.bungeecord.framework.WATERFALL_LIBRARY_KIND +import com.demonwav.mcdev.platform.fabric.framework.FABRIC_LIBRARY_KIND import com.demonwav.mcdev.platform.forge.framework.FORGE_LIBRARY_KIND import com.demonwav.mcdev.platform.liteloader.framework.LITELOADER_LIBRARY_KIND import com.demonwav.mcdev.platform.mcp.framework.MCP_LIBRARY_KIND @@ -28,6 +29,7 @@ val MINECRAFT_LIBRARY_KINDS = setOf( PAPER_LIBRARY_KIND, SPONGE_LIBRARY_KIND, FORGE_LIBRARY_KIND, + FABRIC_LIBRARY_KIND, LITELOADER_LIBRARY_KIND, MCP_LIBRARY_KIND, MIXIN_LIBRARY_KIND, diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/PlatformType.kt b/src/main/kotlin/com/demonwav/mcdev/platform/PlatformType.kt index 8cafd1852..7a95ba312 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/PlatformType.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/PlatformType.kt @@ -20,6 +20,8 @@ import com.demonwav.mcdev.platform.bungeecord.BungeeCordModuleType import com.demonwav.mcdev.platform.bungeecord.WaterfallModuleType import com.demonwav.mcdev.platform.bungeecord.framework.BUNGEECORD_LIBRARY_KIND import com.demonwav.mcdev.platform.bungeecord.framework.WATERFALL_LIBRARY_KIND +import com.demonwav.mcdev.platform.fabric.FabricModuleType +import com.demonwav.mcdev.platform.fabric.framework.FABRIC_LIBRARY_KIND import com.demonwav.mcdev.platform.forge.ForgeModuleType import com.demonwav.mcdev.platform.forge.framework.FORGE_LIBRARY_KIND import com.demonwav.mcdev.platform.liteloader.LiteLoaderModuleType @@ -45,6 +47,7 @@ enum class PlatformType( SPIGOT(SpigotModuleType, "Spigot", "spigot.json", BUKKIT), PAPER(PaperModuleType, "Paper", "paper.json", SPIGOT), FORGE(ForgeModuleType, "Forge"), + FABRIC(FabricModuleType, "Fabric"), SPONGE(SpongeModuleType, "Sponge"), BUNGEECORD(BungeeCordModuleType, "BungeeCord", "bungeecord.json"), WATERFALL(WaterfallModuleType, "Waterfall", "waterfall.json", BUNGEECORD), @@ -74,6 +77,7 @@ enum class PlatformType( PAPER_LIBRARY_KIND -> PAPER SPONGE_LIBRARY_KIND -> SPONGE FORGE_LIBRARY_KIND -> FORGE + FABRIC_LIBRARY_KIND -> FABRIC LITELOADER_LIBRARY_KIND -> LITELOADER MCP_LIBRARY_KIND -> MCP MIXIN_LIBRARY_KIND -> MIXIN diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/EntryPoint.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/EntryPoint.kt new file mode 100644 index 000000000..8cea2bbc8 --- /dev/null +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/EntryPoint.kt @@ -0,0 +1,34 @@ +/* + * Minecraft Dev for IntelliJ + * + * https://minecraftdev.org + * + * Copyright (c) 2020 minecraft-dev + * + * MIT License + */ + +package com.demonwav.mcdev.platform.fabric + +import com.demonwav.mcdev.creator.isValidClassName + +data class EntryPoint( + val category: String, + val type: Type, + val className: String, + val interfaceName: String, + val methodName: String? = null +) { + val reference = when (type) { + Type.CLASS -> className + Type.METHOD -> "$className::$methodName" + } + + val valid by lazy { category.isNotBlank() && isValidClassName(className) && isValidClassName(interfaceName) } + + override fun toString() = "$category -> $reference implements $interfaceName" + + enum class Type { + CLASS, METHOD + } +} diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/FabricFileIconProvider.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/FabricFileIconProvider.kt new file mode 100644 index 000000000..58e7830b7 --- /dev/null +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/FabricFileIconProvider.kt @@ -0,0 +1,38 @@ +/* + * Minecraft Dev for IntelliJ + * + * https://minecraftdev.org + * + * Copyright (c) 2020 minecraft-dev + * + * MIT License + */ + +package com.demonwav.mcdev.platform.fabric + +import com.demonwav.mcdev.MinecraftSettings +import com.demonwav.mcdev.facet.MinecraftFacet +import com.intellij.ide.FileIconProvider +import com.intellij.openapi.module.ModuleUtilCore +import com.intellij.openapi.project.Project +import com.intellij.openapi.vfs.VirtualFile +import javax.swing.Icon + +class FabricFileIconProvider : FileIconProvider { + override fun getIcon(file: VirtualFile, flags: Int, project: Project?): Icon? { + project ?: return null + + if (!MinecraftSettings.instance.isShowProjectPlatformIcons) { + return null + } + + val module = ModuleUtilCore.findModuleForFile(file, project) ?: return null + val fabricModule = MinecraftFacet.getInstance(module, FabricModuleType) ?: return null + + if (file == fabricModule.fabricJson) { + return fabricModule.icon + } + + return null + } +} diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/FabricModule.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/FabricModule.kt new file mode 100644 index 000000000..cfecdc15b --- /dev/null +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/FabricModule.kt @@ -0,0 +1,54 @@ +/* + * Minecraft Dev for IntelliJ + * + * https://minecraftdev.org + * + * Copyright (c) 2020 minecraft-dev + * + * MIT License + */ + +package com.demonwav.mcdev.platform.fabric + +import com.demonwav.mcdev.asset.PlatformAssets +import com.demonwav.mcdev.facet.MinecraftFacet +import com.demonwav.mcdev.platform.AbstractModule +import com.demonwav.mcdev.platform.PlatformType +import com.demonwav.mcdev.platform.fabric.util.FabricConstants +import com.demonwav.mcdev.util.SourceType +import com.demonwav.mcdev.util.nullable +import com.intellij.psi.PsiClass +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiIdentifier +import com.intellij.psi.PsiMethod + +class FabricModule internal constructor(facet: MinecraftFacet) : AbstractModule(facet) { + + var fabricJson by nullable { facet.findFile(FabricConstants.FABRIC_MOD_JSON, SourceType.RESOURCE) } + private set + + override val moduleType = FabricModuleType + override val type = PlatformType.FABRIC + override val icon = PlatformAssets.FABRIC_ICON + + override fun isEventClassValid(eventClass: PsiClass, method: PsiMethod?) = true + + override fun writeErrorMessageForEventParameter(eventClass: PsiClass, method: PsiMethod) = "" + + override fun shouldShowPluginIcon(element: PsiElement?): Boolean { + if (element !is PsiIdentifier) { + return false + } + + val psiClass = (element.parent as? PsiClass) ?: return false + + // TODO: check the mod json, and support method entrypoints + val interfaces = psiClass.interfaces + return interfaces.any { it.qualifiedName == FabricConstants.MOD_INITIALIZER || it.qualifiedName == FabricConstants.CLIENT_MOD_INITIALIZER } + } + + override fun dispose() { + super.dispose() + fabricJson = null + } +} diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/FabricModuleType.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/FabricModuleType.kt new file mode 100644 index 000000000..e399713f1 --- /dev/null +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/FabricModuleType.kt @@ -0,0 +1,32 @@ +/* + * Minecraft Dev for IntelliJ + * + * https://minecraftdev.org + * + * Copyright (c) 2020 minecraft-dev + * + * MIT License + */ + +package com.demonwav.mcdev.platform.fabric + +import com.demonwav.mcdev.asset.PlatformAssets +import com.demonwav.mcdev.facet.MinecraftFacet +import com.demonwav.mcdev.platform.AbstractModuleType +import com.demonwav.mcdev.platform.PlatformType + +object FabricModuleType : AbstractModuleType("", "") { + + private const val ID = "FABRIC_MODULE_TYPE" + + val IGNORED_ANNOTATIONS = emptyList() + val LISTENER_ANNOTATIONS = emptyList() + + override val platformType = PlatformType.FABRIC + override val icon = PlatformAssets.FABRIC_ICON + override val id = ID + override val ignoredAnnotations = IGNORED_ANNOTATIONS + override val listenerAnnotations = LISTENER_ANNOTATIONS + + override fun generateModule(facet: MinecraftFacet) = FabricModule(facet) +} diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectConfig.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectConfig.kt new file mode 100644 index 000000000..6cd3a567d --- /dev/null +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectConfig.kt @@ -0,0 +1,65 @@ +/* + * Minecraft Dev for IntelliJ + * + * https://minecraftdev.org + * + * Copyright (c) 2020 minecraft-dev + * + * MIT License + */ + +package com.demonwav.mcdev.platform.fabric.creator + +import com.demonwav.mcdev.creator.ProjectConfig +import com.demonwav.mcdev.creator.ProjectCreator +import com.demonwav.mcdev.creator.buildsystem.BuildSystemType +import com.demonwav.mcdev.creator.buildsystem.gradle.GradleBuildSystem +import com.demonwav.mcdev.creator.buildsystem.gradle.GradleCreator +import com.demonwav.mcdev.platform.PlatformType +import com.demonwav.mcdev.platform.fabric.EntryPoint +import com.demonwav.mcdev.platform.forge.inspections.sideonly.Side +import com.demonwav.mcdev.util.License +import com.demonwav.mcdev.util.SemanticVersion +import com.intellij.openapi.module.Module +import java.nio.file.Path + +class FabricProjectConfig : ProjectConfig(), GradleCreator { + + var yarnVersion = SemanticVersion.release() + var yarnClassifier: String? = "v2" + // Minecraft does not follow semver in the snapshots + var mcVersion = "" + var semanticMcVersion = SemanticVersion.release() + var loaderVersion = SemanticVersion.release() + var apiVersion: SemanticVersion? = null + var apiMavenLocation: String? = null + var loomVersion = SemanticVersion.release() + var gradleVersion = SemanticVersion.release() + var environment = Side.NONE + var entryPoints: List = arrayListOf() + var modRepo: String? = null + var mixins = false + var genSources = true + var license: License? = null + + override var type = PlatformType.FABRIC + + override val preferredBuildSystem = BuildSystemType.GRADLE + + override fun buildGradleCreator( + rootDirectory: Path, + module: Module, + buildSystem: GradleBuildSystem + ): ProjectCreator { + return FabricProjectCreator( + rootDirectory, + module, + buildSystem, + this + ) + } + + override fun configureRootGradle(rootDirectory: Path, buildSystem: GradleBuildSystem) { + buildSystem.gradleVersion = gradleVersion + } +} diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt new file mode 100644 index 000000000..06baed855 --- /dev/null +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt @@ -0,0 +1,418 @@ +/* + * Minecraft Dev for IntelliJ + * + * https://minecraftdev.org + * + * Copyright (c) 2020 minecraft-dev + * + * MIT License + */ + +package com.demonwav.mcdev.platform.fabric.creator + +import com.demonwav.mcdev.creator.BaseProjectCreator +import com.demonwav.mcdev.creator.CreatorStep +import com.demonwav.mcdev.creator.buildsystem.BuildSystem +import com.demonwav.mcdev.creator.buildsystem.gradle.BasicGradleFinalizerStep +import com.demonwav.mcdev.creator.buildsystem.gradle.GradleBuildSystem +import com.demonwav.mcdev.creator.buildsystem.gradle.GradleFiles +import com.demonwav.mcdev.creator.buildsystem.gradle.GradleGitignoreStep +import com.demonwav.mcdev.creator.buildsystem.gradle.GradleWrapperStep +import com.demonwav.mcdev.platform.fabric.EntryPoint +import com.demonwav.mcdev.platform.fabric.util.FabricConstants +import com.demonwav.mcdev.platform.forge.creator.GradleSetupStep +import com.demonwav.mcdev.util.License +import com.demonwav.mcdev.util.addImplements +import com.demonwav.mcdev.util.addMethod +import com.demonwav.mcdev.util.invokeLater +import com.demonwav.mcdev.util.runGradleTask +import com.demonwav.mcdev.util.runWriteAction +import com.demonwav.mcdev.util.runWriteTask +import com.demonwav.mcdev.util.virtualFile +import com.intellij.codeInsight.CodeInsightBundle +import com.intellij.codeInsight.daemon.impl.quickfix.CreateFromUsageUtils +import com.intellij.codeInsight.generation.OverrideImplementUtil +import com.intellij.codeInsight.generation.PsiMethodMember +import com.intellij.codeInsight.intention.AddAnnotationFix +import com.intellij.ide.util.EditorHelper +import com.intellij.json.JsonLanguage +import com.intellij.json.psi.JsonArray +import com.intellij.json.psi.JsonElementGenerator +import com.intellij.json.psi.JsonFile +import com.intellij.json.psi.JsonObject +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.module.Module +import com.intellij.openapi.progress.ProgressIndicator +import com.intellij.openapi.project.Project +import com.intellij.openapi.ui.Messages +import com.intellij.openapi.util.text.StringUtil +import com.intellij.psi.JavaDirectoryService +import com.intellij.psi.JavaPsiFacade +import com.intellij.psi.PsiClass +import com.intellij.psi.PsiFileFactory +import com.intellij.psi.PsiManager +import com.intellij.psi.PsiMethod +import com.intellij.psi.PsiModifier +import com.intellij.psi.PsiModifierListOwner +import com.intellij.util.IncorrectOperationException +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.StandardOpenOption +import java.util.Locale + +class FabricProjectCreator( + private val rootDirectory: Path, + private val rootModule: Module, + private val buildSystem: GradleBuildSystem, + private val config: FabricProjectConfig +): BaseProjectCreator(rootModule, buildSystem) { + + override fun getSingleModuleSteps(): Iterable { + val buildText = FabricTemplate.applyBuildGradle(project, buildSystem, config) + val propText = FabricTemplate.applyGradleProp(project, buildSystem, config) + val settingsText = FabricTemplate.applySettingsGradle(project, buildSystem, config) + val files = GradleFiles(buildText, propText, settingsText) + + val steps = mutableListOf( + GradleSetupStep(project, rootDirectory, buildSystem, files), + GradleWrapperStep(project, rootDirectory, buildSystem) + ) + if (config.genSources) { + steps += GenSourcesStep(project, rootDirectory) + } + steps += GradleGitignoreStep(project, rootDirectory) + config.license?.let { + steps += LicenseStep(project, rootDirectory, it, config) + } + steps += BasicGradleFinalizerStep(rootModule, rootDirectory, buildSystem) + steps += FabricModJsonStep(project, buildSystem, config) + if (config.mixins) { + steps += MixinConfigStep(project, buildSystem) + } + for (entry in config.entryPoints.groupBy { it.className }.entries.sortedBy { it.key }) { + steps += CreateEntryPointStep(project, buildSystem, entry.key, entry.value) + } + return steps + } + + override fun getMultiModuleSteps(projectBaseDir: Path): Iterable { + TODO("Not yet implemented") + } + +} + +class GenSourcesStep( + private val project: Project, + private val rootDirectory: Path +) : CreatorStep { + + override fun runStep(indicator: ProgressIndicator) { + indicator.text = "Setting up project" + indicator.text2 = "Running Gradle task: 'genSources'" + runGradleTask(project, rootDirectory) { settings -> + settings.taskNames = listOf("genSources") + settings.vmOptions = "-Xmx1G" + } + indicator.text2 = null + } +} + +class LicenseStep( + private val project: Project, + private val rootDirectory: Path, + private val license: License, + private val config: FabricProjectConfig +) : CreatorStep { + + override fun runStep(indicator: ProgressIndicator) { + val licenseFile = rootDirectory.resolve("LICENSE") + + val fileText = FabricTemplate.applyLicenseTemplate(project, license, config) + + Files.write(licenseFile, fileText.toByteArray(Charsets.UTF_8), + StandardOpenOption.CREATE, + StandardOpenOption.WRITE, + StandardOpenOption.TRUNCATE_EXISTING + ) + } +} + +class FabricModJsonStep( + private val project: Project, + private val buildSystem: BuildSystem, + private val config: FabricProjectConfig +) : CreatorStep { + + override fun runStep(indicator: ProgressIndicator) { + val text = FabricTemplate.applyFabricModJsonTemplate(project, buildSystem, config) + val dir = buildSystem.dirsOrError.resourceDirectory + runWriteTask { + val file = PsiFileFactory.getInstance(project).createFileFromText(JsonLanguage.INSTANCE, text) + file.runWriteAction { + val jsonFile = file as JsonFile + val json = jsonFile.topLevelValue as? JsonObject ?: return@runWriteAction + val generator = JsonElementGenerator(project) + + (json.findProperty("authors")?.value as? JsonArray)?.let { authorsArray -> + for (i in config.authors.indices) { + if (i != 0) { + authorsArray.addBefore(generator.createComma(), authorsArray.lastChild) + } + authorsArray.addBefore(generator.createStringLiteral(config.authors[i]), authorsArray.lastChild) + } + } + + (json.findProperty("contact")?.value as? JsonObject)?.let { contactObject -> + val properties = mutableListOf>() + val website = config.website + if (!website.isNullOrBlank()) { + properties += "website" to website + } + val repo = config.modRepo + if (!repo.isNullOrBlank()) { + properties += "repo" to repo + } + for (i in properties.indices) { + if (i != 0) { + contactObject.addBefore(generator.createComma(), contactObject.lastChild) + } + val key = StringUtil.escapeStringCharacters(properties[i].first) + val value = "\"${StringUtil.escapeStringCharacters(properties[i].second)}\"" + contactObject.addBefore(generator.createProperty(key, value), contactObject.lastChild) + } + } + + (json.findProperty("entrypoints")?.value as? JsonObject)?.let { entryPointsObject -> + val entryPointsByCategory = config.entryPoints + .groupBy { it.category } + .asSequence() + .sortedBy { it.key } + .toList() + for (i in entryPointsByCategory.indices) { + val entryPointCategory = entryPointsByCategory[i] + if (i != 0) { + entryPointsObject.addBefore(generator.createComma(), entryPointsObject.lastChild) + } + val values = generator.createValue("[]") + for (j in entryPointCategory.value.indices) { + if (j != 0) { + values.addBefore(generator.createComma(), values.lastChild) + } + val value = generator.createStringLiteral(entryPointCategory.value[j].reference) + values.addBefore(value, values.lastChild) + } + val key = StringUtil.escapeStringCharacters(entryPointCategory.key) + val prop = generator.createProperty(key, "[]") + prop.value?.replace(values) + entryPointsObject.addBefore(prop, entryPointsObject.lastChild) + } + } + } + CreatorStep.writeTextToFile(project, dir, FabricConstants.FABRIC_MOD_JSON, file.text) + } + } +} + +class MixinConfigStep( + private val project: Project, + private val buildSystem: BuildSystem +) : CreatorStep { + override fun runStep(indicator: ProgressIndicator) { + val text = FabricTemplate.applyMixinConfigTemplate(project, buildSystem) + val dir = buildSystem.dirsOrError.resourceDirectory + runWriteTask { + CreatorStep.writeTextToFile(project, dir, "${buildSystem.artifactId}.mixins.json", text) + } + } +} + +class CreateEntryPointStep( + private val project: Project, + private val buildSystem: BuildSystem, + private val qualifiedClassName: String, + private val entryPoints: List +) : CreatorStep { + override fun runStep(indicator: ProgressIndicator) { + val dirs = buildSystem.dirsOrError + + runWriteTask { + val dotIndex = qualifiedClassName.lastIndexOf('.') + val packageName = if (dotIndex == -1) { + "" + } else { + qualifiedClassName.substring(0, dotIndex) + } + val className = qualifiedClassName.substring(dotIndex + 1) + + indicator.text = "Writing class: $className" + + var directory = dirs.sourceDirectory + for (part in packageName.split(".")) { + directory = directory.resolve(part) + } + if (Files.notExists(directory)) { + Files.createDirectories(directory) + } + + val clazz = try { + val psiDir = directory.virtualFile?.let { PsiManager.getInstance(project).findDirectory(it) } ?: return@runWriteTask + JavaDirectoryService.getInstance().createClass(psiDir, className) + } catch (e: IncorrectOperationException) { + invokeLater { + val message = "${CodeInsightBundle.message( + "intention.error.cannot.create.class.message", + className + )}\n${e.localizedMessage}" + Messages.showErrorDialog( + project, + message, + CodeInsightBundle.message("intention.error.cannot.create.class.title") + ) + } + return@runWriteTask + } + + val editor = EditorHelper.openInEditor(clazz) + + val clientEntryPoints = entryPoints.filter { it.category == "client" } + val serverEntryPoints = entryPoints.filter { it.category == "server" } + val otherEntryPoints = entryPoints.filter { it.category != "client" && it.category != "server" } + val entryPointsByInterface = entryPoints + .filter { it.type == EntryPoint.Type.CLASS } + .groupBy { it.interfaceName } + .entries + .sortedBy { it.key } + val entryPointsByMethodNameAndSig = entryPoints + .filter { it.type == EntryPoint.Type.METHOD } + .groupBy {entryPoint -> + val functionalMethod = findFunctionalMethod(clazz, entryPoint.interfaceName) ?: return@groupBy null + val paramTypes = functionalMethod.parameterList.parameters.map { it.type.canonicalText } + (entryPoint.methodName ?: functionalMethod.name) to paramTypes + } + .entries + .filter { it.key != null } + .map { it.key!! to it.value } + .sortedBy { it.first.first } + + val elementFactory = JavaPsiFacade.getElementFactory(project) + + var isClientClass = false + var isServerClass = false + if (clientEntryPoints.isNotEmpty()) { + if (serverEntryPoints.isEmpty() && otherEntryPoints.isEmpty()) { + addEnvironmentAnnotation(clazz, "CLIENT") + isClientClass = true + } else { + addSidedInterfaceEntryPoints(entryPointsByInterface, clazz, editor, "client") + } + } else if (serverEntryPoints.isNotEmpty()) { + if (clientEntryPoints.isEmpty() && otherEntryPoints.isEmpty()) { + addEnvironmentAnnotation(clazz, "SERVER") + isServerClass = true + } else { + addSidedInterfaceEntryPoints(entryPointsByInterface, clazz, editor, "server") + } + } + + for (eps in entryPointsByInterface) { + clazz.addImplements(eps.key) + } + implementAll(clazz, editor) + + for (eps in entryPointsByMethodNameAndSig) { + val functionalMethod = findFunctionalMethod(clazz, eps.second.first().interfaceName) ?: continue + val newMethod = clazz.addMethod(functionalMethod) ?: continue + val methodName = eps.first.first + newMethod.nameIdentifier?.replace(elementFactory.createIdentifier(methodName)) + newMethod.modifierList.setModifierProperty(PsiModifier.PUBLIC, true) + newMethod.modifierList.setModifierProperty(PsiModifier.STATIC, true) + newMethod.modifierList.setModifierProperty(PsiModifier.ABSTRACT, false) + CreateFromUsageUtils.setupMethodBody(newMethod) + if (!isClientClass && eps.second.all { it.category == "client" }) { + addEnvironmentAnnotation(newMethod, "CLIENT") + } else if (!isServerClass && eps.second.all { it.category == "server" }) { + addEnvironmentAnnotation(newMethod, "SERVER") + } + } + } + } + + private fun addSidedInterfaceEntryPoints( + entryPointsByInterface: List>>, + clazz: PsiClass, + editor: Editor, + side: String + ) { + val capsSide = side.toUpperCase(Locale.ROOT) + var needsInterfaceFix = false + for (eps in entryPointsByInterface) { + if (eps.value.all { it.category == side }) { + addEnvironmentInterfaceAnnotation(clazz, capsSide, eps.key) + clazz.addImplements(eps.key) + needsInterfaceFix = true + } + } + if (needsInterfaceFix) { + implementAll(clazz, editor) + for (method in clazz.methods) { + if (!method.hasAnnotation(FabricConstants.ENVIRONMENT_ANNOTATION)) { + addEnvironmentAnnotation(method, capsSide) + } + } + } + } + + private fun addEnvironmentAnnotation(owner: PsiModifierListOwner, envType: String) { + val elementFactory = JavaPsiFacade.getElementFactory(project) + val annotationText = + "@${FabricConstants.ENVIRONMENT_ANNOTATION}(${FabricConstants.ENV_TYPE}.$envType)" + val annotation = elementFactory.createAnnotationFromText(annotationText, owner) + AddAnnotationFix(FabricConstants.ENVIRONMENT_ANNOTATION, owner, annotation.parameterList.attributes) + .applyFix() + } + + private fun addEnvironmentInterfaceAnnotation( + owner: PsiModifierListOwner, + envType: String, + interfaceQualifiedName: String + ) { + val elementFactory = JavaPsiFacade.getElementFactory(project) + val annotationText = "@${FabricConstants.ENVIRONMENT_INTERFACE_ANNOTATION}(" + + "value=${FabricConstants.ENV_TYPE}.$envType," + + "itf=$interfaceQualifiedName.class" + + ")" + val annotation = elementFactory.createAnnotationFromText(annotationText, owner) + AddAnnotationFix(FabricConstants.ENVIRONMENT_INTERFACE_ANNOTATION, owner, annotation.parameterList.attributes) + .applyFix() + } + + private fun implementAll(clazz: PsiClass, editor: Editor) { + val methodsToImplement = OverrideImplementUtil.getMethodsToOverrideImplement(clazz, true) + .map { PsiMethodMember(it) } + OverrideImplementUtil.overrideOrImplementMethodsInRightPlace( + editor, + clazz, + methodsToImplement, + false, + true + ) + } + + private fun findFunctionalMethod(clazz: PsiClass, interfaceName: String): PsiMethod? { + val interfaceClass = JavaPsiFacade.getInstance(project) + .findClass(interfaceName, clazz.resolveScope) ?: return null + if (!interfaceClass.isInterface) { + return null + } + val functionalMethods = interfaceClass.allMethods + .filter { + !it.hasModifierProperty(PsiModifier.STATIC) + && !it.hasModifierProperty(PsiModifier.DEFAULT) + } + return if (functionalMethods.size != 1) { + null + } else { + functionalMethods[0] + } + } +} diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.form b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.form new file mode 100644 index 000000000..e9b0c7b94 --- /dev/null +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.form @@ -0,0 +1,385 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt new file mode 100644 index 000000000..114e30f87 --- /dev/null +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt @@ -0,0 +1,400 @@ +/* + * Minecraft Dev for IntelliJ + * + * https://minecraftdev.org + * + * Copyright (c) 2020 minecraft-dev + * + * MIT License + */ + +package com.demonwav.mcdev.platform.fabric.creator + +import com.demonwav.mcdev.asset.PlatformAssets +import com.demonwav.mcdev.creator.MinecraftModuleWizardStep +import com.demonwav.mcdev.creator.MinecraftProjectCreator +import com.demonwav.mcdev.creator.ValidatedField +import com.demonwav.mcdev.creator.ValidatedFieldType.LIST +import com.demonwav.mcdev.creator.ValidatedFieldType.NON_BLANK +import com.demonwav.mcdev.platform.PlatformType +import com.demonwav.mcdev.platform.fabric.EntryPoint +import com.demonwav.mcdev.platform.fabric.util.FabricConstants +import com.demonwav.mcdev.platform.forge.inspections.sideonly.Side +import com.demonwav.mcdev.util.License +import com.demonwav.mcdev.util.SemanticVersion +import com.demonwav.mcdev.util.firstOfType +import com.demonwav.mcdev.util.toPackageName +import com.extracraftx.minecraft.templatemakerfabric.data.DataProvider +import com.intellij.openapi.ui.ComboBox +import com.intellij.ui.CollectionComboBoxModel +import com.intellij.ui.ToolbarDecorator +import com.intellij.ui.table.JBTable +import com.intellij.util.ui.EditableModel +import kotlinx.coroutines.* +import kotlinx.coroutines.swing.Swing +import org.apache.commons.lang.WordUtils +import java.awt.event.ActionListener +import java.awt.event.ComponentAdapter +import java.awt.event.ComponentEvent +import java.io.IOException +import java.util.* +import javax.swing.* +import javax.swing.table.AbstractTableModel + +class FabricProjectSettingsWizard(private val creator: MinecraftProjectCreator) : MinecraftModuleWizardStep() { + + // Initialize ALL custom fields in createUIComponents, otherwise they are null until after that point! + @ValidatedField(NON_BLANK) + private lateinit var modNameField: JTextField + private lateinit var panel: JPanel + private lateinit var title: JLabel + private lateinit var descriptionField: JTextField + @ValidatedField(LIST) + private lateinit var authorsField: JTextField + private lateinit var websiteField: JTextField + private lateinit var repositoryField: JTextField + private lateinit var minecraftVersionBox: JComboBox + private lateinit var loaderVersionBox: JComboBox + private lateinit var yarnVersionBox: JComboBox + private lateinit var loomVersionBox: JComboBox + private lateinit var licenseBox: JComboBox + private lateinit var useFabricApiCheckbox: JCheckBox + private lateinit var fabricApiBox: JComboBox + private lateinit var environmentBox: JComboBox + private lateinit var mixinsCheckbox: JCheckBox + private lateinit var decompileMcCheckbox: JCheckBox + private lateinit var loadingBar: JProgressBar + private lateinit var minecraftVersionLabel: JLabel + private lateinit var entryPointsTable: JPanel + private lateinit var entryPoints : ArrayList + private lateinit var tableModel : EntryPointTableModel + private lateinit var yarnWarning: JLabel + private lateinit var errorLabel: JLabel + + private var config: FabricProjectConfig? = null + + private var dataProvider: DataProvider? = null + + private var currentJob: Job? = null + + private var initializedEntryPointsTable = false + + private val minecraftBoxActionListener: ActionListener = ActionListener { + yarnVersionBox.selectedItem = null + loaderVersionBox.selectedItem = null + loomVersionBox.selectedItem = null + fabricApiBox.selectedItem = null + updateForm() + } + + init { + yarnWarning.isVisible = false + } + + fun createUIComponents() { + entryPoints = arrayListOf() + + tableModel = EntryPointTableModel(entryPoints) + val entryPointsTable = JBTable(tableModel) + fun resizeColumns() { + val model = entryPointsTable.columnModel + val totalWidth = model.totalColumnWidth + model.getColumn(0).preferredWidth = (totalWidth * 0.1).toInt() + model.getColumn(1).preferredWidth = (totalWidth * 0.1).toInt() + model.getColumn(2).preferredWidth = (totalWidth * 0.3).toInt() + model.getColumn(3).preferredWidth = (totalWidth * 0.3).toInt() + model.getColumn(4).preferredWidth = (totalWidth * 0.2).toInt() + } + resizeColumns() + entryPointsTable.addComponentListener(object : ComponentAdapter() { + override fun componentResized(e: ComponentEvent?) { + resizeColumns() + } + }) + this.entryPointsTable = ToolbarDecorator.createDecorator(entryPointsTable).createPanel() + + licenseBox = ComboBox(CollectionComboBoxModel(enumValues().toList())) + licenseBox.selectedItem = License.MIT + } + + override fun getComponent(): JComponent { + return panel + } + + override fun updateStep() { + config = creator.configs.firstOfType() + + val buildSystem = creator.buildSystem ?: return + + modNameField.text = WordUtils.capitalize(buildSystem.artifactId.replace('-', ' ')) + + val conf = config ?: return + + if (creator.configs.indexOf(conf) != 0) { + modNameField.isEditable = false + } + + if (!initializedEntryPointsTable) { + val packageName = "${buildSystem.groupId.toPackageName()}.${buildSystem.artifactId.toPackageName()}" + var className = buildSystem.artifactId.replace('-', ' ').let { WordUtils.capitalize(it) }.replace(" ", "") + if (creator.configs.size > 1) + className += PlatformType.FABRIC.normalName + entryPoints.add(EntryPoint("main", EntryPoint.Type.CLASS, "$packageName.$className", FabricConstants.MOD_INITIALIZER)) + entryPoints.add(EntryPoint("client", EntryPoint.Type.CLASS,"$packageName.client.${className}Client", FabricConstants.CLIENT_MOD_INITIALIZER)) + tableModel.fireTableDataChanged() + entryPointsTable.revalidate() + initializedEntryPointsTable = true + } + + title.icon = PlatformAssets.FABRIC_ICON_2X + title.text = "Fabric Settings" + + minecraftVersionLabel.text = "Minecraft Version" + + if (dataProvider != null || currentJob?.isActive == true) { + return + } + currentJob = updateVersions() + } + + private val mcVersion: String? + get() = minecraftVersionBox.selectedItem as? String + + private val yarnVersion: String? + get() = yarnVersionBox.selectedItem as? String + + private val loomVersion: String? + get() = loomVersionBox.selectedItem as? String + + private val loaderVersion: String? + get() = loaderVersionBox.selectedItem as? String + + private val fabricApiVersion: String? + get() = fabricApiBox.selectedItem as? String + + override fun validate(): Boolean { + return super.validate() && !loadingBar.isVisible + } + + override fun isStepVisible(): Boolean { + return creator.configs.any { it is FabricProjectConfig } + } + + override fun onStepLeaving() { + currentJob?.cancel() + } + + fun error() { + errorLabel.isVisible = true + loadingBar.isIndeterminate = false + loadingBar.isVisible = false + } + + override fun updateDataModel() { + val conf = config ?: return + conf.pluginName = modNameField.text + conf.description = descriptionField.text + conf.website = websiteField.text + + conf.setAuthors(authorsField.text) + conf.modRepo = repositoryField.text + + conf.yarnVersion = yarnVersion?.let { SemanticVersion.parse(it) } ?: SemanticVersion.release() + conf.yarnClassifier = if (dataProvider?.yarnVersions?.firstOrNull { it.name == yarnVersion }?.hasV2Mappings == false) null else "v2" + conf.mcVersion = mcVersion ?: "" + conf.semanticMcVersion = dataProvider?.getNormalizedMinecraftVersion(mcVersion)?.normalized?.let { SemanticVersion.parse(it) } ?: SemanticVersion.release() + val loaderVer = loaderVersion + if (loaderVer != null) + conf.loaderVersion = SemanticVersion.parse(loaderVer) + val api = if (useFabricApiCheckbox.isSelected) dataProvider?.fabricApiVersions?.firstOrNull { it.name == fabricApiVersion } else null + conf.apiVersion = api?.mavenVersion?.let { SemanticVersion.parse(it) } + conf.apiMavenLocation = api?.mavenLocation + conf.gradleVersion = when (dataProvider?.loomVersions?.firstOrNull { it.name == loomVersion }?.gradle) { + 4 -> SemanticVersion.release(4, 10, 3) + else -> SemanticVersion.release(5, 5, 1) + } + val loomVer = loomVersion + if (loomVer != null) + conf.loomVersion = SemanticVersion.parse(loomVer) + conf.environment = when ((environmentBox.selectedItem as? String)?.toLowerCase(Locale.ROOT)) { + "client" -> Side.CLIENT + "server" -> Side.SERVER + else -> Side.NONE + } + conf.license = licenseBox.selectedItem as? License + conf.entryPoints = entryPoints.filter { it.valid } + conf.mixins = mixinsCheckbox.isSelected + conf.genSources = decompileMcCheckbox.isSelected + } + + private fun updateVersions() = CoroutineScope(Dispatchers.Swing).launch { + loadingBar.isIndeterminate = true + loadingBar.isVisible = true + + try { + dataProvider = downloadVersions() + updateForm() + } catch (e: Exception) { + error() + } + + loadingBar.isIndeterminate = false + loadingBar.isVisible = false + + currentJob = null + } + + private suspend fun downloadVersions(): DataProvider? = coroutineScope { + val dataProvider = DataProvider() + val minecraftVersionJob = async(Dispatchers.IO) { try { dataProvider.minecraftVersions } catch (e: IOException) { null } } + val fabricApiVersionJob = async(Dispatchers.IO) { try { dataProvider.fabricApiVersions } catch (e: IOException) { null } } + val yarnVersionJob = async(Dispatchers.IO) { try { dataProvider.yarnVersions } catch (e: IOException) { null } } + val loomVersionJob = async(Dispatchers.IO) { try { dataProvider.loomVersions } catch (e: IOException) { null } } + val loaderVersionJob = async(Dispatchers.IO) { try { dataProvider.loaderVersions } catch (e: IOException) { null } } + + minecraftVersionJob.await() ?: return@coroutineScope null + fabricApiVersionJob.await() ?: return@coroutineScope null + yarnVersionJob.await() ?: return@coroutineScope null + loomVersionJob.await() ?: return@coroutineScope null + loaderVersionJob.await() ?: return@coroutineScope null + + return@coroutineScope dataProvider + } + + private fun updateForm() { + val dp = dataProvider ?: return + + val mcVer = when { + mcVersion != null -> { + mcVersion ?: return + } + else -> { + dp.minecraftVersions.firstOrNull { it.stable }?.name + } + } + val mcVerObj = dp.minecraftVersions.firstOrNull { it.name == mcVer } + + val yarnVer = when { + yarnVersion != null -> { + yarnVersion ?: return + } + else -> { + mcVerObj?.let { mvo -> + dp.getFilteredYarnVersions(mvo).firstOrNull()?.name + } + } + } + val yarnVerObj = dp.yarnVersions.firstOrNull { it.name == yarnVer } + + val loomVer = when { + loomVersion != null -> { + loomVersion ?: return + } + else -> { + yarnVerObj?.let { dp.getDefaultLoomVersion(it) }?.name + } + } + val loomVerObj = dp.loomVersions.firstOrNull { it.name == loomVer } + + val loaderVer = when { + loaderVersion != null -> { + loaderVersion ?: return + } + else -> { + loomVerObj?.let { lvo -> + dp.getFilteredLoaderVersions(lvo).firstOrNull()?.name + } + } + } + + val fabricVer = when { + fabricApiVersion != null -> { + fabricApiVersion ?: return + } + else -> { + mcVerObj?.let { mvo -> + dp.getDefaultFabricApiVersion(mvo) + }?.let { dp.sortedFabricApiVersions[it] }?.name + } + } + + minecraftVersionBox.removeActionListener(minecraftBoxActionListener) + minecraftVersionBox.model = CollectionComboBoxModel(dp.minecraftVersions.map { it.name }) + minecraftVersionBox.selectedItem = mcVer + minecraftVersionBox.addActionListener(minecraftBoxActionListener) + yarnVersionBox.model = CollectionComboBoxModel(dp.yarnVersions.map { it.name }) + yarnVersionBox.selectedItem = yarnVer + loomVersionBox.model = CollectionComboBoxModel(dp.loomVersions.map { it.name }) + loomVersionBox.selectedItem = loomVer + loaderVersionBox.model = CollectionComboBoxModel(dp.loaderVersions.map { it.name }) + loaderVersionBox.selectedItem = loaderVer + fabricApiBox.model = CollectionComboBoxModel(dp.fabricApiVersions.map { it.name }) + fabricApiBox.selectedItem = fabricVer + useFabricApiCheckbox.isSelected = fabricVer != null + } + + class EntryPointTableModel(private val entryPoints: ArrayList) : AbstractTableModel(), EditableModel { + + override fun getColumnName(col: Int) = when (col) { + 0 -> "Category" + 1 -> "Type" + 2 -> "Class" + 3 -> "Interface" + else -> "Method Name" + } + + override fun getRowCount() = entryPoints.size + + override fun getColumnCount() = 5 + + override fun getValueAt(row: Int, col: Int) = when (col) { + 0 -> entryPoints[row].category + 1 -> entryPoints[row].type + 2 -> entryPoints[row].className + 3 -> entryPoints[row].interfaceName + else -> entryPoints[row].methodName + } + + override fun isCellEditable(row: Int, col: Int): Boolean { + return col != 4 || entryPoints.getOrNull(row)?.type == EntryPoint.Type.METHOD + } + + override fun setValueAt(value: Any?, row: Int, col: Int) { + when (col) { + 0 -> entryPoints[row] = entryPoints[row].copy(category = value.toString()) + 1 -> entryPoints[row] = entryPoints[row].copy(type = parseEntryPointType(value)) + 2 -> entryPoints[row] = entryPoints[row].copy(className = value.toString()) + 3 -> entryPoints[row] = entryPoints[row].copy(interfaceName = value.toString()) + 4 -> entryPoints[row] = entryPoints[row].copy(methodName = value.toString()) + } + fireTableCellUpdated(row, col) + } + + private fun parseEntryPointType(value: Any?): EntryPoint.Type { + return value as? EntryPoint.Type ?: EntryPoint.Type.values().firstOrNull { it.name.equals(value.toString(), ignoreCase = true) } ?: EntryPoint.Type.CLASS + } + + override fun removeRow(idx: Int) { + entryPoints.removeAt(idx) + } + + override fun exchangeRows(oldIndex: Int, newIndex: Int) { + Collections.swap(entryPoints, oldIndex, newIndex) + } + + override fun canExchangeRows(oldIndex: Int, newIndex: Int) = true + + override fun addRow() { + entryPoints.add(EntryPoint("", EntryPoint.Type.CLASS, "", "", "")) + } + + override fun getColumnClass(col: Int): Class<*> { + return if (col == 1) { + EntryPoint.Type::class.java + } else { + String::class.java + } + } + } + +} diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricTemplate.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricTemplate.kt new file mode 100644 index 000000000..e9f9e24be --- /dev/null +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricTemplate.kt @@ -0,0 +1,129 @@ +/* + * Minecraft Dev for IntelliJ + * + * https://minecraftdev.org + * + * Copyright (c) 2020 minecraft-dev + * + * MIT License + */ + +package com.demonwav.mcdev.platform.fabric.creator + +import com.demonwav.mcdev.creator.buildsystem.BuildSystem +import com.demonwav.mcdev.platform.BaseTemplate +import com.demonwav.mcdev.platform.forge.inspections.sideonly.Side +import com.demonwav.mcdev.util.License +import com.demonwav.mcdev.util.MinecraftTemplates.Companion.FABRIC_BUILD_GRADLE_TEMPLATE +import com.demonwav.mcdev.util.MinecraftTemplates.Companion.FABRIC_GRADLE_PROPERTIES_TEMPLATE +import com.demonwav.mcdev.util.MinecraftTemplates.Companion.FABRIC_MIXINS_JSON_TEMPLATE +import com.demonwav.mcdev.util.MinecraftTemplates.Companion.FABRIC_MOD_JSON_TEMPLATE +import com.demonwav.mcdev.util.MinecraftTemplates.Companion.FABRIC_SETTINGS_GRADLE_TEMPLATE +import com.demonwav.mcdev.util.toPackageName +import com.intellij.openapi.project.Project +import java.time.ZonedDateTime + +object FabricTemplate : BaseTemplate() { + + private fun Project.applyGradleTemplate( + templateName: String, + buildSystem: BuildSystem, + config: FabricProjectConfig + ): String { + val props = mutableMapOf( + "GROUP_ID" to buildSystem.groupId, + "ARTIFACT_ID" to buildSystem.artifactId, + "VERSION" to buildSystem.version, + "MC_VERSION" to config.mcVersion, + "YARN_MAPPINGS" to config.yarnVersion.toString(), + "LOADER_VERSION" to config.loaderVersion.toString(), + "LOOM_VERSION" to config.loomVersion.toString() + ) + config.yarnClassifier?.let { + props["YARN_CLASSIFIER"] = it + } + config.apiVersion?.let { + props["API_VERSION"] = it.toString() + } + config.apiMavenLocation?.let { + props["API_MAVEN_LOCATION"] = it + } + + return applyTemplate(templateName, props) + } + + fun applyBuildGradle( + project: Project, + buildSystem: BuildSystem, + config: FabricProjectConfig + ): String { + return project.applyGradleTemplate(FABRIC_BUILD_GRADLE_TEMPLATE, buildSystem, config) + } + + fun applySettingsGradle( + project: Project, + buildSystem: BuildSystem, + config: FabricProjectConfig + ): String { + return project.applyGradleTemplate(FABRIC_SETTINGS_GRADLE_TEMPLATE, buildSystem, config) + } + + fun applyGradleProp( + project: Project, + buildSystem: BuildSystem, + config: FabricProjectConfig + ): String { + return project.applyGradleTemplate(FABRIC_GRADLE_PROPERTIES_TEMPLATE, buildSystem, config) + } + + fun applyLicenseTemplate( + project: Project, + license: License, + config: FabricProjectConfig + ): String { + val props = mapOf( + "YEAR" to ZonedDateTime.now().year.toString(), + "AUTHOR" to config.authors.joinToString(", ") + ) + return project.applyTemplate(license.id, props) + } + + fun applyFabricModJsonTemplate( + project: Project, + buildSystem: BuildSystem, + config: FabricProjectConfig + ): String { + val props = mutableMapOf( + "ARTIFACT_ID" to buildSystem.artifactId, + "MOD_NAME" to config.pluginName, + "MOD_DESCRIPTION" to (config.description ?: ""), + "MOD_ENVIRONMENT" to when (config.environment) { + Side.CLIENT -> "client" + Side.SERVER -> "server" + else -> "*" + }, + "LOADER_VERSION" to config.loaderVersion.toString(), + "MC_VERSION" to config.semanticMcVersion.toString(), + "LICENSE" to ((config.license ?: License.ALL_RIGHTS_RESERVED).id) + ) + config.apiVersion?.let { + props["API_VERSION"] = it.toString() + } + if (config.mixins) { + props["MIXINS"] = "true" + } + + return project.applyTemplate(FABRIC_MOD_JSON_TEMPLATE, props) + } + + fun applyMixinConfigTemplate( + project: Project, + buildSystem: BuildSystem + ): String { + val packageName = "${buildSystem.groupId.toPackageName()}.${buildSystem.artifactId.toPackageName()}.mixin" + val props = mapOf( + "PACKAGE_NAME" to packageName + ) + return project.applyTemplate(FABRIC_MIXINS_JSON_TEMPLATE, props) + } +} diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/framework/FabricLibraryKind.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/framework/FabricLibraryKind.kt new file mode 100644 index 000000000..75483ce22 --- /dev/null +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/framework/FabricLibraryKind.kt @@ -0,0 +1,15 @@ +/* + * Minecraft Dev for IntelliJ + * + * https://minecraftdev.org + * + * Copyright (c) 2020 minecraft-dev + * + * MIT License + */ + +package com.demonwav.mcdev.platform.fabric.framework + +import com.intellij.openapi.roots.libraries.LibraryKind + +val FABRIC_LIBRARY_KIND: LibraryKind = LibraryKind.create("fabric-library") diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/framework/FabricPresentationProvider.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/framework/FabricPresentationProvider.kt new file mode 100644 index 000000000..defe50325 --- /dev/null +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/framework/FabricPresentationProvider.kt @@ -0,0 +1,39 @@ +/* + * Minecraft Dev for IntelliJ + * + * https://minecraftdev.org + * + * Copyright (c) 2020 minecraft-dev + * + * MIT License + */ + +package com.demonwav.mcdev.platform.fabric.framework + +import com.demonwav.mcdev.asset.PlatformAssets +import com.demonwav.mcdev.util.localFile +import com.intellij.framework.library.LibraryVersionProperties +import com.intellij.openapi.roots.libraries.LibraryPresentationProvider +import com.intellij.openapi.vfs.VirtualFile +import java.util.jar.JarFile + +class FabricPresentationProvider : LibraryPresentationProvider(FABRIC_LIBRARY_KIND) { + + override fun getIcon(properties: LibraryVersionProperties?) = PlatformAssets.FABRIC_ICON + + override fun detect(classesRoots: MutableList): LibraryVersionProperties? { + for (classesRoot in classesRoots) { + if (classesRoot.name.endsWith(".jar")) { + JarFile(classesRoot.localFile).runCatching { + val isFabricLib = entries().asSequence().any { + it.name.startsWith("net/fabricmc/") && it.name.endsWith(".class") + } + if (isFabricLib) { + return LibraryVersionProperties() + } + } + } + } + return null + } +} diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/util/FabricConstants.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/util/FabricConstants.kt new file mode 100644 index 000000000..871cf879f --- /dev/null +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/util/FabricConstants.kt @@ -0,0 +1,22 @@ +/* + * Minecraft Dev for IntelliJ + * + * https://minecraftdev.org + * + * Copyright (c) 2020 minecraft-dev + * + * MIT License + */ + +package com.demonwav.mcdev.platform.fabric.util + +object FabricConstants { + + const val FABRIC_MOD_JSON = "fabric.mod.json" + + const val MOD_INITIALIZER = "net.fabricmc.api.ModInitializer" + const val CLIENT_MOD_INITIALIZER = "net.fabricmc.api.ClientModInitializer" + const val ENVIRONMENT_ANNOTATION = "net.fabricmc.api.Environment" + const val ENV_TYPE = "net.fabricmc.api.EnvType" + const val ENVIRONMENT_INTERFACE_ANNOTATION = "net.fabricmc.api.EnvironmentInterface" +} diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/forge/creator/ForgeProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/platform/forge/creator/ForgeProjectCreator.kt index 3fb506d6c..29bf84906 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/forge/creator/ForgeProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/forge/creator/ForgeProjectCreator.kt @@ -56,7 +56,7 @@ class Fg2ProjectCreator( val files = GradleFiles(buildText, propText, settingsText) return listOf( - FgSetupStep(project, rootDirectory, buildSystem, files), + GradleSetupStep(project, rootDirectory, buildSystem, files), setupMainClassStep(), GradleWrapperStep(project, rootDirectory, buildSystem), McmodInfoStep(project, buildSystem, config), @@ -73,7 +73,7 @@ class Fg2ProjectCreator( val files = GradleFiles(buildText, propText, null) return listOf( - FgSetupStep(project, rootDirectory, buildSystem, files), + GradleSetupStep(project, rootDirectory, buildSystem, files), setupMainClassStep(), McmodInfoStep(project, buildSystem, config), SetupDecompWorkspaceStep(project, rootDirectory), @@ -116,7 +116,7 @@ open class Fg3ProjectCreator( val files = createGradleFiles(hasData = true) return listOf( - FgSetupStep(project, rootDirectory, buildSystem, files), + GradleSetupStep(project, rootDirectory, buildSystem, files), setupMainClassStep(), GradleWrapperStep(project, rootDirectory, buildSystem), Fg3ProjectFilesStep(project, buildSystem, config), @@ -133,7 +133,7 @@ open class Fg3ProjectCreator( val files = GradleFiles(buildText, null, null) return listOf( - FgSetupStep(project, rootDirectory, buildSystem, files), + GradleSetupStep(project, rootDirectory, buildSystem, files), setupMainClassStep(), Fg3ProjectFilesStep(project, buildSystem, config), Fg3CompileJavaStep(project, rootDirectory), @@ -159,7 +159,7 @@ class Fg3Mc112ProjectCreator( val files = createGradleFiles(hasData = false) return listOf( - FgSetupStep(project, rootDirectory, buildSystem, files), + GradleSetupStep(project, rootDirectory, buildSystem, files), setupMainClassStep(), GradleWrapperStep(project, rootDirectory, buildSystem), McmodInfoStep(project, buildSystem, config), @@ -176,7 +176,7 @@ class Fg3Mc112ProjectCreator( val files = GradleFiles(buildText, null, null) return listOf( - FgSetupStep(project, rootDirectory, buildSystem, files), + GradleSetupStep(project, rootDirectory, buildSystem, files), setupMainClassStep(), McmodInfoStep(project, buildSystem, config), Fg3CompileJavaStep(project, rootDirectory), @@ -201,7 +201,7 @@ class SetupDecompWorkspaceStep( } } -class FgSetupStep( +class GradleSetupStep( private val project: Project, private val rootDirectory: Path, private val buildSystem: BuildSystem, diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/liteloader/creator/LiteLoaderProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/platform/liteloader/creator/LiteLoaderProjectCreator.kt index 7d409f0e9..53ddeac17 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/liteloader/creator/LiteLoaderProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/liteloader/creator/LiteLoaderProjectCreator.kt @@ -18,7 +18,7 @@ import com.demonwav.mcdev.creator.buildsystem.gradle.GradleBuildSystem import com.demonwav.mcdev.creator.buildsystem.gradle.GradleFiles import com.demonwav.mcdev.creator.buildsystem.gradle.GradleGitignoreStep import com.demonwav.mcdev.creator.buildsystem.gradle.GradleWrapperStep -import com.demonwav.mcdev.platform.forge.creator.FgSetupStep +import com.demonwav.mcdev.platform.forge.creator.GradleSetupStep import com.demonwav.mcdev.platform.forge.creator.SetupDecompWorkspaceStep import com.intellij.openapi.module.Module import java.nio.file.Path @@ -44,7 +44,7 @@ class LiteLoaderProjectCreator( val files = GradleFiles(buildText, propText, settingsText) return listOf( - FgSetupStep(project, rootDirectory, buildSystem, files), + GradleSetupStep(project, rootDirectory, buildSystem, files), setupMainClassStep(), GradleWrapperStep(project, rootDirectory, buildSystem), SetupDecompWorkspaceStep(project, rootDirectory), @@ -59,7 +59,7 @@ class LiteLoaderProjectCreator( val files = GradleFiles(buildText, propText, null) return listOf( - FgSetupStep(project, rootDirectory, buildSystem, files), + GradleSetupStep(project, rootDirectory, buildSystem, files), setupMainClassStep(), SetupDecompWorkspaceStep(project, rootDirectory) ) diff --git a/src/main/kotlin/com/demonwav/mcdev/util/License.kt b/src/main/kotlin/com/demonwav/mcdev/util/License.kt new file mode 100644 index 000000000..7d12dee0c --- /dev/null +++ b/src/main/kotlin/com/demonwav/mcdev/util/License.kt @@ -0,0 +1,28 @@ +/* + * Minecraft Dev for IntelliJ + * + * https://minecraftdev.org + * + * Copyright (c) 2020 minecraft-dev + * + * MIT License + */ + +package com.demonwav.mcdev.util + +enum class License(private val displayName: String, val id: String) { + MIT("MIT", "MIT"), + ALL_RIGHTS_RESERVED("All Rights Reserved", "All-Rights-Reserved"), + ISC("Internet Systems Consortium (ISC) License", "ISC"), + BSD_2("BSD 2-Clause (FreeBSD) License", "BSD-2-Clause-FreeBSD"), + BSD_3("BSD 3-Clause (NewBSD) License", "BSD-3-Clause"), + APACHE_2("Apache 2.0", "Apache-2.0"), + MPL_2("Mozilla Public License 2.0", "MPL-2.0"), + LGPL_3("GNU LGPL 3.0", "LGPL-3.0"), + GPL_3("GNU GPL 3.0", "GPL-3.0"), + AGPL_3("GNU AGPL 3.0", "AGPL-3.0"), + UNLICENSE("Unlicense", "unlicense"), + ; + + override fun toString() = displayName +} diff --git a/src/main/kotlin/com/demonwav/mcdev/util/MinecraftTemplates.kt b/src/main/kotlin/com/demonwav/mcdev/util/MinecraftTemplates.kt index 17555d0fd..2f5920786 100644 --- a/src/main/kotlin/com/demonwav/mcdev/util/MinecraftTemplates.kt +++ b/src/main/kotlin/com/demonwav/mcdev/util/MinecraftTemplates.kt @@ -83,6 +83,15 @@ class MinecraftTemplates : FileTemplateGroupDescriptorFactory { forgeGroup.addTemplate(FileTemplateDescriptor(PACK_MCMETA_TEMPLATE)) } + FileTemplateGroupDescriptor("Fabric", PlatformAssets.FABRIC_ICON).let { fabricGroup -> + group.addTemplate(fabricGroup) + fabricGroup.addTemplate(FileTemplateDescriptor(FABRIC_BUILD_GRADLE_TEMPLATE, PlatformAssets.FABRIC_ICON)) + fabricGroup.addTemplate(FileTemplateDescriptor(FABRIC_GRADLE_PROPERTIES_TEMPLATE, PlatformAssets.FABRIC_ICON)) + fabricGroup.addTemplate(FileTemplateDescriptor(FABRIC_MIXINS_JSON_TEMPLATE, PlatformAssets.FABRIC_ICON)) + fabricGroup.addTemplate(FileTemplateDescriptor(FABRIC_MOD_JSON_TEMPLATE, PlatformAssets.FABRIC_ICON)) + fabricGroup.addTemplate(FileTemplateDescriptor(FABRIC_SETTINGS_GRADLE_TEMPLATE, PlatformAssets.FABRIC_ICON)) + } + FileTemplateGroupDescriptor("LiteLoader", PlatformAssets.LITELOADER_ICON).let { liteGroup -> group.addTemplate(liteGroup) liteGroup.addTemplate(FileTemplateDescriptor(LITELOADER_MAIN_CLASS_TEMPLATE)) @@ -112,6 +121,13 @@ class MinecraftTemplates : FileTemplateGroupDescriptorFactory { commonGroup.addTemplate(FileTemplateDescriptor(MAVEN_GITIGNORE_TEMPLATE)) } + FileTemplateGroupDescriptor("Licenses", null).let { licenseGroup -> + group.addTemplate(licenseGroup) + enumValues().forEach { license -> + licenseGroup.addTemplate(FileTemplateDescriptor(license.id)) + } + } + return group } @@ -164,6 +180,12 @@ class MinecraftTemplates : FileTemplateGroupDescriptorFactory { const val MODS_TOML_TEMPLATE = "mods.toml" const val PACK_MCMETA_TEMPLATE = "pack.mcmeta" + const val FABRIC_BUILD_GRADLE_TEMPLATE = "fabric_build.gradle" + const val FABRIC_GRADLE_PROPERTIES_TEMPLATE = "fabric_gradle.properties" + const val FABRIC_MIXINS_JSON_TEMPLATE = "fabric_mixins.json" + const val FABRIC_MOD_JSON_TEMPLATE = "fabric_mod.json" + const val FABRIC_SETTINGS_GRADLE_TEMPLATE = "fabric_settings.gradle" + const val LITELOADER_MAIN_CLASS_TEMPLATE = "LiteLoader Main Class.java" const val LITELOADER_BUILD_GRADLE_TEMPLATE = "LiteLoader build.gradle" const val LITELOADER_SUBMODULE_BUILD_GRADLE_TEMPLATE = "LiteLoader Submodule build.gradle" diff --git a/src/main/kotlin/com/demonwav/mcdev/util/SemanticVersion.kt b/src/main/kotlin/com/demonwav/mcdev/util/SemanticVersion.kt index 42e512ba6..bb904e1dc 100644 --- a/src/main/kotlin/com/demonwav/mcdev/util/SemanticVersion.kt +++ b/src/main/kotlin/com/demonwav/mcdev/util/SemanticVersion.kt @@ -18,8 +18,21 @@ import com.demonwav.mcdev.util.SemanticVersion.Companion.VersionPart.TextPart * Each constituent part (delimited by periods in a version string) contributes * to the version ranking with decreasing priority from left to right. */ -class SemanticVersion(private val parts: List) : Comparable { - private val versionString = parts.joinToString(".") { it.versionString } +class SemanticVersion( + private val parts: List, + private val buildMetadata: String = "" +) : Comparable { + + private fun createVersionString(): String { + val mainPart = parts.joinToString(".") { it.versionString } + return if (buildMetadata.isBlank()) { + mainPart + } else { + "$mainPart+$buildMetadata" + } + } + + private val versionString = createVersionString() override fun compareTo(other: SemanticVersion): Int = naturalOrder().lexicographical().compare(parts, other.parts) @@ -101,7 +114,11 @@ class SemanticVersion(private val parts: List) : Comparable + val mainPartAndMetadata = value.split("+", limit = 2) + val mainPart = mainPartAndMetadata[0] + val metadata = mainPartAndMetadata.getOrNull(1) ?: "" + + val parts = mainPart.split('.').map { part -> val separator = SEPARATORS.find { it in part } if (separator != null) { parseTextPart(part.split(separator, limit = 2), separator) @@ -115,7 +132,7 @@ class SemanticVersion(private val parts: List) : Comparable { diff --git a/src/main/kotlin/com/demonwav/mcdev/util/class-utils.kt b/src/main/kotlin/com/demonwav/mcdev/util/class-utils.kt index 30d5bbccf..7e364cf8b 100644 --- a/src/main/kotlin/com/demonwav/mcdev/util/class-utils.kt +++ b/src/main/kotlin/com/demonwav/mcdev/util/class-utils.kt @@ -10,7 +10,9 @@ package com.demonwav.mcdev.util +import com.intellij.codeInsight.daemon.impl.quickfix.AddMethodFix import com.intellij.navigation.AnonymousElementProvider +import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project import com.intellij.psi.CommonClassNames import com.intellij.psi.JavaPsiFacade @@ -18,6 +20,7 @@ import com.intellij.psi.PsiClass import com.intellij.psi.PsiClassType import com.intellij.psi.PsiElement import com.intellij.psi.PsiField +import com.intellij.psi.PsiFile import com.intellij.psi.PsiInvalidElementAccessException import com.intellij.psi.PsiJavaFile import com.intellij.psi.PsiMethod @@ -183,6 +186,10 @@ fun PsiClass.extendsOrImplements(qualifiedClassName: String): Boolean { } fun PsiClass.addImplements(qualifiedClassName: String) { + if (interfaces.any { it.qualifiedName == qualifiedClassName }) { + return + } + val project = project val listenerClass = JavaPsiFacade.getInstance(project).findClass(qualifiedClassName, resolveScope) ?: return @@ -199,6 +206,20 @@ fun PsiClass.addImplements(qualifiedClassName: String) { // Member +/** + * Adds the given method to this class, or its copy. Returns the method actually added + */ +fun PsiClass.addMethod(template: PsiMethod): PsiMethod? { + var theNewMethod: PsiMethod? = null + object : AddMethodFix(template, this) { + override fun postAddAction(file: PsiFile, editor: Editor?, newMethod: PsiMethod?) { + theNewMethod = newMethod + super.postAddAction(file, editor, newMethod) + } + }.applyFix() + return theNewMethod +} + fun PsiClass.findMatchingMethod( pattern: PsiMethod, checkBases: Boolean, diff --git a/src/main/kotlin/com/demonwav/mcdev/util/utils.kt b/src/main/kotlin/com/demonwav/mcdev/util/utils.kt index 08b32d30c..098fded58 100644 --- a/src/main/kotlin/com/demonwav/mcdev/util/utils.kt +++ b/src/main/kotlin/com/demonwav/mcdev/util/utils.kt @@ -25,6 +25,7 @@ import com.intellij.openapi.util.Computable import com.intellij.openapi.util.Ref import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiFile +import java.util.Locale inline fun runWriteTask(crossinline func: () -> T): T { return invokeAndWait { @@ -118,7 +119,7 @@ fun Module.findChildren(): Set { } val path = manager.getModuleGroupPath(m) ?: continue - val namedModule = manager.findModuleByName(path.last()) ?: continue + val namedModule = path.last()?.let { manager.findModuleByName(it) } ?: continue if (namedModule != this) { continue @@ -168,6 +169,30 @@ fun String.getSimilarity(text: String, bonus: Int = 0): Int { return distance + bonus } +fun String.toPackageName(): String { + if (this.isEmpty()) { + return "_" + } + + val firstChar = this.first().let { + if (it.isJavaIdentifierStart()) { + "$it" + } else { + "" + } + } + val packageName = firstChar + this.asSequence() + .drop(1) + .filter { it.isJavaIdentifierPart() || it == '.' } + .joinToString("") + + return if (packageName.isEmpty()) { + "_" + } else { + packageName.toLowerCase(Locale.ROOT) + } +} + inline fun Iterable<*>.firstOfType(): T? { return this.firstOrNull { it is T } as? T } diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index fbad5f768..5595c4172 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -190,6 +190,11 @@ + + + + + diff --git a/src/main/resources/assets/icons/platform/Fabric.png b/src/main/resources/assets/icons/platform/Fabric.png new file mode 100644 index 0000000000000000000000000000000000000000..d11d4e4df2eb06570b59f51c23349a4c90d7925b GIT binary patch literal 394 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPVo0NbE!{OYcUO*w)%#er@=ltB<)VvZPmw~~#C^fMp zHASI3vm`^o-P1Q9MK6^dDE`jV#WBRKDYhx+_r_T7kGoh_r_E5SX)}0uX-`3wbn}c3hQq7PGgj82st)=Sg@mcTeLc9+yBhB{2qu XK#QrZZMqp{pdj&d^>bP0l+XkK_e_!# literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/icons/platform/Fabric@2x.png b/src/main/resources/assets/icons/platform/Fabric@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..c235eefbbf31c5cdd51f103dde9376109e5edda0 GIT binary patch literal 449 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzwj^(N7l!{JxM1({$v_d#0*}aI z1_o|n5N2eUHAey{$X?><>&pIwO-evSOX3>O9H5YFW=KSdbAE1aYF-JD%fR4Vl$uzQ znxasiS(2gP?&%wlqL<3fz`&^L>Eaj?aX2|af;EKc+OuE(*Pi|QfAXsS%muRNJb33D z8yFbq%(-{$01ybwk30&Z3%)#YJ*Ftgq;tjS#nsvTJQ<1~=g*iRu`81y{7$*~bVHyP zgN{xPfvIY3aU2I~`rZXgD443W`Ee{bZdvt8T|{W<)>w^C8zxBnQEWKyoGJLKq%+m_vHJHB$ zXk^EMM|Bsjvszp}Fxz~+qy!M?#WsKVx<%yUv7gQE_dP%Te89`7GW~ygLPA1EKhFVa zp(V$DURceWxRXgtNJ(iC4+zxQ$cX%`d9j7FaB1hglhP|5H7vZXbV$g_*_g$Rk)a}~ V?dX!(^0J_i^mO%eS?83{1OWQhrOE&R literal 0 HcmV?d00001 diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_build.gradle.ft b/src/main/resources/fileTemplates/j2ee/fabric/fabric_build.gradle.ft new file mode 100644 index 000000000..9a3a92d9d --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_build.gradle.ft @@ -0,0 +1,79 @@ +plugins { + id 'fabric-loom' version '${LOOM_VERSION}' + id 'maven-publish' +} + +sourceCompatibility = JavaVersion.VERSION_1_8 +targetCompatibility = JavaVersion.VERSION_1_8 + +archivesBaseName = project.archives_base_name +version = project.mod_version +group = project.maven_group + +dependencies { + //to change the versions see the gradle.properties file + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + + #if (${API_VERSION}) + // Fabric API. This is technically optional, but you probably want it anyway. + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + #end + + // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. + // You may need to force-disable transitiveness on them. +} + +processResources { + inputs.property "version", project.version + + from(sourceSets.main.resources.srcDirs) { + include "fabric.mod.json" + expand "version": project.version + } + + from(sourceSets.main.resources.srcDirs) { + exclude "fabric.mod.json" + } +} + +// ensure that the encoding is set to UTF-8, no matter what the system default is +// this fixes some edge cases with special characters not displaying correctly +// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html +tasks.withType(JavaCompile) { + options.encoding = "UTF-8" +} + +// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task +// if it is present. +// If you remove this task, sources will not be generated. +task sourcesJar(type: Jar, dependsOn: classes) { + classifier = "sources" + from sourceSets.main.allSource +} + +jar { + from "LICENSE" +} + +// configure the maven publication +publishing { + publications { + mavenJava(MavenPublication) { + // add all the jars that should be included when publishing to maven + artifact(remapJar) { + builtBy remapJar + } + artifact(sourcesJar) { + builtBy remapSourcesJar + } + } + } + + // select the repositories you want to publish to + repositories { + // uncomment to publish to the local maven + // mavenLocal() + } +} diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_build.gradle.html b/src/main/resources/fileTemplates/j2ee/fabric/fabric_build.gradle.html new file mode 100644 index 000000000..c30a35880 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_build.gradle.html @@ -0,0 +1,15 @@ + + + + +

This is a built-in file template used to create a new build.gradle file for Fabric projects.

+ + diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_gradle.properties.ft b/src/main/resources/fileTemplates/j2ee/fabric/fabric_gradle.properties.ft new file mode 100644 index 000000000..ae1e1d62e --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_gradle.properties.ft @@ -0,0 +1,19 @@ +# Done to increase the memory available to gradle. +org.gradle.jvmargs=-Xmx1G + +# Fabric Properties + # check these on https://modmuss50.me/fabric.html + minecraft_version=${MC_VERSION} + yarn_mappings=${YARN_MAPPINGS} + loader_version=${LOADER_VERSION} + +# Mod Properties + mod_version = ${VERSION} + maven_group = ${GROUP_ID} + archives_base_name = ${ARTIFACT_ID} + +#if (${API_VERSION}) +# Dependencies + # check this on https://modmuss50.me/fabric.html + fabric_version=${API_VERSION} +#end diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_gradle.properties.html b/src/main/resources/fileTemplates/j2ee/fabric/fabric_gradle.properties.html new file mode 100644 index 000000000..d12192ef3 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_gradle.properties.html @@ -0,0 +1,15 @@ + + + + +

This is a built-in file template used to create a new gradle.properties file for Fabric projects.

+ + diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_mixins.json.ft b/src/main/resources/fileTemplates/j2ee/fabric/fabric_mixins.json.ft new file mode 100644 index 000000000..3f14bed41 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_mixins.json.ft @@ -0,0 +1,13 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "${PACKAGE_NAME}", + "compatibilityLevel": "JAVA_8", + "mixins": [ + ], + "client": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_mixins.json.html b/src/main/resources/fileTemplates/j2ee/fabric/fabric_mixins.json.html new file mode 100644 index 000000000..15e52be74 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_mixins.json.html @@ -0,0 +1,15 @@ + + + + +

This is a built-in file template used to create a new modoid.mixins.json file for Fabric projects.

+ + diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_mod.json.ft b/src/main/resources/fileTemplates/j2ee/fabric/fabric_mod.json.ft new file mode 100644 index 000000000..0ca281e30 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_mod.json.ft @@ -0,0 +1,31 @@ +#set ( $d = "$" ) +{ + "schemaVersion": 1, + "id": "${ARTIFACT_ID}", + "version": "${d}{version}", + + "name": "${MOD_NAME}", + "description": "${MOD_DESCRIPTION}", + "authors": [], + "contact": {}, + + "license": "${LICENSE}", + "icon": "assets/${ARTIFACT_ID}/icon.png", + + "environment": "${MOD_ENVIRONMENT}", + "entrypoints": {}, + + #if (${MIXINS}) + "mixins": [ + "${ARTIFACT_ID}.mixins.json" + ], + #end + + "depends": { + "fabricloader": ">=${LOADER_VERSION}", + #if (${API_VERSION}) + "fabric": "*", + #end + "minecraft": "${MC_VERSION}" + } +} diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_mod.json.html b/src/main/resources/fileTemplates/j2ee/fabric/fabric_mod.json.html new file mode 100644 index 000000000..ac57601a3 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_mod.json.html @@ -0,0 +1,15 @@ + + + + +

This is a built-in file template used to create a new fabric.mod.json for Fabric projects.

+ + diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_settings.gradle.ft b/src/main/resources/fileTemplates/j2ee/fabric/fabric_settings.gradle.ft new file mode 100644 index 000000000..5b60df3d2 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_settings.gradle.ft @@ -0,0 +1,10 @@ +pluginManagement { + repositories { + jcenter() + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + gradlePluginPortal() + } +} diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_settings.gradle.html b/src/main/resources/fileTemplates/j2ee/fabric/fabric_settings.gradle.html new file mode 100644 index 000000000..f574a71c9 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_settings.gradle.html @@ -0,0 +1,15 @@ + + + + +

This is a built-in file template used to create a new settings.gradle file for Fabric projects.

+ + diff --git a/src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.ft b/src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.ft new file mode 100644 index 000000000..42e981d79 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.ft @@ -0,0 +1,633 @@ +#set ( $l = "<" ) +#set ( $g = ">" ) +Copyright (c) $YEAR $AUTHOR + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. ${l}http://fsf.org/${g} + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS diff --git a/src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.html b/src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.html new file mode 100644 index 000000000..338d7e8bc --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.html @@ -0,0 +1,15 @@ + + + + +

GNU AGPL 3.0 license template

+ + diff --git a/src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.ft b/src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.ft new file mode 100644 index 000000000..7924c59a4 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.ft @@ -0,0 +1,2 @@ +Copyright (c) $YEAR $AUTHOR +All rights reserved. diff --git a/src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.html b/src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.html new file mode 100644 index 000000000..fa47a7ada --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.html @@ -0,0 +1,15 @@ + + + + +

All Rights Reserved license template

+ + diff --git a/src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.ft b/src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.ft new file mode 100644 index 000000000..d9344cb12 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.ft @@ -0,0 +1,13 @@ +Copyright $YEAR $AUTHOR + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.html b/src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.html new file mode 100644 index 000000000..ddbd7806c --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.html @@ -0,0 +1,15 @@ + + + + +

Apache 2.0 license template

+ + diff --git a/src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.ft b/src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.ft new file mode 100644 index 000000000..4caed8cc9 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.ft @@ -0,0 +1,26 @@ +Copyright (c) $YEAR $AUTHOR +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation are those +of the authors and should not be interpreted as representing official policies, +either expressed or implied, of the FreeBSD Project. diff --git a/src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.html b/src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.html new file mode 100644 index 000000000..137767fdd --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.html @@ -0,0 +1,15 @@ + + + + +

BSD 2-Clause (FreeBSD) License template

+ + diff --git a/src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.ft b/src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.ft new file mode 100644 index 000000000..c3fbf05e2 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.ft @@ -0,0 +1,26 @@ +#set ( $l = "<" ) +#set ( $g = ">" ) +Copyright (c) $YEAR $AUTHOR +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the $ORGANIZATION nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL $COPYRIGHT_HOLDER BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.html b/src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.html new file mode 100644 index 000000000..92accb22f --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.html @@ -0,0 +1,15 @@ + + + + +

BSD 3-Clause (NewBSD) License template

+ + diff --git a/src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.ft b/src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.ft new file mode 100644 index 000000000..66128e0b3 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.ft @@ -0,0 +1,694 @@ +#set ( $l = "<" ) +#set ( $g = ">" ) +Copyright (c) $YEAR $AUTHOR + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see ${l}http://www.gnu.org/licenses/${g} + + + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. ${l}http://fsf.org/${g} + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {one line to give the program's name and a brief idea of what it does.} + Copyright (C) {year} {name of author} + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see ${l}http://www.gnu.org/licenses/${g}. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + {project} Copyright (C) {year} {fullname} + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +${l}http://www.gnu.org/licenses/${g}. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +${l}http://www.gnu.org/philosophy/why-not-lgpl.html${g}. + diff --git a/src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.html b/src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.html new file mode 100644 index 000000000..93c597961 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.html @@ -0,0 +1,15 @@ + + + + +

GNU GPL 3.0 license template

+ + diff --git a/src/main/resources/fileTemplates/j2ee/licenses/ISC.ft b/src/main/resources/fileTemplates/j2ee/licenses/ISC.ft new file mode 100644 index 000000000..c860b0114 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/licenses/ISC.ft @@ -0,0 +1,15 @@ +Copyright (c) $YEAR $AUTHOR + +Permission to use, copy, modify, and/or distribute this software for +any purpose with or without fee is hereby granted, provided that the +above copyright notice and this permission notice appear in all +copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL +WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE +AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL +DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR +PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/src/main/resources/fileTemplates/j2ee/licenses/ISC.html b/src/main/resources/fileTemplates/j2ee/licenses/ISC.html new file mode 100644 index 000000000..a0ddabc37 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/licenses/ISC.html @@ -0,0 +1,15 @@ + + + + +

Internet Systems Consortium (ISC) License template

+ + diff --git a/src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.ft b/src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.ft new file mode 100644 index 000000000..aa771bea7 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.ft @@ -0,0 +1,859 @@ +#set ( $l = "<" ) +#set ( $g = ">" ) +Copyright (c) $YEAR $AUTHOR + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +and a copy of GNU General Public License along with this program. If not, see +${l}http://www.gnu.org/licenses/${g} + + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. ${l}http://fsf.org/${g} + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. ${l}http://fsf.org/${g} + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {one line to give the program's name and a brief idea of what it does.} + Copyright (C) {year} {name of author} + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see ${l}http://www.gnu.org/licenses/${g}. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + {project} Copyright (C) {year} {fullname} + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +${l}http://www.gnu.org/licenses/${g}. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +${l}http://www.gnu.org/philosophy/why-not-lgpl.html${g}. + diff --git a/src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.html b/src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.html new file mode 100644 index 000000000..2e411a0c1 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.html @@ -0,0 +1,15 @@ + + + + +

GNU LGPL 3.0 license template

+ + diff --git a/src/main/resources/fileTemplates/j2ee/licenses/MIT.ft b/src/main/resources/fileTemplates/j2ee/licenses/MIT.ft new file mode 100644 index 000000000..ebd2d03e5 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/licenses/MIT.ft @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) $YEAR $AUTHOR + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/src/main/resources/fileTemplates/j2ee/licenses/MIT.html b/src/main/resources/fileTemplates/j2ee/licenses/MIT.html new file mode 100644 index 000000000..daaaba82d --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/licenses/MIT.html @@ -0,0 +1,15 @@ + + + + +

MIT license template

+ + diff --git a/src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.ft b/src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.ft new file mode 100644 index 000000000..aa8ed8fda --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.ft @@ -0,0 +1,380 @@ +Copyright (c) $YEAR $AUTHOR + +This Source Code Form is subject to the terms of the Mozilla Public +License, v. 2.0. If a copy of the MPL was not distributed with this +file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. + diff --git a/src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.html b/src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.html new file mode 100644 index 000000000..fd3f2a399 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.html @@ -0,0 +1,15 @@ + + + + +

Mozilla Public License 2.0 license template

+ + diff --git a/src/main/resources/fileTemplates/j2ee/licenses/unlicense.ft b/src/main/resources/fileTemplates/j2ee/licenses/unlicense.ft new file mode 100644 index 000000000..600eb7348 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/licenses/unlicense.ft @@ -0,0 +1,26 @@ +#set ( $l = "<" ) +#set ( $g = ">" ) +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to ${l}http://unlicense.org/${g} diff --git a/src/main/resources/fileTemplates/j2ee/licenses/unlicense.html b/src/main/resources/fileTemplates/j2ee/licenses/unlicense.html new file mode 100644 index 000000000..43a3b493c --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/licenses/unlicense.html @@ -0,0 +1,15 @@ + + + + +

Unlicense license template

+ + From 0a6039400b3be469a40651c336753d22a436b581 Mon Sep 17 00:00:00 2001 From: Joe Date: Mon, 29 Jun 2020 13:03:06 +0100 Subject: [PATCH 02/23] Rename gradle steps --- .../buildsystem/gradle/GradleBuildSystem.kt | 2 +- .../buildsystem/gradle/gradle-steps.kt | 43 +++++++++++- .../bukkit/creator/BukkitProjectCreator.kt | 6 +- .../creator/BungeeCordProjectCreator.kt | 6 +- .../fabric/creator/FabricProjectCreator.kt | 9 ++- .../forge/creator/ForgeProjectCreator.kt | 70 ++++++++++--------- .../creator/LiteLoaderProjectCreator.kt | 16 ++++- .../sponge/creator/SpongeProjectCreator.kt | 6 +- .../creator/VelocityProjectCreator.kt | 6 +- 9 files changed, 112 insertions(+), 52 deletions(-) diff --git a/src/main/kotlin/com/demonwav/mcdev/creator/buildsystem/gradle/GradleBuildSystem.kt b/src/main/kotlin/com/demonwav/mcdev/creator/buildsystem/gradle/GradleBuildSystem.kt index da17da627..636cea090 100644 --- a/src/main/kotlin/com/demonwav/mcdev/creator/buildsystem/gradle/GradleBuildSystem.kt +++ b/src/main/kotlin/com/demonwav/mcdev/creator/buildsystem/gradle/GradleBuildSystem.kt @@ -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) ) } diff --git a/src/main/kotlin/com/demonwav/mcdev/creator/buildsystem/gradle/gradle-steps.kt b/src/main/kotlin/com/demonwav/mcdev/creator/buildsystem/gradle/gradle-steps.kt index 48005e446..f7997623a 100644 --- a/src/main/kotlin/com/demonwav/mcdev/creator/buildsystem/gradle/gradle-steps.kt +++ b/src/main/kotlin/com/demonwav/mcdev/creator/buildsystem/gradle/gradle-steps.kt @@ -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 @@ -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 +) : 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, diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/bukkit/creator/BukkitProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/platform/bukkit/creator/BukkitProjectCreator.kt index c2c93917f..fe39773fc 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/bukkit/creator/BukkitProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/bukkit/creator/BukkitProjectCreator.kt @@ -18,7 +18,7 @@ import com.demonwav.mcdev.creator.buildsystem.BuildDependency import com.demonwav.mcdev.creator.buildsystem.BuildRepository import com.demonwav.mcdev.creator.buildsystem.BuildSystem import com.demonwav.mcdev.creator.buildsystem.gradle.BasicGradleFinalizerStep -import com.demonwav.mcdev.creator.buildsystem.gradle.BasicGradleStep +import com.demonwav.mcdev.creator.buildsystem.gradle.GradleSetupStep import com.demonwav.mcdev.creator.buildsystem.gradle.GradleBuildSystem import com.demonwav.mcdev.creator.buildsystem.gradle.GradleFiles import com.demonwav.mcdev.creator.buildsystem.gradle.GradleGitignoreStep @@ -117,7 +117,7 @@ class BukkitGradleCreator( return listOf( setupDependencyStep(), CreateDirectoriesStep(buildSystem, rootDirectory), - BasicGradleStep(project, rootDirectory, buildSystem, files), + GradleSetupStep(project, rootDirectory, buildSystem, files), setupMainClassStep(), setupYmlStep(), GradleWrapperStep(project, rootDirectory, buildSystem), @@ -133,7 +133,7 @@ class BukkitGradleCreator( return listOf( setupDependencyStep(), CreateDirectoriesStep(buildSystem, rootDirectory), - BasicGradleStep(project, rootDirectory, buildSystem, files), + GradleSetupStep(project, rootDirectory, buildSystem, files), setupMainClassStep(), setupYmlStep() ) diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/bungeecord/creator/BungeeCordProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/platform/bungeecord/creator/BungeeCordProjectCreator.kt index a9637accf..eb09e07b0 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/bungeecord/creator/BungeeCordProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/bungeecord/creator/BungeeCordProjectCreator.kt @@ -18,7 +18,7 @@ import com.demonwav.mcdev.creator.buildsystem.BuildDependency import com.demonwav.mcdev.creator.buildsystem.BuildRepository import com.demonwav.mcdev.creator.buildsystem.BuildSystem import com.demonwav.mcdev.creator.buildsystem.gradle.BasicGradleFinalizerStep -import com.demonwav.mcdev.creator.buildsystem.gradle.BasicGradleStep +import com.demonwav.mcdev.creator.buildsystem.gradle.GradleSetupStep import com.demonwav.mcdev.creator.buildsystem.gradle.GradleBuildSystem import com.demonwav.mcdev.creator.buildsystem.gradle.GradleFiles import com.demonwav.mcdev.creator.buildsystem.gradle.GradleGitignoreStep @@ -118,7 +118,7 @@ class BungeeCordGradleCreator( return listOf( setupDependencyStep(), CreateDirectoriesStep(buildSystem, rootDirectory), - BasicGradleStep(project, rootDirectory, buildSystem, files), + GradleSetupStep(project, rootDirectory, buildSystem, files), setupMainClassStep(), setupYmlStep(), GradleWrapperStep(project, rootDirectory, buildSystem), @@ -134,7 +134,7 @@ class BungeeCordGradleCreator( return listOf( setupDependencyStep(), CreateDirectoriesStep(buildSystem, rootDirectory), - BasicGradleStep(project, rootDirectory, buildSystem, files), + GradleSetupStep(project, rootDirectory, buildSystem, files), setupMainClassStep(), setupYmlStep() ) diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt index 06baed855..15c452f36 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt @@ -20,7 +20,7 @@ import com.demonwav.mcdev.creator.buildsystem.gradle.GradleGitignoreStep import com.demonwav.mcdev.creator.buildsystem.gradle.GradleWrapperStep import com.demonwav.mcdev.platform.fabric.EntryPoint import com.demonwav.mcdev.platform.fabric.util.FabricConstants -import com.demonwav.mcdev.platform.forge.creator.GradleSetupStep +import com.demonwav.mcdev.creator.buildsystem.gradle.SimpleGradleSetupStep import com.demonwav.mcdev.util.License import com.demonwav.mcdev.util.addImplements import com.demonwav.mcdev.util.addMethod @@ -74,7 +74,12 @@ class FabricProjectCreator( val files = GradleFiles(buildText, propText, settingsText) val steps = mutableListOf( - GradleSetupStep(project, rootDirectory, buildSystem, files), + SimpleGradleSetupStep( + project, + rootDirectory, + buildSystem, + files + ), GradleWrapperStep(project, rootDirectory, buildSystem) ) if (config.genSources) { diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/forge/creator/ForgeProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/platform/forge/creator/ForgeProjectCreator.kt index 29bf84906..7d73c19a0 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/forge/creator/ForgeProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/forge/creator/ForgeProjectCreator.kt @@ -14,13 +14,12 @@ import com.demonwav.mcdev.creator.BaseProjectCreator import com.demonwav.mcdev.creator.BasicJavaClassStep import com.demonwav.mcdev.creator.CreatorStep import com.demonwav.mcdev.creator.buildsystem.BuildSystem -import com.demonwav.mcdev.creator.buildsystem.DirectorySet import com.demonwav.mcdev.creator.buildsystem.gradle.BasicGradleFinalizerStep import com.demonwav.mcdev.creator.buildsystem.gradle.GradleBuildSystem import com.demonwav.mcdev.creator.buildsystem.gradle.GradleFiles import com.demonwav.mcdev.creator.buildsystem.gradle.GradleGitignoreStep import com.demonwav.mcdev.creator.buildsystem.gradle.GradleWrapperStep -import com.demonwav.mcdev.creator.buildsystem.gradle.setupGradleFiles +import com.demonwav.mcdev.creator.buildsystem.gradle.SimpleGradleSetupStep import com.demonwav.mcdev.platform.forge.util.ForgeConstants import com.demonwav.mcdev.util.SemanticVersion import com.demonwav.mcdev.util.runGradleTask @@ -28,7 +27,6 @@ import com.demonwav.mcdev.util.runWriteTask import com.intellij.openapi.module.Module import com.intellij.openapi.progress.ProgressIndicator import com.intellij.openapi.project.Project -import com.intellij.psi.PsiManager import java.nio.file.Files import java.nio.file.Path import java.nio.file.StandardOpenOption.CREATE @@ -56,7 +54,12 @@ class Fg2ProjectCreator( val files = GradleFiles(buildText, propText, settingsText) return listOf( - GradleSetupStep(project, rootDirectory, buildSystem, files), + SimpleGradleSetupStep( + project, + rootDirectory, + buildSystem, + files + ), setupMainClassStep(), GradleWrapperStep(project, rootDirectory, buildSystem), McmodInfoStep(project, buildSystem, config), @@ -73,7 +76,12 @@ class Fg2ProjectCreator( val files = GradleFiles(buildText, propText, null) return listOf( - GradleSetupStep(project, rootDirectory, buildSystem, files), + SimpleGradleSetupStep( + project, + rootDirectory, + buildSystem, + files + ), setupMainClassStep(), McmodInfoStep(project, buildSystem, config), SetupDecompWorkspaceStep(project, rootDirectory), @@ -116,7 +124,12 @@ open class Fg3ProjectCreator( val files = createGradleFiles(hasData = true) return listOf( - GradleSetupStep(project, rootDirectory, buildSystem, files), + SimpleGradleSetupStep( + project, + rootDirectory, + buildSystem, + files + ), setupMainClassStep(), GradleWrapperStep(project, rootDirectory, buildSystem), Fg3ProjectFilesStep(project, buildSystem, config), @@ -133,7 +146,12 @@ open class Fg3ProjectCreator( val files = GradleFiles(buildText, null, null) return listOf( - GradleSetupStep(project, rootDirectory, buildSystem, files), + SimpleGradleSetupStep( + project, + rootDirectory, + buildSystem, + files + ), setupMainClassStep(), Fg3ProjectFilesStep(project, buildSystem, config), Fg3CompileJavaStep(project, rootDirectory), @@ -159,7 +177,12 @@ class Fg3Mc112ProjectCreator( val files = createGradleFiles(hasData = false) return listOf( - GradleSetupStep(project, rootDirectory, buildSystem, files), + SimpleGradleSetupStep( + project, + rootDirectory, + buildSystem, + files + ), setupMainClassStep(), GradleWrapperStep(project, rootDirectory, buildSystem), McmodInfoStep(project, buildSystem, config), @@ -176,7 +199,12 @@ class Fg3Mc112ProjectCreator( val files = GradleFiles(buildText, null, null) return listOf( - GradleSetupStep(project, rootDirectory, buildSystem, files), + SimpleGradleSetupStep( + project, + rootDirectory, + buildSystem, + files + ), setupMainClassStep(), McmodInfoStep(project, buildSystem, config), Fg3CompileJavaStep(project, rootDirectory), @@ -201,30 +229,6 @@ class SetupDecompWorkspaceStep( } } -class GradleSetupStep( - private val project: Project, - private val rootDirectory: Path, - private val buildSystem: BuildSystem, - private val gradleFiles: GradleFiles -) : CreatorStep { - - override fun runStep(indicator: ProgressIndicator) { - runWriteTask { - buildSystem.directories = DirectorySet.create(rootDirectory) - val (buildGradle, gradleProp, settingsGradle) = setupGradleFiles(rootDirectory, gradleFiles) - - val psiManager = PsiManager.getInstance(project) - CreatorStep.writeText(buildGradle, gradleFiles.buildGradle, psiManager) - if (gradleProp != null && gradleFiles.gradleProperties != null) { - CreatorStep.writeText(gradleProp, gradleFiles.gradleProperties, psiManager) - } - if (settingsGradle != null && gradleFiles.settingsGradle != null) { - CreatorStep.writeText(settingsGradle, gradleFiles.settingsGradle, psiManager) - } - } - } -} - class McmodInfoStep( private val project: Project, private val buildSystem: BuildSystem, diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/liteloader/creator/LiteLoaderProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/platform/liteloader/creator/LiteLoaderProjectCreator.kt index 53ddeac17..338786089 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/liteloader/creator/LiteLoaderProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/liteloader/creator/LiteLoaderProjectCreator.kt @@ -18,7 +18,7 @@ import com.demonwav.mcdev.creator.buildsystem.gradle.GradleBuildSystem import com.demonwav.mcdev.creator.buildsystem.gradle.GradleFiles import com.demonwav.mcdev.creator.buildsystem.gradle.GradleGitignoreStep import com.demonwav.mcdev.creator.buildsystem.gradle.GradleWrapperStep -import com.demonwav.mcdev.platform.forge.creator.GradleSetupStep +import com.demonwav.mcdev.creator.buildsystem.gradle.SimpleGradleSetupStep import com.demonwav.mcdev.platform.forge.creator.SetupDecompWorkspaceStep import com.intellij.openapi.module.Module import java.nio.file.Path @@ -44,7 +44,12 @@ class LiteLoaderProjectCreator( val files = GradleFiles(buildText, propText, settingsText) return listOf( - GradleSetupStep(project, rootDirectory, buildSystem, files), + SimpleGradleSetupStep( + project, + rootDirectory, + buildSystem, + files + ), setupMainClassStep(), GradleWrapperStep(project, rootDirectory, buildSystem), SetupDecompWorkspaceStep(project, rootDirectory), @@ -59,7 +64,12 @@ class LiteLoaderProjectCreator( val files = GradleFiles(buildText, propText, null) return listOf( - GradleSetupStep(project, rootDirectory, buildSystem, files), + SimpleGradleSetupStep( + project, + rootDirectory, + buildSystem, + files + ), setupMainClassStep(), SetupDecompWorkspaceStep(project, rootDirectory) ) diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/sponge/creator/SpongeProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/platform/sponge/creator/SpongeProjectCreator.kt index 24cb03ff1..5ddbc7f41 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/sponge/creator/SpongeProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/sponge/creator/SpongeProjectCreator.kt @@ -18,7 +18,7 @@ import com.demonwav.mcdev.creator.buildsystem.BuildRepository import com.demonwav.mcdev.creator.buildsystem.BuildSystem import com.demonwav.mcdev.creator.buildsystem.BuildSystemType import com.demonwav.mcdev.creator.buildsystem.gradle.BasicGradleFinalizerStep -import com.demonwav.mcdev.creator.buildsystem.gradle.BasicGradleStep +import com.demonwav.mcdev.creator.buildsystem.gradle.GradleSetupStep import com.demonwav.mcdev.creator.buildsystem.gradle.GradleBuildSystem import com.demonwav.mcdev.creator.buildsystem.gradle.GradleFiles import com.demonwav.mcdev.creator.buildsystem.gradle.GradleGitignoreStep @@ -129,7 +129,7 @@ class SpongeGradleCreator( return listOf( setupDependencyStep(), CreateDirectoriesStep(buildSystem, rootDirectory), - BasicGradleStep(project, rootDirectory, buildSystem, files), + GradleSetupStep(project, rootDirectory, buildSystem, files), mainClassStep, modifyStep, GradleWrapperStep(project, rootDirectory, buildSystem), @@ -147,7 +147,7 @@ class SpongeGradleCreator( return listOf( setupDependencyStep(), CreateDirectoriesStep(buildSystem, rootDirectory), - BasicGradleStep(project, rootDirectory, buildSystem, files), + GradleSetupStep(project, rootDirectory, buildSystem, files), mainClassStep, modifyStep ) diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/velocity/creator/VelocityProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/platform/velocity/creator/VelocityProjectCreator.kt index 382ed4e49..0c4e0147c 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/velocity/creator/VelocityProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/velocity/creator/VelocityProjectCreator.kt @@ -17,7 +17,7 @@ import com.demonwav.mcdev.creator.buildsystem.BuildDependency import com.demonwav.mcdev.creator.buildsystem.BuildRepository import com.demonwav.mcdev.creator.buildsystem.BuildSystem import com.demonwav.mcdev.creator.buildsystem.gradle.BasicGradleFinalizerStep -import com.demonwav.mcdev.creator.buildsystem.gradle.BasicGradleStep +import com.demonwav.mcdev.creator.buildsystem.gradle.GradleSetupStep import com.demonwav.mcdev.creator.buildsystem.gradle.GradleBuildSystem import com.demonwav.mcdev.creator.buildsystem.gradle.GradleFiles import com.demonwav.mcdev.creator.buildsystem.gradle.GradleGitignoreStep @@ -125,7 +125,7 @@ class VelocityGradleCreator( return listOf( setupDependencyStep(), CreateDirectoriesStep(buildSystem, rootDirectory), - BasicGradleStep(project, rootDirectory, buildSystem, files), + GradleSetupStep(project, rootDirectory, buildSystem, files), mainClassStep, modifyStep, GradleWrapperStep(project, rootDirectory, buildSystem), @@ -143,7 +143,7 @@ class VelocityGradleCreator( return listOf( setupDependencyStep(), CreateDirectoriesStep(buildSystem, rootDirectory), - BasicGradleStep(project, rootDirectory, buildSystem, files), + GradleSetupStep(project, rootDirectory, buildSystem, files), mainClassStep, modifyStep ) From 454e5d708778b67d7f98a97744e5900bde6bb299 Mon Sep 17 00:00:00 2001 From: Joe Date: Tue, 30 Jun 2020 11:36:13 +0100 Subject: [PATCH 03/23] Smart mode fixes --- .../fabric/creator/FabricProjectCreator.kt | 9 ++++-- .../kotlin/com/demonwav/mcdev/util/utils.kt | 29 +++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt index 15c452f36..4ad39ade3 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt @@ -28,6 +28,7 @@ import com.demonwav.mcdev.util.invokeLater import com.demonwav.mcdev.util.runGradleTask import com.demonwav.mcdev.util.runWriteAction import com.demonwav.mcdev.util.runWriteTask +import com.demonwav.mcdev.util.runWriteTaskInSmartMode import com.demonwav.mcdev.util.virtualFile import com.intellij.codeInsight.CodeInsightBundle import com.intellij.codeInsight.daemon.impl.quickfix.CreateFromUsageUtils @@ -240,7 +241,9 @@ class CreateEntryPointStep( override fun runStep(indicator: ProgressIndicator) { val dirs = buildSystem.dirsOrError - runWriteTask { + indicator.text = "Indexing" + + project.runWriteTaskInSmartMode { val dotIndex = qualifiedClassName.lastIndexOf('.') val packageName = if (dotIndex == -1) { "" @@ -260,7 +263,7 @@ class CreateEntryPointStep( } val clazz = try { - val psiDir = directory.virtualFile?.let { PsiManager.getInstance(project).findDirectory(it) } ?: return@runWriteTask + val psiDir = directory.virtualFile?.let { PsiManager.getInstance(project).findDirectory(it) } ?: return@runWriteTaskInSmartMode JavaDirectoryService.getInstance().createClass(psiDir, className) } catch (e: IncorrectOperationException) { invokeLater { @@ -274,7 +277,7 @@ class CreateEntryPointStep( CodeInsightBundle.message("intention.error.cannot.create.class.title") ) } - return@runWriteTask + return@runWriteTaskInSmartMode } val editor = EditorHelper.openInEditor(clazz) diff --git a/src/main/kotlin/com/demonwav/mcdev/util/utils.kt b/src/main/kotlin/com/demonwav/mcdev/util/utils.kt index 098fded58..5f3ca73e7 100644 --- a/src/main/kotlin/com/demonwav/mcdev/util/utils.kt +++ b/src/main/kotlin/com/demonwav/mcdev/util/utils.kt @@ -19,7 +19,9 @@ import com.intellij.openapi.command.WriteCommandAction import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.openapi.module.Module import com.intellij.openapi.module.ModuleManager +import com.intellij.openapi.progress.ProcessCanceledException import com.intellij.openapi.project.DumbService +import com.intellij.openapi.project.Project import com.intellij.openapi.project.ProjectManager import com.intellij.openapi.util.Computable import com.intellij.openapi.util.Ref @@ -39,6 +41,33 @@ fun runWriteTaskLater(func: () -> Unit) { } } +inline fun Project.runWriteTaskInSmartMode(crossinline func: () -> T): T { + if (ApplicationManager.getApplication().isReadAccessAllowed) { + println("WARNING: not supposed to do this!") + return runWriteTask { func() } + } + + val dumbService = DumbService.getInstance(this) + val ref = Ref() + while (true) { + dumbService.waitForSmartMode() + val success = runWriteTask { + if (isDisposed) { + throw ProcessCanceledException() + } + if (dumbService.isDumb) { + return@runWriteTask false + } + ref.set(func()) + return@runWriteTask true + } + if (success) { + break + } + } + return ref.get() +} + fun invokeAndWait(func: () -> T): T { val ref = Ref() ApplicationManager.getApplication().invokeAndWait({ ref.set(func()) }, ModalityState.defaultModalityState()) From 25b30e22fd58c0090d3405b861a0c3e397391c76 Mon Sep 17 00:00:00 2001 From: Joe Date: Tue, 30 Jun 2020 16:52:02 +0100 Subject: [PATCH 04/23] Fix entrypoint generation --- .../fabric/creator/FabricProjectCreator.kt | 151 +++++++++--------- .../kotlin/com/demonwav/mcdev/util/utils.kt | 1 - 2 files changed, 78 insertions(+), 74 deletions(-) diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt index 4ad39ade3..b7d6db473 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt @@ -243,27 +243,29 @@ class CreateEntryPointStep( indicator.text = "Indexing" - project.runWriteTaskInSmartMode { - val dotIndex = qualifiedClassName.lastIndexOf('.') - val packageName = if (dotIndex == -1) { - "" - } else { - qualifiedClassName.substring(0, dotIndex) - } - val className = qualifiedClassName.substring(dotIndex + 1) + val dotIndex = qualifiedClassName.lastIndexOf('.') + val packageName = if (dotIndex == -1) { + "" + } else { + qualifiedClassName.substring(0, dotIndex) + } + val className = qualifiedClassName.substring(dotIndex + 1) - indicator.text = "Writing class: $className" + indicator.text = "Writing class: $className" - var directory = dirs.sourceDirectory - for (part in packageName.split(".")) { - directory = directory.resolve(part) - } - if (Files.notExists(directory)) { - Files.createDirectories(directory) - } + var directory = dirs.sourceDirectory + for (part in packageName.split(".")) { + directory = directory.resolve(part) + } + if (Files.notExists(directory)) { + Files.createDirectories(directory) + } + + val virtualDir = directory.virtualFile ?: return + project.runWriteTaskInSmartMode { + val psiDir = PsiManager.getInstance(project).findDirectory(virtualDir) ?: return@runWriteTaskInSmartMode val clazz = try { - val psiDir = directory.virtualFile?.let { PsiManager.getInstance(project).findDirectory(it) } ?: return@runWriteTaskInSmartMode JavaDirectoryService.getInstance().createClass(psiDir, className) } catch (e: IncorrectOperationException) { invokeLater { @@ -282,64 +284,67 @@ class CreateEntryPointStep( val editor = EditorHelper.openInEditor(clazz) - val clientEntryPoints = entryPoints.filter { it.category == "client" } - val serverEntryPoints = entryPoints.filter { it.category == "server" } - val otherEntryPoints = entryPoints.filter { it.category != "client" && it.category != "server" } - val entryPointsByInterface = entryPoints - .filter { it.type == EntryPoint.Type.CLASS } - .groupBy { it.interfaceName } - .entries - .sortedBy { it.key } - val entryPointsByMethodNameAndSig = entryPoints - .filter { it.type == EntryPoint.Type.METHOD } - .groupBy {entryPoint -> - val functionalMethod = findFunctionalMethod(clazz, entryPoint.interfaceName) ?: return@groupBy null - val paramTypes = functionalMethod.parameterList.parameters.map { it.type.canonicalText } - (entryPoint.methodName ?: functionalMethod.name) to paramTypes - } - .entries - .filter { it.key != null } - .map { it.key!! to it.value } - .sortedBy { it.first.first } - - val elementFactory = JavaPsiFacade.getElementFactory(project) - - var isClientClass = false - var isServerClass = false - if (clientEntryPoints.isNotEmpty()) { - if (serverEntryPoints.isEmpty() && otherEntryPoints.isEmpty()) { - addEnvironmentAnnotation(clazz, "CLIENT") - isClientClass = true - } else { - addSidedInterfaceEntryPoints(entryPointsByInterface, clazz, editor, "client") - } - } else if (serverEntryPoints.isNotEmpty()) { - if (clientEntryPoints.isEmpty() && otherEntryPoints.isEmpty()) { - addEnvironmentAnnotation(clazz, "SERVER") - isServerClass = true - } else { - addSidedInterfaceEntryPoints(entryPointsByInterface, clazz, editor, "server") + clazz.containingFile.runWriteAction { + val clientEntryPoints = entryPoints.filter { it.category == "client" } + val serverEntryPoints = entryPoints.filter { it.category == "server" } + val otherEntryPoints = entryPoints.filter { it.category != "client" && it.category != "server" } + val entryPointsByInterface = entryPoints + .filter { it.type == EntryPoint.Type.CLASS } + .groupBy { it.interfaceName } + .entries + .sortedBy { it.key } + val entryPointsByMethodNameAndSig = entryPoints + .filter { it.type == EntryPoint.Type.METHOD } + .groupBy {entryPoint -> + val functionalMethod = findFunctionalMethod(clazz, entryPoint.interfaceName) ?: return@groupBy null + val paramTypes = functionalMethod.parameterList.parameters.map { it.type.canonicalText } + (entryPoint.methodName ?: functionalMethod.name) to paramTypes + } + .entries + .filter { it.key != null } + .map { it.key!! to it.value } + .sortedBy { it.first.first } + + + val elementFactory = JavaPsiFacade.getElementFactory(project) + + var isClientClass = false + var isServerClass = false + if (clientEntryPoints.isNotEmpty()) { + if (serverEntryPoints.isEmpty() && otherEntryPoints.isEmpty()) { + addEnvironmentAnnotation(clazz, "CLIENT") + isClientClass = true + } else { + addSidedInterfaceEntryPoints(entryPointsByInterface, clazz, editor, "client") + } + } else if (serverEntryPoints.isNotEmpty()) { + if (clientEntryPoints.isEmpty() && otherEntryPoints.isEmpty()) { + addEnvironmentAnnotation(clazz, "SERVER") + isServerClass = true + } else { + addSidedInterfaceEntryPoints(entryPointsByInterface, clazz, editor, "server") + } } - } - for (eps in entryPointsByInterface) { - clazz.addImplements(eps.key) - } - implementAll(clazz, editor) - - for (eps in entryPointsByMethodNameAndSig) { - val functionalMethod = findFunctionalMethod(clazz, eps.second.first().interfaceName) ?: continue - val newMethod = clazz.addMethod(functionalMethod) ?: continue - val methodName = eps.first.first - newMethod.nameIdentifier?.replace(elementFactory.createIdentifier(methodName)) - newMethod.modifierList.setModifierProperty(PsiModifier.PUBLIC, true) - newMethod.modifierList.setModifierProperty(PsiModifier.STATIC, true) - newMethod.modifierList.setModifierProperty(PsiModifier.ABSTRACT, false) - CreateFromUsageUtils.setupMethodBody(newMethod) - if (!isClientClass && eps.second.all { it.category == "client" }) { - addEnvironmentAnnotation(newMethod, "CLIENT") - } else if (!isServerClass && eps.second.all { it.category == "server" }) { - addEnvironmentAnnotation(newMethod, "SERVER") + for (eps in entryPointsByInterface) { + clazz.addImplements(eps.key) + } + implementAll(clazz, editor) + + for (eps in entryPointsByMethodNameAndSig) { + val functionalMethod = findFunctionalMethod(clazz, eps.second.first().interfaceName) ?: continue + val newMethod = clazz.addMethod(functionalMethod) ?: continue + val methodName = eps.first.first + newMethod.nameIdentifier?.replace(elementFactory.createIdentifier(methodName)) + newMethod.modifierList.setModifierProperty(PsiModifier.PUBLIC, true) + newMethod.modifierList.setModifierProperty(PsiModifier.STATIC, true) + newMethod.modifierList.setModifierProperty(PsiModifier.ABSTRACT, false) + CreateFromUsageUtils.setupMethodBody(newMethod) + if (!isClientClass && eps.second.all { it.category == "client" }) { + addEnvironmentAnnotation(newMethod, "CLIENT") + } else if (!isServerClass && eps.second.all { it.category == "server" }) { + addEnvironmentAnnotation(newMethod, "SERVER") + } } } } diff --git a/src/main/kotlin/com/demonwav/mcdev/util/utils.kt b/src/main/kotlin/com/demonwav/mcdev/util/utils.kt index 5f3ca73e7..95a12cb52 100644 --- a/src/main/kotlin/com/demonwav/mcdev/util/utils.kt +++ b/src/main/kotlin/com/demonwav/mcdev/util/utils.kt @@ -43,7 +43,6 @@ fun runWriteTaskLater(func: () -> Unit) { inline fun Project.runWriteTaskInSmartMode(crossinline func: () -> T): T { if (ApplicationManager.getApplication().isReadAccessAllowed) { - println("WARNING: not supposed to do this!") return runWriteTask { func() } } From 82a13cced15f291de35e9012c9d8acc1e1f6aae6 Mon Sep 17 00:00:00 2001 From: Joe Date: Tue, 30 Jun 2020 17:13:32 +0100 Subject: [PATCH 05/23] Fix formatting --- .../mcdev/facet/MinecraftFacetEditorTab.kt | 4 +- .../bukkit/creator/BukkitProjectCreator.kt | 2 +- .../creator/BungeeCordProjectCreator.kt | 2 +- .../mcdev/platform/fabric/FabricModule.kt | 5 +- .../creator/FabricProjectSettingsWizard.kt | 89 ++++++++++++++----- .../sponge/creator/SpongeProjectCreator.kt | 2 +- .../creator/VelocityProjectCreator.kt | 2 +- .../demonwav/mcdev/util/MinecraftTemplates.kt | 4 +- 8 files changed, 80 insertions(+), 30 deletions(-) diff --git a/src/main/kotlin/com/demonwav/mcdev/facet/MinecraftFacetEditorTab.kt b/src/main/kotlin/com/demonwav/mcdev/facet/MinecraftFacetEditorTab.kt index 582d1627d..cef876fa0 100644 --- a/src/main/kotlin/com/demonwav/mcdev/facet/MinecraftFacetEditorTab.kt +++ b/src/main/kotlin/com/demonwav/mcdev/facet/MinecraftFacetEditorTab.kt @@ -139,7 +139,9 @@ class MinecraftFacetEditorTab(private val configuration: MinecraftFacetConfigura } forgeEnabledCheckBox.addActionListener { also(forgeEnabledCheckBox, mcpEnabledCheckBox) } - fabricEnabledCheckBox.addActionListener { also(fabricEnabledCheckBox, mixinEnabledCheckBox, mcpEnabledCheckBox) } + fabricEnabledCheckBox.addActionListener { + also(fabricEnabledCheckBox, mixinEnabledCheckBox, mcpEnabledCheckBox) + } liteloaderEnabledCheckBox.addActionListener { also(liteloaderEnabledCheckBox, mcpEnabledCheckBox) } mixinEnabledCheckBox.addActionListener { also(mixinEnabledCheckBox, mcpEnabledCheckBox) } diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/bukkit/creator/BukkitProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/platform/bukkit/creator/BukkitProjectCreator.kt index fe39773fc..da3e5bcd9 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/bukkit/creator/BukkitProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/bukkit/creator/BukkitProjectCreator.kt @@ -18,10 +18,10 @@ import com.demonwav.mcdev.creator.buildsystem.BuildDependency import com.demonwav.mcdev.creator.buildsystem.BuildRepository import com.demonwav.mcdev.creator.buildsystem.BuildSystem import com.demonwav.mcdev.creator.buildsystem.gradle.BasicGradleFinalizerStep -import com.demonwav.mcdev.creator.buildsystem.gradle.GradleSetupStep import com.demonwav.mcdev.creator.buildsystem.gradle.GradleBuildSystem import com.demonwav.mcdev.creator.buildsystem.gradle.GradleFiles import com.demonwav.mcdev.creator.buildsystem.gradle.GradleGitignoreStep +import com.demonwav.mcdev.creator.buildsystem.gradle.GradleSetupStep import com.demonwav.mcdev.creator.buildsystem.gradle.GradleWrapperStep import com.demonwav.mcdev.creator.buildsystem.maven.BasicMavenFinalizerStep import com.demonwav.mcdev.creator.buildsystem.maven.BasicMavenStep diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/bungeecord/creator/BungeeCordProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/platform/bungeecord/creator/BungeeCordProjectCreator.kt index eb09e07b0..36e7208ea 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/bungeecord/creator/BungeeCordProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/bungeecord/creator/BungeeCordProjectCreator.kt @@ -18,10 +18,10 @@ import com.demonwav.mcdev.creator.buildsystem.BuildDependency import com.demonwav.mcdev.creator.buildsystem.BuildRepository import com.demonwav.mcdev.creator.buildsystem.BuildSystem import com.demonwav.mcdev.creator.buildsystem.gradle.BasicGradleFinalizerStep -import com.demonwav.mcdev.creator.buildsystem.gradle.GradleSetupStep import com.demonwav.mcdev.creator.buildsystem.gradle.GradleBuildSystem import com.demonwav.mcdev.creator.buildsystem.gradle.GradleFiles import com.demonwav.mcdev.creator.buildsystem.gradle.GradleGitignoreStep +import com.demonwav.mcdev.creator.buildsystem.gradle.GradleSetupStep import com.demonwav.mcdev.creator.buildsystem.gradle.GradleWrapperStep import com.demonwav.mcdev.creator.buildsystem.maven.BasicMavenFinalizerStep import com.demonwav.mcdev.creator.buildsystem.maven.BasicMavenStep diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/FabricModule.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/FabricModule.kt index cfecdc15b..7fd574699 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/FabricModule.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/FabricModule.kt @@ -44,7 +44,10 @@ class FabricModule internal constructor(facet: MinecraftFacet) : AbstractModule( // TODO: check the mod json, and support method entrypoints val interfaces = psiClass.interfaces - return interfaces.any { it.qualifiedName == FabricConstants.MOD_INITIALIZER || it.qualifiedName == FabricConstants.CLIENT_MOD_INITIALIZER } + return interfaces.any { + it.qualifiedName == FabricConstants.MOD_INITIALIZER || + it.qualifiedName == FabricConstants.CLIENT_MOD_INITIALIZER + } } override fun dispose() { diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt index 114e30f87..1c77391db 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt @@ -30,16 +30,27 @@ import com.intellij.ui.CollectionComboBoxModel import com.intellij.ui.ToolbarDecorator import com.intellij.ui.table.JBTable import com.intellij.util.ui.EditableModel -import kotlinx.coroutines.* -import kotlinx.coroutines.swing.Swing -import org.apache.commons.lang.WordUtils import java.awt.event.ActionListener import java.awt.event.ComponentAdapter import java.awt.event.ComponentEvent -import java.io.IOException -import java.util.* -import javax.swing.* +import java.util.Collections +import java.util.Locale +import javax.swing.JCheckBox +import javax.swing.JComboBox +import javax.swing.JComponent +import javax.swing.JLabel +import javax.swing.JPanel +import javax.swing.JProgressBar +import javax.swing.JTextField import javax.swing.table.AbstractTableModel +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job +import kotlinx.coroutines.async +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.launch +import kotlinx.coroutines.swing.Swing +import org.apache.commons.lang.WordUtils class FabricProjectSettingsWizard(private val creator: MinecraftProjectCreator) : MinecraftModuleWizardStep() { @@ -66,8 +77,8 @@ class FabricProjectSettingsWizard(private val creator: MinecraftProjectCreator) private lateinit var loadingBar: JProgressBar private lateinit var minecraftVersionLabel: JLabel private lateinit var entryPointsTable: JPanel - private lateinit var entryPoints : ArrayList - private lateinit var tableModel : EntryPointTableModel + private lateinit var entryPoints: ArrayList + private lateinit var tableModel: EntryPointTableModel private lateinit var yarnWarning: JLabel private lateinit var errorLabel: JLabel @@ -137,10 +148,25 @@ class FabricProjectSettingsWizard(private val creator: MinecraftProjectCreator) if (!initializedEntryPointsTable) { val packageName = "${buildSystem.groupId.toPackageName()}.${buildSystem.artifactId.toPackageName()}" var className = buildSystem.artifactId.replace('-', ' ').let { WordUtils.capitalize(it) }.replace(" ", "") - if (creator.configs.size > 1) + if (creator.configs.size > 1) { className += PlatformType.FABRIC.normalName - entryPoints.add(EntryPoint("main", EntryPoint.Type.CLASS, "$packageName.$className", FabricConstants.MOD_INITIALIZER)) - entryPoints.add(EntryPoint("client", EntryPoint.Type.CLASS,"$packageName.client.${className}Client", FabricConstants.CLIENT_MOD_INITIALIZER)) + } + entryPoints.add( + EntryPoint( + "main", + EntryPoint.Type.CLASS, + "$packageName.$className", + FabricConstants.MOD_INITIALIZER + ) + ) + entryPoints.add( + EntryPoint( + "client", + EntryPoint.Type.CLASS, + "$packageName.client.${className}Client", + FabricConstants.CLIENT_MOD_INITIALIZER + ) + ) tableModel.fireTableDataChanged() entryPointsTable.revalidate() initializedEntryPointsTable = true @@ -200,13 +226,24 @@ class FabricProjectSettingsWizard(private val creator: MinecraftProjectCreator) conf.modRepo = repositoryField.text conf.yarnVersion = yarnVersion?.let { SemanticVersion.parse(it) } ?: SemanticVersion.release() - conf.yarnClassifier = if (dataProvider?.yarnVersions?.firstOrNull { it.name == yarnVersion }?.hasV2Mappings == false) null else "v2" + val yarnVersionObj = dataProvider?.yarnVersions?.firstOrNull { it.name == yarnVersion } + conf.yarnClassifier = if (yarnVersionObj?.hasV2Mappings == false) { + null + } else { + "v2" + } conf.mcVersion = mcVersion ?: "" - conf.semanticMcVersion = dataProvider?.getNormalizedMinecraftVersion(mcVersion)?.normalized?.let { SemanticVersion.parse(it) } ?: SemanticVersion.release() + val normalizedMcVersion = dataProvider?.getNormalizedMinecraftVersion(mcVersion)?.normalized + conf.semanticMcVersion = normalizedMcVersion?.let { SemanticVersion.parse(it) } ?: SemanticVersion.release() val loaderVer = loaderVersion - if (loaderVer != null) + if (loaderVer != null) { conf.loaderVersion = SemanticVersion.parse(loaderVer) - val api = if (useFabricApiCheckbox.isSelected) dataProvider?.fabricApiVersions?.firstOrNull { it.name == fabricApiVersion } else null + } + val api = if (useFabricApiCheckbox.isSelected) { + dataProvider?.fabricApiVersions?.firstOrNull { it.name == fabricApiVersion } + } else { + null + } conf.apiVersion = api?.mavenVersion?.let { SemanticVersion.parse(it) } conf.apiMavenLocation = api?.mavenLocation conf.gradleVersion = when (dataProvider?.loomVersions?.firstOrNull { it.name == loomVersion }?.gradle) { @@ -214,8 +251,9 @@ class FabricProjectSettingsWizard(private val creator: MinecraftProjectCreator) else -> SemanticVersion.release(5, 5, 1) } val loomVer = loomVersion - if (loomVer != null) + if (loomVer != null) { conf.loomVersion = SemanticVersion.parse(loomVer) + } conf.environment = when ((environmentBox.selectedItem as? String)?.toLowerCase(Locale.ROOT)) { "client" -> Side.CLIENT "server" -> Side.SERVER @@ -245,12 +283,13 @@ class FabricProjectSettingsWizard(private val creator: MinecraftProjectCreator) } private suspend fun downloadVersions(): DataProvider? = coroutineScope { + // prefetch the data val dataProvider = DataProvider() - val minecraftVersionJob = async(Dispatchers.IO) { try { dataProvider.minecraftVersions } catch (e: IOException) { null } } - val fabricApiVersionJob = async(Dispatchers.IO) { try { dataProvider.fabricApiVersions } catch (e: IOException) { null } } - val yarnVersionJob = async(Dispatchers.IO) { try { dataProvider.yarnVersions } catch (e: IOException) { null } } - val loomVersionJob = async(Dispatchers.IO) { try { dataProvider.loomVersions } catch (e: IOException) { null } } - val loaderVersionJob = async(Dispatchers.IO) { try { dataProvider.loaderVersions } catch (e: IOException) { null } } + val minecraftVersionJob = async(Dispatchers.IO) { runCatching { dataProvider.minecraftVersions }.getOrNull() } + val fabricApiVersionJob = async(Dispatchers.IO) { runCatching { dataProvider.fabricApiVersions }.getOrNull() } + val yarnVersionJob = async(Dispatchers.IO) { runCatching { dataProvider.yarnVersions }.getOrNull() } + val loomVersionJob = async(Dispatchers.IO) { runCatching { dataProvider.loomVersions }.getOrNull() } + val loaderVersionJob = async(Dispatchers.IO) { runCatching { dataProvider.loaderVersions }.getOrNull() } minecraftVersionJob.await() ?: return@coroutineScope null fabricApiVersionJob.await() ?: return@coroutineScope null @@ -371,7 +410,12 @@ class FabricProjectSettingsWizard(private val creator: MinecraftProjectCreator) } private fun parseEntryPointType(value: Any?): EntryPoint.Type { - return value as? EntryPoint.Type ?: EntryPoint.Type.values().firstOrNull { it.name.equals(value.toString(), ignoreCase = true) } ?: EntryPoint.Type.CLASS + return when (value) { + is EntryPoint.Type -> value + else -> enumValues().firstOrNull { + it.name.equals(value.toString(), ignoreCase = true) + } ?: EntryPoint.Type.CLASS + } } override fun removeRow(idx: Int) { @@ -396,5 +440,4 @@ class FabricProjectSettingsWizard(private val creator: MinecraftProjectCreator) } } } - } diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/sponge/creator/SpongeProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/platform/sponge/creator/SpongeProjectCreator.kt index 5ddbc7f41..19792d0a3 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/sponge/creator/SpongeProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/sponge/creator/SpongeProjectCreator.kt @@ -18,10 +18,10 @@ import com.demonwav.mcdev.creator.buildsystem.BuildRepository import com.demonwav.mcdev.creator.buildsystem.BuildSystem import com.demonwav.mcdev.creator.buildsystem.BuildSystemType import com.demonwav.mcdev.creator.buildsystem.gradle.BasicGradleFinalizerStep -import com.demonwav.mcdev.creator.buildsystem.gradle.GradleSetupStep import com.demonwav.mcdev.creator.buildsystem.gradle.GradleBuildSystem import com.demonwav.mcdev.creator.buildsystem.gradle.GradleFiles import com.demonwav.mcdev.creator.buildsystem.gradle.GradleGitignoreStep +import com.demonwav.mcdev.creator.buildsystem.gradle.GradleSetupStep import com.demonwav.mcdev.creator.buildsystem.gradle.GradleWrapperStep import com.demonwav.mcdev.creator.buildsystem.maven.BasicMavenFinalizerStep import com.demonwav.mcdev.creator.buildsystem.maven.BasicMavenStep diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/velocity/creator/VelocityProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/platform/velocity/creator/VelocityProjectCreator.kt index 0c4e0147c..d7d487359 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/velocity/creator/VelocityProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/velocity/creator/VelocityProjectCreator.kt @@ -17,10 +17,10 @@ import com.demonwav.mcdev.creator.buildsystem.BuildDependency import com.demonwav.mcdev.creator.buildsystem.BuildRepository import com.demonwav.mcdev.creator.buildsystem.BuildSystem import com.demonwav.mcdev.creator.buildsystem.gradle.BasicGradleFinalizerStep -import com.demonwav.mcdev.creator.buildsystem.gradle.GradleSetupStep import com.demonwav.mcdev.creator.buildsystem.gradle.GradleBuildSystem import com.demonwav.mcdev.creator.buildsystem.gradle.GradleFiles import com.demonwav.mcdev.creator.buildsystem.gradle.GradleGitignoreStep +import com.demonwav.mcdev.creator.buildsystem.gradle.GradleSetupStep import com.demonwav.mcdev.creator.buildsystem.gradle.GradleWrapperStep import com.demonwav.mcdev.creator.buildsystem.maven.BasicMavenFinalizerStep import com.demonwav.mcdev.creator.buildsystem.maven.BasicMavenStep diff --git a/src/main/kotlin/com/demonwav/mcdev/util/MinecraftTemplates.kt b/src/main/kotlin/com/demonwav/mcdev/util/MinecraftTemplates.kt index 2f5920786..609af3b20 100644 --- a/src/main/kotlin/com/demonwav/mcdev/util/MinecraftTemplates.kt +++ b/src/main/kotlin/com/demonwav/mcdev/util/MinecraftTemplates.kt @@ -86,7 +86,9 @@ class MinecraftTemplates : FileTemplateGroupDescriptorFactory { FileTemplateGroupDescriptor("Fabric", PlatformAssets.FABRIC_ICON).let { fabricGroup -> group.addTemplate(fabricGroup) fabricGroup.addTemplate(FileTemplateDescriptor(FABRIC_BUILD_GRADLE_TEMPLATE, PlatformAssets.FABRIC_ICON)) - fabricGroup.addTemplate(FileTemplateDescriptor(FABRIC_GRADLE_PROPERTIES_TEMPLATE, PlatformAssets.FABRIC_ICON)) + fabricGroup.addTemplate( + FileTemplateDescriptor(FABRIC_GRADLE_PROPERTIES_TEMPLATE, PlatformAssets.FABRIC_ICON) + ) fabricGroup.addTemplate(FileTemplateDescriptor(FABRIC_MIXINS_JSON_TEMPLATE, PlatformAssets.FABRIC_ICON)) fabricGroup.addTemplate(FileTemplateDescriptor(FABRIC_MOD_JSON_TEMPLATE, PlatformAssets.FABRIC_ICON)) fabricGroup.addTemplate(FileTemplateDescriptor(FABRIC_SETTINGS_GRADLE_TEMPLATE, PlatformAssets.FABRIC_ICON)) From 376c4795a45f5f09395cc6ff7b8590f931f264a5 Mon Sep 17 00:00:00 2001 From: Joe Date: Tue, 30 Jun 2020 17:29:20 +0100 Subject: [PATCH 06/23] Fix license headers in template descriptions --- .../j2ee/fabric/fabric_build.gradle.html | 14 +++++++------- .../j2ee/fabric/fabric_gradle.properties.html | 14 +++++++------- .../j2ee/fabric/fabric_mixins.json.html | 14 +++++++------- .../fileTemplates/j2ee/fabric/fabric_mod.json.html | 14 +++++++------- .../j2ee/fabric/fabric_settings.gradle.html | 14 +++++++------- .../fileTemplates/j2ee/licenses/AGPL-3.0.html | 14 +++++++------- .../j2ee/licenses/All-Rights-Reserved.html | 14 +++++++------- .../fileTemplates/j2ee/licenses/Apache-2.0.html | 14 +++++++------- .../j2ee/licenses/BSD-2-Clause-FreeBSD.html | 14 +++++++------- .../fileTemplates/j2ee/licenses/BSD-3-Clause.html | 14 +++++++------- .../fileTemplates/j2ee/licenses/GPL-3.0.html | 14 +++++++------- .../resources/fileTemplates/j2ee/licenses/ISC.html | 14 +++++++------- .../fileTemplates/j2ee/licenses/LGPL-3.0.html | 14 +++++++------- .../resources/fileTemplates/j2ee/licenses/MIT.html | 14 +++++++------- .../fileTemplates/j2ee/licenses/MPL-2.0.html | 14 +++++++------- .../fileTemplates/j2ee/licenses/unlicense.html | 14 +++++++------- 16 files changed, 112 insertions(+), 112 deletions(-) diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_build.gradle.html b/src/main/resources/fileTemplates/j2ee/fabric/fabric_build.gradle.html index c30a35880..a8e3eebe4 100644 --- a/src/main/resources/fileTemplates/j2ee/fabric/fabric_build.gradle.html +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_build.gradle.html @@ -1,11 +1,11 @@ diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_gradle.properties.html b/src/main/resources/fileTemplates/j2ee/fabric/fabric_gradle.properties.html index d12192ef3..a6843cd83 100644 --- a/src/main/resources/fileTemplates/j2ee/fabric/fabric_gradle.properties.html +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_gradle.properties.html @@ -1,11 +1,11 @@ diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_mixins.json.html b/src/main/resources/fileTemplates/j2ee/fabric/fabric_mixins.json.html index 15e52be74..f3eed5305 100644 --- a/src/main/resources/fileTemplates/j2ee/fabric/fabric_mixins.json.html +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_mixins.json.html @@ -1,11 +1,11 @@ diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_mod.json.html b/src/main/resources/fileTemplates/j2ee/fabric/fabric_mod.json.html index ac57601a3..53e59684b 100644 --- a/src/main/resources/fileTemplates/j2ee/fabric/fabric_mod.json.html +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_mod.json.html @@ -1,11 +1,11 @@ diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_settings.gradle.html b/src/main/resources/fileTemplates/j2ee/fabric/fabric_settings.gradle.html index f574a71c9..4e318ea0e 100644 --- a/src/main/resources/fileTemplates/j2ee/fabric/fabric_settings.gradle.html +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_settings.gradle.html @@ -1,11 +1,11 @@ diff --git a/src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.html b/src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.html index 338d7e8bc..11ae478a3 100644 --- a/src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.html +++ b/src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.html @@ -1,11 +1,11 @@ diff --git a/src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.html b/src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.html index fa47a7ada..ba99590fe 100644 --- a/src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.html +++ b/src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.html @@ -1,11 +1,11 @@ diff --git a/src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.html b/src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.html index ddbd7806c..eeec74738 100644 --- a/src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.html +++ b/src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.html @@ -1,11 +1,11 @@ diff --git a/src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.html b/src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.html index 137767fdd..7f321abaa 100644 --- a/src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.html +++ b/src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.html @@ -1,11 +1,11 @@ diff --git a/src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.html b/src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.html index 92accb22f..d0cbb0b24 100644 --- a/src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.html +++ b/src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.html @@ -1,11 +1,11 @@ diff --git a/src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.html b/src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.html index 93c597961..373611465 100644 --- a/src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.html +++ b/src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.html @@ -1,11 +1,11 @@ diff --git a/src/main/resources/fileTemplates/j2ee/licenses/ISC.html b/src/main/resources/fileTemplates/j2ee/licenses/ISC.html index a0ddabc37..8c62d4668 100644 --- a/src/main/resources/fileTemplates/j2ee/licenses/ISC.html +++ b/src/main/resources/fileTemplates/j2ee/licenses/ISC.html @@ -1,11 +1,11 @@ diff --git a/src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.html b/src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.html index 2e411a0c1..d5b2ac939 100644 --- a/src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.html +++ b/src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.html @@ -1,11 +1,11 @@ diff --git a/src/main/resources/fileTemplates/j2ee/licenses/MIT.html b/src/main/resources/fileTemplates/j2ee/licenses/MIT.html index daaaba82d..2470ebd26 100644 --- a/src/main/resources/fileTemplates/j2ee/licenses/MIT.html +++ b/src/main/resources/fileTemplates/j2ee/licenses/MIT.html @@ -1,11 +1,11 @@ diff --git a/src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.html b/src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.html index fd3f2a399..5f141ff21 100644 --- a/src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.html +++ b/src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.html @@ -1,11 +1,11 @@ diff --git a/src/main/resources/fileTemplates/j2ee/licenses/unlicense.html b/src/main/resources/fileTemplates/j2ee/licenses/unlicense.html index 43a3b493c..8c2f384f2 100644 --- a/src/main/resources/fileTemplates/j2ee/licenses/unlicense.html +++ b/src/main/resources/fileTemplates/j2ee/licenses/unlicense.html @@ -1,11 +1,11 @@ From 7cd3388b73380cbc27a17f3dd746bab0f5f1c87f Mon Sep 17 00:00:00 2001 From: Joe Date: Tue, 30 Jun 2020 17:38:29 +0100 Subject: [PATCH 07/23] Fix template licenses again --- .../fileTemplates/j2ee/fabric/fabric_build.gradle.html | 2 +- .../fileTemplates/j2ee/fabric/fabric_gradle.properties.html | 2 +- .../resources/fileTemplates/j2ee/fabric/fabric_mixins.json.html | 2 +- .../resources/fileTemplates/j2ee/fabric/fabric_mod.json.html | 2 +- .../fileTemplates/j2ee/fabric/fabric_settings.gradle.html | 2 +- src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.html | 2 +- .../fileTemplates/j2ee/licenses/All-Rights-Reserved.html | 2 +- src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.html | 2 +- .../fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.html | 2 +- .../resources/fileTemplates/j2ee/licenses/BSD-3-Clause.html | 2 +- src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.html | 2 +- src/main/resources/fileTemplates/j2ee/licenses/ISC.html | 2 +- src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.html | 2 +- src/main/resources/fileTemplates/j2ee/licenses/MIT.html | 2 +- src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.html | 2 +- src/main/resources/fileTemplates/j2ee/licenses/unlicense.html | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_build.gradle.html b/src/main/resources/fileTemplates/j2ee/fabric/fabric_build.gradle.html index a8e3eebe4..821eac96b 100644 --- a/src/main/resources/fileTemplates/j2ee/fabric/fabric_build.gradle.html +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_build.gradle.html @@ -6,7 +6,7 @@ Copyright (c) 2020 minecraft-dev MIT License - --> +--> diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_gradle.properties.html b/src/main/resources/fileTemplates/j2ee/fabric/fabric_gradle.properties.html index a6843cd83..933d4037f 100644 --- a/src/main/resources/fileTemplates/j2ee/fabric/fabric_gradle.properties.html +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_gradle.properties.html @@ -6,7 +6,7 @@ Copyright (c) 2020 minecraft-dev MIT License - --> +--> diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_mixins.json.html b/src/main/resources/fileTemplates/j2ee/fabric/fabric_mixins.json.html index f3eed5305..64508a518 100644 --- a/src/main/resources/fileTemplates/j2ee/fabric/fabric_mixins.json.html +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_mixins.json.html @@ -6,7 +6,7 @@ Copyright (c) 2020 minecraft-dev MIT License - --> +--> diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_mod.json.html b/src/main/resources/fileTemplates/j2ee/fabric/fabric_mod.json.html index 53e59684b..b67b9237d 100644 --- a/src/main/resources/fileTemplates/j2ee/fabric/fabric_mod.json.html +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_mod.json.html @@ -6,7 +6,7 @@ Copyright (c) 2020 minecraft-dev MIT License - --> +--> diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_settings.gradle.html b/src/main/resources/fileTemplates/j2ee/fabric/fabric_settings.gradle.html index 4e318ea0e..195edfae1 100644 --- a/src/main/resources/fileTemplates/j2ee/fabric/fabric_settings.gradle.html +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_settings.gradle.html @@ -6,7 +6,7 @@ Copyright (c) 2020 minecraft-dev MIT License - --> +--> diff --git a/src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.html b/src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.html index 11ae478a3..0213cb8ac 100644 --- a/src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.html +++ b/src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.html @@ -6,7 +6,7 @@ Copyright (c) 2020 minecraft-dev MIT License - --> +--> diff --git a/src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.html b/src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.html index ba99590fe..b5167b9d7 100644 --- a/src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.html +++ b/src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.html @@ -6,7 +6,7 @@ Copyright (c) 2020 minecraft-dev MIT License - --> +--> diff --git a/src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.html b/src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.html index eeec74738..346328ba3 100644 --- a/src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.html +++ b/src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.html @@ -6,7 +6,7 @@ Copyright (c) 2020 minecraft-dev MIT License - --> +--> diff --git a/src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.html b/src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.html index 7f321abaa..9ea965172 100644 --- a/src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.html +++ b/src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.html @@ -6,7 +6,7 @@ Copyright (c) 2020 minecraft-dev MIT License - --> +--> diff --git a/src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.html b/src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.html index d0cbb0b24..07273520e 100644 --- a/src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.html +++ b/src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.html @@ -6,7 +6,7 @@ Copyright (c) 2020 minecraft-dev MIT License - --> +--> diff --git a/src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.html b/src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.html index 373611465..8bcbb6312 100644 --- a/src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.html +++ b/src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.html @@ -6,7 +6,7 @@ Copyright (c) 2020 minecraft-dev MIT License - --> +--> diff --git a/src/main/resources/fileTemplates/j2ee/licenses/ISC.html b/src/main/resources/fileTemplates/j2ee/licenses/ISC.html index 8c62d4668..29b915f49 100644 --- a/src/main/resources/fileTemplates/j2ee/licenses/ISC.html +++ b/src/main/resources/fileTemplates/j2ee/licenses/ISC.html @@ -6,7 +6,7 @@ Copyright (c) 2020 minecraft-dev MIT License - --> +--> diff --git a/src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.html b/src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.html index d5b2ac939..806dad53d 100644 --- a/src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.html +++ b/src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.html @@ -6,7 +6,7 @@ Copyright (c) 2020 minecraft-dev MIT License - --> +--> diff --git a/src/main/resources/fileTemplates/j2ee/licenses/MIT.html b/src/main/resources/fileTemplates/j2ee/licenses/MIT.html index 2470ebd26..20bcaa5df 100644 --- a/src/main/resources/fileTemplates/j2ee/licenses/MIT.html +++ b/src/main/resources/fileTemplates/j2ee/licenses/MIT.html @@ -6,7 +6,7 @@ Copyright (c) 2020 minecraft-dev MIT License - --> +--> diff --git a/src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.html b/src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.html index 5f141ff21..66ae5beb4 100644 --- a/src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.html +++ b/src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.html @@ -6,7 +6,7 @@ Copyright (c) 2020 minecraft-dev MIT License - --> +--> diff --git a/src/main/resources/fileTemplates/j2ee/licenses/unlicense.html b/src/main/resources/fileTemplates/j2ee/licenses/unlicense.html index 8c2f384f2..029099e81 100644 --- a/src/main/resources/fileTemplates/j2ee/licenses/unlicense.html +++ b/src/main/resources/fileTemplates/j2ee/licenses/unlicense.html @@ -6,7 +6,7 @@ Copyright (c) 2020 minecraft-dev MIT License - --> +--> From 49f6c0742d999566b7a5d9730fa6cef0ea205e03 Mon Sep 17 00:00:00 2001 From: Joe Date: Tue, 30 Jun 2020 17:59:19 +0100 Subject: [PATCH 08/23] Fix formatting again --- .../fabric/creator/FabricProjectCreator.kt | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt index b7d6db473..21b2c1d21 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt @@ -18,9 +18,9 @@ import com.demonwav.mcdev.creator.buildsystem.gradle.GradleBuildSystem import com.demonwav.mcdev.creator.buildsystem.gradle.GradleFiles import com.demonwav.mcdev.creator.buildsystem.gradle.GradleGitignoreStep import com.demonwav.mcdev.creator.buildsystem.gradle.GradleWrapperStep +import com.demonwav.mcdev.creator.buildsystem.gradle.SimpleGradleSetupStep import com.demonwav.mcdev.platform.fabric.EntryPoint import com.demonwav.mcdev.platform.fabric.util.FabricConstants -import com.demonwav.mcdev.creator.buildsystem.gradle.SimpleGradleSetupStep import com.demonwav.mcdev.util.License import com.demonwav.mcdev.util.addImplements import com.demonwav.mcdev.util.addMethod @@ -66,7 +66,7 @@ class FabricProjectCreator( private val rootModule: Module, private val buildSystem: GradleBuildSystem, private val config: FabricProjectConfig -): BaseProjectCreator(rootModule, buildSystem) { +) : BaseProjectCreator(rootModule, buildSystem) { override fun getSingleModuleSteps(): Iterable { val buildText = FabricTemplate.applyBuildGradle(project, buildSystem, config) @@ -104,7 +104,6 @@ class FabricProjectCreator( override fun getMultiModuleSteps(projectBaseDir: Path): Iterable { TODO("Not yet implemented") } - } class GenSourcesStep( @@ -295,8 +294,9 @@ class CreateEntryPointStep( .sortedBy { it.key } val entryPointsByMethodNameAndSig = entryPoints .filter { it.type == EntryPoint.Type.METHOD } - .groupBy {entryPoint -> - val functionalMethod = findFunctionalMethod(clazz, entryPoint.interfaceName) ?: return@groupBy null + .groupBy { entryPoint -> + val functionalMethod = findFunctionalMethod(clazz, entryPoint.interfaceName) + ?: return@groupBy null val paramTypes = functionalMethod.parameterList.parameters.map { it.type.canonicalText } (entryPoint.methodName ?: functionalMethod.name) to paramTypes } @@ -305,7 +305,6 @@ class CreateEntryPointStep( .map { it.key!! to it.value } .sortedBy { it.first.first } - val elementFactory = JavaPsiFacade.getElementFactory(project) var isClientClass = false @@ -391,9 +390,9 @@ class CreateEntryPointStep( ) { val elementFactory = JavaPsiFacade.getElementFactory(project) val annotationText = "@${FabricConstants.ENVIRONMENT_INTERFACE_ANNOTATION}(" + - "value=${FabricConstants.ENV_TYPE}.$envType," + - "itf=$interfaceQualifiedName.class" + - ")" + "value=${FabricConstants.ENV_TYPE}.$envType," + + "itf=$interfaceQualifiedName.class" + + ")" val annotation = elementFactory.createAnnotationFromText(annotationText, owner) AddAnnotationFix(FabricConstants.ENVIRONMENT_INTERFACE_ANNOTATION, owner, annotation.parameterList.attributes) .applyFix() @@ -419,8 +418,8 @@ class CreateEntryPointStep( } val functionalMethods = interfaceClass.allMethods .filter { - !it.hasModifierProperty(PsiModifier.STATIC) - && !it.hasModifierProperty(PsiModifier.DEFAULT) + !it.hasModifierProperty(PsiModifier.STATIC) && + !it.hasModifierProperty(PsiModifier.DEFAULT) } return if (functionalMethods.size != 1) { null From e8912351e5f6da2e07eeaf509be147614a42f78f Mon Sep 17 00:00:00 2001 From: Joe Date: Wed, 1 Jul 2020 10:53:57 +0100 Subject: [PATCH 09/23] Fix licenses not being written --- .../mcdev/platform/fabric/creator/FabricProjectCreator.kt | 4 ++-- .../demonwav/mcdev/platform/fabric/creator/FabricTemplate.kt | 2 +- .../j2ee/licenses/{AGPL-3.0.ft => AGPL-3.0.txt.ft} | 0 .../j2ee/licenses/{AGPL-3.0.html => AGPL-3.0.txt.html} | 0 .../{All-Rights-Reserved.ft => All-Rights-Reserved.txt.ft} | 0 ...{All-Rights-Reserved.html => All-Rights-Reserved.txt.html} | 0 .../j2ee/licenses/{Apache-2.0.ft => Apache-2.0.txt.ft} | 0 .../j2ee/licenses/{Apache-2.0.html => Apache-2.0.txt.html} | 0 .../{BSD-2-Clause-FreeBSD.ft => BSD-2-Clause-FreeBSD.txt.ft} | 0 ...SD-2-Clause-FreeBSD.html => BSD-2-Clause-FreeBSD.txt.html} | 0 .../j2ee/licenses/{BSD-3-Clause.ft => BSD-3-Clause.txt.ft} | 0 .../licenses/{BSD-3-Clause.html => BSD-3-Clause.txt.html} | 0 .../j2ee/licenses/{GPL-3.0.ft => GPL-3.0.txt.ft} | 0 .../j2ee/licenses/{GPL-3.0.html => GPL-3.0.txt.html} | 0 .../fileTemplates/j2ee/licenses/{ISC.ft => ISC.txt.ft} | 0 .../fileTemplates/j2ee/licenses/{ISC.html => ISC.txt.html} | 0 .../j2ee/licenses/{LGPL-3.0.ft => LGPL-3.0.txt.ft} | 0 .../j2ee/licenses/{LGPL-3.0.html => LGPL-3.0.txt.html} | 0 .../fileTemplates/j2ee/licenses/{MIT.ft => MIT.txt.ft} | 0 .../fileTemplates/j2ee/licenses/{MIT.html => MIT.txt.html} | 0 .../j2ee/licenses/{MPL-2.0.ft => MPL-2.0.txt.ft} | 0 .../j2ee/licenses/{MPL-2.0.html => MPL-2.0.txt.html} | 0 .../j2ee/licenses/{unlicense.ft => unlicense.txt.ft} | 0 .../j2ee/licenses/{unlicense.html => unlicense.txt.html} | 0 24 files changed, 3 insertions(+), 3 deletions(-) rename src/main/resources/fileTemplates/j2ee/licenses/{AGPL-3.0.ft => AGPL-3.0.txt.ft} (100%) rename src/main/resources/fileTemplates/j2ee/licenses/{AGPL-3.0.html => AGPL-3.0.txt.html} (100%) rename src/main/resources/fileTemplates/j2ee/licenses/{All-Rights-Reserved.ft => All-Rights-Reserved.txt.ft} (100%) rename src/main/resources/fileTemplates/j2ee/licenses/{All-Rights-Reserved.html => All-Rights-Reserved.txt.html} (100%) rename src/main/resources/fileTemplates/j2ee/licenses/{Apache-2.0.ft => Apache-2.0.txt.ft} (100%) rename src/main/resources/fileTemplates/j2ee/licenses/{Apache-2.0.html => Apache-2.0.txt.html} (100%) rename src/main/resources/fileTemplates/j2ee/licenses/{BSD-2-Clause-FreeBSD.ft => BSD-2-Clause-FreeBSD.txt.ft} (100%) rename src/main/resources/fileTemplates/j2ee/licenses/{BSD-2-Clause-FreeBSD.html => BSD-2-Clause-FreeBSD.txt.html} (100%) rename src/main/resources/fileTemplates/j2ee/licenses/{BSD-3-Clause.ft => BSD-3-Clause.txt.ft} (100%) rename src/main/resources/fileTemplates/j2ee/licenses/{BSD-3-Clause.html => BSD-3-Clause.txt.html} (100%) rename src/main/resources/fileTemplates/j2ee/licenses/{GPL-3.0.ft => GPL-3.0.txt.ft} (100%) rename src/main/resources/fileTemplates/j2ee/licenses/{GPL-3.0.html => GPL-3.0.txt.html} (100%) rename src/main/resources/fileTemplates/j2ee/licenses/{ISC.ft => ISC.txt.ft} (100%) rename src/main/resources/fileTemplates/j2ee/licenses/{ISC.html => ISC.txt.html} (100%) rename src/main/resources/fileTemplates/j2ee/licenses/{LGPL-3.0.ft => LGPL-3.0.txt.ft} (100%) rename src/main/resources/fileTemplates/j2ee/licenses/{LGPL-3.0.html => LGPL-3.0.txt.html} (100%) rename src/main/resources/fileTemplates/j2ee/licenses/{MIT.ft => MIT.txt.ft} (100%) rename src/main/resources/fileTemplates/j2ee/licenses/{MIT.html => MIT.txt.html} (100%) rename src/main/resources/fileTemplates/j2ee/licenses/{MPL-2.0.ft => MPL-2.0.txt.ft} (100%) rename src/main/resources/fileTemplates/j2ee/licenses/{MPL-2.0.html => MPL-2.0.txt.html} (100%) rename src/main/resources/fileTemplates/j2ee/licenses/{unlicense.ft => unlicense.txt.ft} (100%) rename src/main/resources/fileTemplates/j2ee/licenses/{unlicense.html => unlicense.txt.html} (100%) diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt index 21b2c1d21..d3a19cafa 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt @@ -250,8 +250,6 @@ class CreateEntryPointStep( } val className = qualifiedClassName.substring(dotIndex + 1) - indicator.text = "Writing class: $className" - var directory = dirs.sourceDirectory for (part in packageName.split(".")) { directory = directory.resolve(part) @@ -263,6 +261,8 @@ class CreateEntryPointStep( val virtualDir = directory.virtualFile ?: return project.runWriteTaskInSmartMode { + indicator.text = "Writing class: $className" + val psiDir = PsiManager.getInstance(project).findDirectory(virtualDir) ?: return@runWriteTaskInSmartMode val clazz = try { JavaDirectoryService.getInstance().createClass(psiDir, className) diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricTemplate.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricTemplate.kt index e9f9e24be..60566aa78 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricTemplate.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricTemplate.kt @@ -85,7 +85,7 @@ object FabricTemplate : BaseTemplate() { "YEAR" to ZonedDateTime.now().year.toString(), "AUTHOR" to config.authors.joinToString(", ") ) - return project.applyTemplate(license.id, props) + return project.applyTemplate("${license.id}.txt", props) } fun applyFabricModJsonTemplate( diff --git a/src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.ft b/src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.txt.ft similarity index 100% rename from src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.ft rename to src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.txt.ft diff --git a/src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.html b/src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.txt.html similarity index 100% rename from src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.html rename to src/main/resources/fileTemplates/j2ee/licenses/AGPL-3.0.txt.html diff --git a/src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.ft b/src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.txt.ft similarity index 100% rename from src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.ft rename to src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.txt.ft diff --git a/src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.html b/src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.txt.html similarity index 100% rename from src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.html rename to src/main/resources/fileTemplates/j2ee/licenses/All-Rights-Reserved.txt.html diff --git a/src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.ft b/src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.txt.ft similarity index 100% rename from src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.ft rename to src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.txt.ft diff --git a/src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.html b/src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.txt.html similarity index 100% rename from src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.html rename to src/main/resources/fileTemplates/j2ee/licenses/Apache-2.0.txt.html diff --git a/src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.ft b/src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.txt.ft similarity index 100% rename from src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.ft rename to src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.txt.ft diff --git a/src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.html b/src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.txt.html similarity index 100% rename from src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.html rename to src/main/resources/fileTemplates/j2ee/licenses/BSD-2-Clause-FreeBSD.txt.html diff --git a/src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.ft b/src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.txt.ft similarity index 100% rename from src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.ft rename to src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.txt.ft diff --git a/src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.html b/src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.txt.html similarity index 100% rename from src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.html rename to src/main/resources/fileTemplates/j2ee/licenses/BSD-3-Clause.txt.html diff --git a/src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.ft b/src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.txt.ft similarity index 100% rename from src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.ft rename to src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.txt.ft diff --git a/src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.html b/src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.txt.html similarity index 100% rename from src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.html rename to src/main/resources/fileTemplates/j2ee/licenses/GPL-3.0.txt.html diff --git a/src/main/resources/fileTemplates/j2ee/licenses/ISC.ft b/src/main/resources/fileTemplates/j2ee/licenses/ISC.txt.ft similarity index 100% rename from src/main/resources/fileTemplates/j2ee/licenses/ISC.ft rename to src/main/resources/fileTemplates/j2ee/licenses/ISC.txt.ft diff --git a/src/main/resources/fileTemplates/j2ee/licenses/ISC.html b/src/main/resources/fileTemplates/j2ee/licenses/ISC.txt.html similarity index 100% rename from src/main/resources/fileTemplates/j2ee/licenses/ISC.html rename to src/main/resources/fileTemplates/j2ee/licenses/ISC.txt.html diff --git a/src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.ft b/src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.txt.ft similarity index 100% rename from src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.ft rename to src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.txt.ft diff --git a/src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.html b/src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.txt.html similarity index 100% rename from src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.html rename to src/main/resources/fileTemplates/j2ee/licenses/LGPL-3.0.txt.html diff --git a/src/main/resources/fileTemplates/j2ee/licenses/MIT.ft b/src/main/resources/fileTemplates/j2ee/licenses/MIT.txt.ft similarity index 100% rename from src/main/resources/fileTemplates/j2ee/licenses/MIT.ft rename to src/main/resources/fileTemplates/j2ee/licenses/MIT.txt.ft diff --git a/src/main/resources/fileTemplates/j2ee/licenses/MIT.html b/src/main/resources/fileTemplates/j2ee/licenses/MIT.txt.html similarity index 100% rename from src/main/resources/fileTemplates/j2ee/licenses/MIT.html rename to src/main/resources/fileTemplates/j2ee/licenses/MIT.txt.html diff --git a/src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.ft b/src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.txt.ft similarity index 100% rename from src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.ft rename to src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.txt.ft diff --git a/src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.html b/src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.txt.html similarity index 100% rename from src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.html rename to src/main/resources/fileTemplates/j2ee/licenses/MPL-2.0.txt.html diff --git a/src/main/resources/fileTemplates/j2ee/licenses/unlicense.ft b/src/main/resources/fileTemplates/j2ee/licenses/unlicense.txt.ft similarity index 100% rename from src/main/resources/fileTemplates/j2ee/licenses/unlicense.ft rename to src/main/resources/fileTemplates/j2ee/licenses/unlicense.txt.ft diff --git a/src/main/resources/fileTemplates/j2ee/licenses/unlicense.html b/src/main/resources/fileTemplates/j2ee/licenses/unlicense.txt.html similarity index 100% rename from src/main/resources/fileTemplates/j2ee/licenses/unlicense.html rename to src/main/resources/fileTemplates/j2ee/licenses/unlicense.txt.html From d10d8637acff557d999fc811a3e2f1a1a3a69e83 Mon Sep 17 00:00:00 2001 From: Joe Date: Wed, 1 Jul 2020 12:12:12 +0100 Subject: [PATCH 10/23] Fix dropdown for entrypoint type column --- .../platform/fabric/creator/FabricProjectSettingsWizard.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt index 1c77391db..a2bb6135c 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt @@ -30,6 +30,7 @@ import com.intellij.ui.CollectionComboBoxModel import com.intellij.ui.ToolbarDecorator import com.intellij.ui.table.JBTable import com.intellij.util.ui.EditableModel +import com.intellij.util.ui.table.ComboBoxTableCellEditor import java.awt.event.ActionListener import java.awt.event.ComponentAdapter import java.awt.event.ComponentEvent @@ -107,6 +108,7 @@ class FabricProjectSettingsWizard(private val creator: MinecraftProjectCreator) tableModel = EntryPointTableModel(entryPoints) val entryPointsTable = JBTable(tableModel) + entryPointsTable.setDefaultEditor(EntryPoint.Type::class.java, ComboBoxTableCellEditor.INSTANCE) fun resizeColumns() { val model = entryPointsTable.columnModel val totalWidth = model.totalColumnWidth From d4432022f9f3243bd5681ed0bdbb6da2d26f3305 Mon Sep 17 00:00:00 2001 From: Joe Date: Wed, 1 Jul 2020 12:13:24 +0100 Subject: [PATCH 11/23] Fix formatting (again) --- .../mcdev/platform/fabric/creator/FabricProjectCreator.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt index d3a19cafa..3f98efaa8 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt @@ -134,7 +134,9 @@ class LicenseStep( val fileText = FabricTemplate.applyLicenseTemplate(project, license, config) - Files.write(licenseFile, fileText.toByteArray(Charsets.UTF_8), + Files.write( + licenseFile, + fileText.toByteArray(Charsets.UTF_8), StandardOpenOption.CREATE, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING From dd59f84f7ba82e743077d6424cd3cd48f961f336 Mon Sep 17 00:00:00 2001 From: Joe Date: Thu, 2 Jul 2020 13:16:46 +0100 Subject: [PATCH 12/23] Entrypoint fixes --- .../mcdev/platform/fabric/EntryPoint.kt | 37 ++++++++++++++++++- .../fabric/creator/FabricProjectCreator.kt | 36 ++++++------------ 2 files changed, 46 insertions(+), 27 deletions(-) diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/EntryPoint.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/EntryPoint.kt index 8cea2bbc8..39e08d884 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/EntryPoint.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/EntryPoint.kt @@ -11,6 +11,12 @@ package com.demonwav.mcdev.platform.fabric import com.demonwav.mcdev.creator.isValidClassName +import com.intellij.openapi.project.Project +import com.intellij.psi.CommonClassNames +import com.intellij.psi.JavaPsiFacade +import com.intellij.psi.PsiMethod +import com.intellij.psi.PsiModifier +import com.intellij.psi.search.GlobalSearchScope data class EntryPoint( val category: String, @@ -19,14 +25,41 @@ data class EntryPoint( val interfaceName: String, val methodName: String? = null ) { - val reference = when (type) { + private val dumbReference = when (type) { Type.CLASS -> className Type.METHOD -> "$className::$methodName" } val valid by lazy { category.isNotBlank() && isValidClassName(className) && isValidClassName(interfaceName) } - override fun toString() = "$category -> $reference implements $interfaceName" + fun computeReference(project: Project): String { + if (type != Type.METHOD || methodName != null) { + return dumbReference + } + return "$className::${findFunctionalMethod(project)?.name}" + } + + fun findFunctionalMethod(project: Project): PsiMethod? { + val classFinder = JavaPsiFacade.getInstance(project) + val clazz = classFinder.findClass(className, GlobalSearchScope.projectScope(project)) ?: return null + val interfaceClass = classFinder.findClass(interfaceName, clazz.resolveScope) ?: return null + if (!interfaceClass.isInterface) { + return null + } + val candidates = interfaceClass.allMethods + .filter { + !it.hasModifierProperty(PsiModifier.STATIC) && + !it.hasModifierProperty(PsiModifier.DEFAULT) && + it.containingClass?.qualifiedName != CommonClassNames.JAVA_LANG_OBJECT + } + return if (candidates.size == 1) { + candidates[0] + } else { + null + } + } + + override fun toString() = "$category -> $dumbReference implements $interfaceName" enum class Type { CLASS, METHOD diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt index 3f98efaa8..ef8304118 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt @@ -52,7 +52,6 @@ import com.intellij.psi.JavaPsiFacade import com.intellij.psi.PsiClass import com.intellij.psi.PsiFileFactory import com.intellij.psi.PsiManager -import com.intellij.psi.PsiMethod import com.intellij.psi.PsiModifier import com.intellij.psi.PsiModifierListOwner import com.intellij.util.IncorrectOperationException @@ -91,13 +90,13 @@ class FabricProjectCreator( steps += LicenseStep(project, rootDirectory, it, config) } steps += BasicGradleFinalizerStep(rootModule, rootDirectory, buildSystem) - steps += FabricModJsonStep(project, buildSystem, config) if (config.mixins) { steps += MixinConfigStep(project, buildSystem) } for (entry in config.entryPoints.groupBy { it.className }.entries.sortedBy { it.key }) { steps += CreateEntryPointStep(project, buildSystem, entry.key, entry.value) } + steps += FabricModJsonStep(project, buildSystem, config) return steps } @@ -153,7 +152,12 @@ class FabricModJsonStep( override fun runStep(indicator: ProgressIndicator) { val text = FabricTemplate.applyFabricModJsonTemplate(project, buildSystem, config) val dir = buildSystem.dirsOrError.resourceDirectory - runWriteTask { + + indicator.text = "Indexing" + + project.runWriteTaskInSmartMode { + indicator.text = "Creating 'fabric.mod.json'" + val file = PsiFileFactory.getInstance(project).createFileFromText(JsonLanguage.INSTANCE, text) file.runWriteAction { val jsonFile = file as JsonFile @@ -205,7 +209,8 @@ class FabricModJsonStep( if (j != 0) { values.addBefore(generator.createComma(), values.lastChild) } - val value = generator.createStringLiteral(entryPointCategory.value[j].reference) + val entryPointReference = entryPointCategory.value[j].computeReference(project) + val value = generator.createStringLiteral(entryPointReference) values.addBefore(value, values.lastChild) } val key = StringUtil.escapeStringCharacters(entryPointCategory.key) @@ -297,8 +302,7 @@ class CreateEntryPointStep( val entryPointsByMethodNameAndSig = entryPoints .filter { it.type == EntryPoint.Type.METHOD } .groupBy { entryPoint -> - val functionalMethod = findFunctionalMethod(clazz, entryPoint.interfaceName) - ?: return@groupBy null + val functionalMethod = entryPoint.findFunctionalMethod(project) ?: return@groupBy null val paramTypes = functionalMethod.parameterList.parameters.map { it.type.canonicalText } (entryPoint.methodName ?: functionalMethod.name) to paramTypes } @@ -333,7 +337,7 @@ class CreateEntryPointStep( implementAll(clazz, editor) for (eps in entryPointsByMethodNameAndSig) { - val functionalMethod = findFunctionalMethod(clazz, eps.second.first().interfaceName) ?: continue + val functionalMethod = eps.second.first().findFunctionalMethod(project) ?: continue val newMethod = clazz.addMethod(functionalMethod) ?: continue val methodName = eps.first.first newMethod.nameIdentifier?.replace(elementFactory.createIdentifier(methodName)) @@ -411,22 +415,4 @@ class CreateEntryPointStep( true ) } - - private fun findFunctionalMethod(clazz: PsiClass, interfaceName: String): PsiMethod? { - val interfaceClass = JavaPsiFacade.getInstance(project) - .findClass(interfaceName, clazz.resolveScope) ?: return null - if (!interfaceClass.isInterface) { - return null - } - val functionalMethods = interfaceClass.allMethods - .filter { - !it.hasModifierProperty(PsiModifier.STATIC) && - !it.hasModifierProperty(PsiModifier.DEFAULT) - } - return if (functionalMethods.size != 1) { - null - } else { - functionalMethods[0] - } - } } From 1073705579195ab5b947cce37187806d0231262a Mon Sep 17 00:00:00 2001 From: Joe Date: Thu, 2 Jul 2020 15:13:29 +0100 Subject: [PATCH 13/23] Fix formatting of fabric.mod.json --- .../kotlin/com/demonwav/mcdev/creator/MinecraftProjectCreator.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/kotlin/com/demonwav/mcdev/creator/MinecraftProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/creator/MinecraftProjectCreator.kt index c5e3041c6..1065901b5 100644 --- a/src/main/kotlin/com/demonwav/mcdev/creator/MinecraftProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/creator/MinecraftProjectCreator.kt @@ -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 -> From 5010bfd8e2d3429062460e1837ec5cc0c818f093 Mon Sep 17 00:00:00 2001 From: Joe Date: Thu, 2 Jul 2020 18:44:28 +0100 Subject: [PATCH 14/23] fabric.mod.json references and basic validation inspection --- .../UnresolvedReferenceInspection.kt | 60 +++++++++++++++++ .../fabric/reference/EntryPointReference.kt | 67 +++++++++++++++++++ .../reference/FabricReferenceContributor.kt | 53 +++++++++++++++ .../fabric/reference/LicenseReference.kt | 63 +++++++++++++++++ .../fabric/reference/ResourceFileReference.kt | 43 ++++++++++++ src/main/resources/META-INF/plugin.xml | 12 ++++ 6 files changed, 298 insertions(+) create mode 100644 src/main/kotlin/com/demonwav/mcdev/platform/fabric/inspection/UnresolvedReferenceInspection.kt create mode 100644 src/main/kotlin/com/demonwav/mcdev/platform/fabric/reference/EntryPointReference.kt create mode 100644 src/main/kotlin/com/demonwav/mcdev/platform/fabric/reference/FabricReferenceContributor.kt create mode 100644 src/main/kotlin/com/demonwav/mcdev/platform/fabric/reference/LicenseReference.kt create mode 100644 src/main/kotlin/com/demonwav/mcdev/platform/fabric/reference/ResourceFileReference.kt diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/inspection/UnresolvedReferenceInspection.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/inspection/UnresolvedReferenceInspection.kt new file mode 100644 index 000000000..94131950b --- /dev/null +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/inspection/UnresolvedReferenceInspection.kt @@ -0,0 +1,60 @@ +/* + * Minecraft Dev for IntelliJ + * + * https://minecraftdev.org + * + * Copyright (c) 2020 minecraft-dev + * + * MIT License + */ + +package com.demonwav.mcdev.platform.fabric.inspection + +import com.demonwav.mcdev.platform.fabric.util.FabricConstants +import com.demonwav.mcdev.util.reference.InspectionReference +import com.intellij.codeInspection.InspectionManager +import com.intellij.codeInspection.LocalInspectionTool +import com.intellij.codeInspection.ProblemDescriptor +import com.intellij.codeInspection.ProblemHighlightType +import com.intellij.codeInspection.ProblemsHolder +import com.intellij.json.psi.JsonElementVisitor +import com.intellij.json.psi.JsonStringLiteral +import com.intellij.psi.PsiElementVisitor +import com.intellij.psi.PsiFile + +class UnresolvedReferenceInspection : LocalInspectionTool() { + + override fun getStaticDescription() = "Reports unresolved references in Fabric mod JSON files." + + override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor { + if (holder.file.name == FabricConstants.FABRIC_MOD_JSON) { + return Visitor(holder) + } + return PsiElementVisitor.EMPTY_VISITOR + } + + override fun processFile(file: PsiFile, manager: InspectionManager): List { + if (file.name == FabricConstants.FABRIC_MOD_JSON) { + return super.processFile(file, manager) + } + return listOf() + } + + private class Visitor(private val holder: ProblemsHolder) : JsonElementVisitor() { + + override fun visitStringLiteral(literal: JsonStringLiteral) { + for (reference in literal.references) { + if (reference !is InspectionReference) { + continue + } + + if (reference.unresolved) { + holder.registerProblem( + literal, "Cannot resolve ${reference.description}".format(reference.canonicalText), + ProblemHighlightType.LIKE_UNKNOWN_SYMBOL, reference.rangeInElement + ) + } + } + } + } +} diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/reference/EntryPointReference.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/reference/EntryPointReference.kt new file mode 100644 index 000000000..5b4df1505 --- /dev/null +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/reference/EntryPointReference.kt @@ -0,0 +1,67 @@ +/* + * Minecraft Dev for IntelliJ + * + * https://minecraftdev.org + * + * Copyright (c) 2020 minecraft-dev + * + * MIT License + */ + +package com.demonwav.mcdev.platform.fabric.reference + +import com.demonwav.mcdev.util.reference.InspectionReference +import com.intellij.json.psi.JsonStringLiteral +import com.intellij.psi.JavaPsiFacade +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiElementResolveResult +import com.intellij.psi.PsiModifier +import com.intellij.psi.PsiPolyVariantReference +import com.intellij.psi.PsiReference +import com.intellij.psi.PsiReferenceBase +import com.intellij.psi.PsiReferenceProvider +import com.intellij.psi.ResolveResult +import com.intellij.util.ProcessingContext + +object EntryPointReference : PsiReferenceProvider() { + override fun getReferencesByElement(element: PsiElement, context: ProcessingContext): Array { + return arrayOf(Reference(element as JsonStringLiteral)) + } + + private fun resolveReference(element: JsonStringLiteral): Array { + val strReference = element.value + val parts = strReference.split("::", limit = 2) + val clazz = JavaPsiFacade.getInstance(element.project).findClass(parts[0], element.resolveScope) + ?: return PsiElement.EMPTY_ARRAY + if (parts.size == 1) { + return arrayOf(clazz) + } + return clazz.methods.filter { method -> + method.name == parts[1] && + method.hasModifierProperty(PsiModifier.PUBLIC) && + method.hasModifierProperty(PsiModifier.STATIC) + }.toTypedArray() + } + + private class Reference(element: JsonStringLiteral) : + PsiReferenceBase(element), + PsiPolyVariantReference, + InspectionReference { + + override val description = "entry point '%s'" + override val unresolved = resolve() == null + + override fun multiResolve(incompleteCode: Boolean): Array { + return resolveReference(element).map { PsiElementResolveResult(it) }.toTypedArray() + } + + override fun resolve(): PsiElement? { + val results = multiResolve(false) + return if (results.size == 1) { + results[0].element + } else { + null + } + } + } +} diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/reference/FabricReferenceContributor.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/reference/FabricReferenceContributor.kt new file mode 100644 index 000000000..a7ab3dc3c --- /dev/null +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/reference/FabricReferenceContributor.kt @@ -0,0 +1,53 @@ +/* + * Minecraft Dev for IntelliJ + * + * https://minecraftdev.org + * + * Copyright (c) 2020 minecraft-dev + * + * MIT License + */ + +package com.demonwav.mcdev.platform.fabric.reference + +import com.demonwav.mcdev.platform.fabric.util.FabricConstants +import com.demonwav.mcdev.util.isPropertyValue +import com.intellij.json.psi.JsonArray +import com.intellij.json.psi.JsonObject +import com.intellij.json.psi.JsonStringLiteral +import com.intellij.patterns.PlatformPatterns +import com.intellij.psi.PsiReferenceContributor +import com.intellij.psi.PsiReferenceRegistrar + +class FabricReferenceContributor : PsiReferenceContributor() { + override fun registerReferenceProviders(registrar: PsiReferenceRegistrar) { + val stringInModJson = PlatformPatterns.psiElement(JsonStringLiteral::class.java) + .inVirtualFile(PlatformPatterns.virtualFile().withName(FabricConstants.FABRIC_MOD_JSON)) + + val entryPointPattern = stringInModJson.withParent( + PlatformPatterns.psiElement(JsonArray::class.java) + .withSuperParent( + 2, + PlatformPatterns.psiElement(JsonObject::class.java).isPropertyValue("entrypoints") + ) + ) + registrar.registerReferenceProvider(entryPointPattern, EntryPointReference) + + val mixinConfigPattern = stringInModJson.withParent( + PlatformPatterns.psiElement(JsonArray::class.java).isPropertyValue("mixins") + ) + registrar.registerReferenceProvider(mixinConfigPattern, ResourceFileReference("mixin config '%s'")) + + registrar.registerReferenceProvider( + stringInModJson.isPropertyValue("accessWidener"), + ResourceFileReference("access widener '%s'") + ) + + registrar.registerReferenceProvider( + stringInModJson.isPropertyValue("icon"), + ResourceFileReference("icon '%s'") + ) + + registrar.registerReferenceProvider(stringInModJson.isPropertyValue("license"), LicenseReference) + } +} diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/reference/LicenseReference.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/reference/LicenseReference.kt new file mode 100644 index 000000000..a5b0de306 --- /dev/null +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/reference/LicenseReference.kt @@ -0,0 +1,63 @@ +/* + * Minecraft Dev for IntelliJ + * + * https://minecraftdev.org + * + * Copyright (c) 2020 minecraft-dev + * + * MIT License + */ + +package com.demonwav.mcdev.platform.fabric.reference + +import com.demonwav.mcdev.util.reference.InspectionReference +import com.intellij.json.psi.JsonStringLiteral +import com.intellij.openapi.module.ModuleManager +import com.intellij.openapi.project.rootManager +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiElementResolveResult +import com.intellij.psi.PsiManager +import com.intellij.psi.PsiPolyVariantReference +import com.intellij.psi.PsiReference +import com.intellij.psi.PsiReferenceBase +import com.intellij.psi.PsiReferenceProvider +import com.intellij.psi.ResolveResult +import com.intellij.util.ProcessingContext + +object LicenseReference : PsiReferenceProvider() { + override fun getReferencesByElement(element: PsiElement, context: ProcessingContext): Array { + return arrayOf(Reference(element as JsonStringLiteral)) + } + + private class Reference(element: JsonStringLiteral) : + PsiReferenceBase(element), + PsiPolyVariantReference, + InspectionReference { + + override val description = "LICENSE file" + override val unresolved = resolve() == null + + override fun multiResolve(incompleteCode: Boolean): Array { + val modules = ModuleManager.getInstance(element.project).modules + val psiManager = PsiManager.getInstance(element.project) + return modules.flatMap { module -> + module.rootManager.contentRoots.mapNotNull { + val licenseFile = it.findChild("LICENSE") + ?: it.findChild("LICENSE.txt") + ?: return@mapNotNull null + val psiLicenseFile = psiManager.findFile(licenseFile) ?: return@mapNotNull null + PsiElementResolveResult(psiLicenseFile) + } + }.toTypedArray() + } + + override fun resolve(): PsiElement? { + val results = multiResolve(false) + return if (results.size == 1) { + results[0].element + } else { + null + } + } + } +} diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/reference/ResourceFileReference.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/reference/ResourceFileReference.kt new file mode 100644 index 000000000..f347d7202 --- /dev/null +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/reference/ResourceFileReference.kt @@ -0,0 +1,43 @@ +/* + * Minecraft Dev for IntelliJ + * + * https://minecraftdev.org + * + * Copyright (c) 2020 minecraft-dev + * + * MIT License + */ + +package com.demonwav.mcdev.platform.fabric.reference + +import com.demonwav.mcdev.facet.MinecraftFacet +import com.demonwav.mcdev.util.SourceType +import com.demonwav.mcdev.util.findModule +import com.demonwav.mcdev.util.reference.InspectionReference +import com.intellij.json.psi.JsonStringLiteral +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiManager +import com.intellij.psi.PsiReference +import com.intellij.psi.PsiReferenceBase +import com.intellij.psi.PsiReferenceProvider +import com.intellij.util.ProcessingContext + +class ResourceFileReference(private val description: String) : PsiReferenceProvider() { + override fun getReferencesByElement(element: PsiElement, context: ProcessingContext): Array { + return arrayOf(Reference(description, element as JsonStringLiteral)) + } + + private class Reference(desc: String, element: JsonStringLiteral) : + PsiReferenceBase(element), + InspectionReference { + override val description = desc + override val unresolved = resolve() == null + + override fun resolve(): PsiElement? { + val module = element.findModule() ?: return null + val facet = MinecraftFacet.getInstance(module) ?: return null + val virtualFile = facet.findFile(element.value, SourceType.RESOURCE) ?: return null + return PsiManager.getInstance(element.project).findFile(virtualFile) + } + } +} diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 5595c4172..825dd7d9a 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -193,6 +193,7 @@ + @@ -433,6 +434,17 @@ implementationClass="com.demonwav.mcdev.platform.forge.inspections.simpleimpl.MissingMessageConstructorInspection"/> + + + + Date: Thu, 2 Jul 2020 19:24:24 +0100 Subject: [PATCH 15/23] Add multi-module fabric support --- .../mcdev/creator/MinecraftProjectCreator.kt | 15 +++- .../demonwav/mcdev/creator/ProjectCreator.kt | 13 ++++ .../fabric/creator/FabricProjectCreator.kt | 38 +++++++-- .../platform/fabric/creator/FabricTemplate.kt | 18 +++++ .../demonwav/mcdev/util/MinecraftTemplates.kt | 8 ++ .../fabric/fabric_submodule_build.gradle.ft | 77 +++++++++++++++++++ .../fabric/fabric_submodule_build.gradle.html | 15 ++++ .../fabric_submodule_gradle.properties.ft | 17 ++++ .../fabric_submodule_gradle.properties.html | 15 ++++ 9 files changed, 207 insertions(+), 9 deletions(-) create mode 100644 src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_build.gradle.ft create mode 100644 src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_build.gradle.html create mode 100644 src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_gradle.properties.ft create mode 100644 src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_gradle.properties.html diff --git a/src/main/kotlin/com/demonwav/mcdev/creator/MinecraftProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/creator/MinecraftProjectCreator.kt index 1065901b5..55388fe0a 100644 --- a/src/main/kotlin/com/demonwav/mcdev/creator/MinecraftProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/creator/MinecraftProjectCreator.kt @@ -110,6 +110,8 @@ class MinecraftProjectCreator { } } + val postMultiModuleAwares = mutableListOf() + for (config in configs) { val log = newLog(config, workLog) @@ -118,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" @@ -139,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 diff --git a/src/main/kotlin/com/demonwav/mcdev/creator/ProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/creator/ProjectCreator.kt index 3b466547e..5542e7f22 100644 --- a/src/main/kotlin/com/demonwav/mcdev/creator/ProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/creator/ProjectCreator.kt @@ -69,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 +} diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt index ef8304118..d314e350c 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt @@ -12,6 +12,7 @@ package com.demonwav.mcdev.platform.fabric.creator import com.demonwav.mcdev.creator.BaseProjectCreator import com.demonwav.mcdev.creator.CreatorStep +import com.demonwav.mcdev.creator.PostMultiModuleAware import com.demonwav.mcdev.creator.buildsystem.BuildSystem import com.demonwav.mcdev.creator.buildsystem.gradle.BasicGradleFinalizerStep import com.demonwav.mcdev.creator.buildsystem.gradle.GradleBuildSystem @@ -65,7 +66,7 @@ class FabricProjectCreator( private val rootModule: Module, private val buildSystem: GradleBuildSystem, private val config: FabricProjectConfig -) : BaseProjectCreator(rootModule, buildSystem) { +) : BaseProjectCreator(rootModule, buildSystem), PostMultiModuleAware { override fun getSingleModuleSteps(): Iterable { val buildText = FabricTemplate.applyBuildGradle(project, buildSystem, config) @@ -74,12 +75,7 @@ class FabricProjectCreator( val files = GradleFiles(buildText, propText, settingsText) val steps = mutableListOf( - SimpleGradleSetupStep( - project, - rootDirectory, - buildSystem, - files - ), + SimpleGradleSetupStep(project, rootDirectory, buildSystem, files), GradleWrapperStep(project, rootDirectory, buildSystem) ) if (config.genSources) { @@ -101,7 +97,33 @@ class FabricProjectCreator( } override fun getMultiModuleSteps(projectBaseDir: Path): Iterable { - TODO("Not yet implemented") + val buildText = FabricTemplate.applyMultiModuleBuildGradle(project, buildSystem, config) + val propText = FabricTemplate.applyMultiModuleGradleProp(project, buildSystem, config) + val settingsText = FabricTemplate.applySettingsGradle(project, buildSystem, config) + val files = GradleFiles(buildText, propText, settingsText) + + val steps = mutableListOf( + SimpleGradleSetupStep(project, rootDirectory, buildSystem, files) + ) + if (config.genSources) { + steps += GenSourcesStep(project, rootDirectory) + } + config.license?.let { + steps += LicenseStep(project, rootDirectory, it, config) + } + if (config.mixins) { + steps += MixinConfigStep(project, buildSystem) + } + return steps + } + + override fun getPostMultiModuleSteps(projectBaseDir: Path): Iterable { + val steps = mutableListOf() + for (entry in config.entryPoints.groupBy { it.className }.entries.sortedBy { it.key }) { + steps += CreateEntryPointStep(project, buildSystem, entry.key, entry.value) + } + steps += FabricModJsonStep(project, buildSystem, config) + return steps } } diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricTemplate.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricTemplate.kt index 60566aa78..05739783e 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricTemplate.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricTemplate.kt @@ -19,6 +19,8 @@ import com.demonwav.mcdev.util.MinecraftTemplates.Companion.FABRIC_GRADLE_PROPER import com.demonwav.mcdev.util.MinecraftTemplates.Companion.FABRIC_MIXINS_JSON_TEMPLATE import com.demonwav.mcdev.util.MinecraftTemplates.Companion.FABRIC_MOD_JSON_TEMPLATE import com.demonwav.mcdev.util.MinecraftTemplates.Companion.FABRIC_SETTINGS_GRADLE_TEMPLATE +import com.demonwav.mcdev.util.MinecraftTemplates.Companion.FABRIC_SUBMODULE_BUILD_GRADLE_TEMPLATE +import com.demonwav.mcdev.util.MinecraftTemplates.Companion.FABRIC_SUBMODULE_GRADLE_PROPERTIES_TEMPLATE import com.demonwav.mcdev.util.toPackageName import com.intellij.openapi.project.Project import java.time.ZonedDateTime @@ -60,6 +62,14 @@ object FabricTemplate : BaseTemplate() { return project.applyGradleTemplate(FABRIC_BUILD_GRADLE_TEMPLATE, buildSystem, config) } + fun applyMultiModuleBuildGradle( + project: Project, + buildSystem: BuildSystem, + config: FabricProjectConfig + ): String { + return project.applyGradleTemplate(FABRIC_SUBMODULE_BUILD_GRADLE_TEMPLATE, buildSystem, config) + } + fun applySettingsGradle( project: Project, buildSystem: BuildSystem, @@ -76,6 +86,14 @@ object FabricTemplate : BaseTemplate() { return project.applyGradleTemplate(FABRIC_GRADLE_PROPERTIES_TEMPLATE, buildSystem, config) } + fun applyMultiModuleGradleProp( + project: Project, + buildSystem: BuildSystem, + config: FabricProjectConfig + ): String { + return project.applyGradleTemplate(FABRIC_SUBMODULE_GRADLE_PROPERTIES_TEMPLATE, buildSystem, config) + } + fun applyLicenseTemplate( project: Project, license: License, diff --git a/src/main/kotlin/com/demonwav/mcdev/util/MinecraftTemplates.kt b/src/main/kotlin/com/demonwav/mcdev/util/MinecraftTemplates.kt index 609af3b20..d7ea46ca6 100644 --- a/src/main/kotlin/com/demonwav/mcdev/util/MinecraftTemplates.kt +++ b/src/main/kotlin/com/demonwav/mcdev/util/MinecraftTemplates.kt @@ -92,6 +92,12 @@ class MinecraftTemplates : FileTemplateGroupDescriptorFactory { fabricGroup.addTemplate(FileTemplateDescriptor(FABRIC_MIXINS_JSON_TEMPLATE, PlatformAssets.FABRIC_ICON)) fabricGroup.addTemplate(FileTemplateDescriptor(FABRIC_MOD_JSON_TEMPLATE, PlatformAssets.FABRIC_ICON)) fabricGroup.addTemplate(FileTemplateDescriptor(FABRIC_SETTINGS_GRADLE_TEMPLATE, PlatformAssets.FABRIC_ICON)) + fabricGroup.addTemplate( + FileTemplateDescriptor(FABRIC_SUBMODULE_BUILD_GRADLE_TEMPLATE, PlatformAssets.FABRIC_ICON) + ) + fabricGroup.addTemplate( + FileTemplateDescriptor(FABRIC_SUBMODULE_GRADLE_PROPERTIES_TEMPLATE, PlatformAssets.FABRIC_ICON) + ) } FileTemplateGroupDescriptor("LiteLoader", PlatformAssets.LITELOADER_ICON).let { liteGroup -> @@ -187,6 +193,8 @@ class MinecraftTemplates : FileTemplateGroupDescriptorFactory { const val FABRIC_MIXINS_JSON_TEMPLATE = "fabric_mixins.json" const val FABRIC_MOD_JSON_TEMPLATE = "fabric_mod.json" const val FABRIC_SETTINGS_GRADLE_TEMPLATE = "fabric_settings.gradle" + const val FABRIC_SUBMODULE_BUILD_GRADLE_TEMPLATE = "fabric_submodule_build.gradle" + const val FABRIC_SUBMODULE_GRADLE_PROPERTIES_TEMPLATE = "fabric_submodule_gradle.properties" const val LITELOADER_MAIN_CLASS_TEMPLATE = "LiteLoader Main Class.java" const val LITELOADER_BUILD_GRADLE_TEMPLATE = "LiteLoader build.gradle" diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_build.gradle.ft b/src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_build.gradle.ft new file mode 100644 index 000000000..391316364 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_build.gradle.ft @@ -0,0 +1,77 @@ +plugins { + id 'fabric-loom' version '${LOOM_VERSION}' + id 'maven-publish' +} + +sourceCompatibility = JavaVersion.VERSION_1_8 +targetCompatibility = JavaVersion.VERSION_1_8 + +archivesBaseName = project.archives_base_name + +dependencies { + //to change the versions see the gradle.properties file + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + + #if (${API_VERSION}) + // Fabric API. This is technically optional, but you probably want it anyway. + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + #end + + // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. + // You may need to force-disable transitiveness on them. +} + +processResources { + inputs.property "version", project.version + + from(sourceSets.main.resources.srcDirs) { + include "fabric.mod.json" + expand "version": project.version + } + + from(sourceSets.main.resources.srcDirs) { + exclude "fabric.mod.json" + } +} + +// ensure that the encoding is set to UTF-8, no matter what the system default is +// this fixes some edge cases with special characters not displaying correctly +// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html +tasks.withType(JavaCompile) { + options.encoding = "UTF-8" +} + +// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task +// if it is present. +// If you remove this task, sources will not be generated. +task sourcesJar(type: Jar, dependsOn: classes) { + classifier = "sources" + from sourceSets.main.allSource +} + +jar { + from "LICENSE" +} + +// configure the maven publication +publishing { + publications { + mavenJava(MavenPublication) { + // add all the jars that should be included when publishing to maven + artifact(remapJar) { + builtBy remapJar + } + artifact(sourcesJar) { + builtBy remapSourcesJar + } + } + } + + // select the repositories you want to publish to + repositories { + // uncomment to publish to the local maven + // mavenLocal() + } +} diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_build.gradle.html b/src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_build.gradle.html new file mode 100644 index 000000000..eed639a2c --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_build.gradle.html @@ -0,0 +1,15 @@ + + + + +

This is a built-in file template used to create a new build.gradle file for multi-module Fabric projects.

+ + diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_gradle.properties.ft b/src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_gradle.properties.ft new file mode 100644 index 000000000..da97f5695 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_gradle.properties.ft @@ -0,0 +1,17 @@ +# Done to increase the memory available to gradle. +org.gradle.jvmargs=-Xmx1G + +# Fabric Properties + # check these on https://modmuss50.me/fabric.html + minecraft_version=${MC_VERSION} + yarn_mappings=${YARN_MAPPINGS} + loader_version=${LOADER_VERSION} + +# Mod Properties + archives_base_name = ${ARTIFACT_ID} + +#if (${API_VERSION}) +# Dependencies + # check this on https://modmuss50.me/fabric.html + fabric_version=${API_VERSION} +#end diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_gradle.properties.html b/src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_gradle.properties.html new file mode 100644 index 000000000..a8bb1f189 --- /dev/null +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_gradle.properties.html @@ -0,0 +1,15 @@ + + + + +

This is a built-in file template used to create a new gradle.properties file for multi-module Fabric projects.

+ + From 86e06e6cc9de5b5dc2601cd509f606d51c7f0216 Mon Sep 17 00:00:00 2001 From: Joe Date: Thu, 2 Jul 2020 20:02:35 +0100 Subject: [PATCH 16/23] Fix licenses (why does intellij do this) --- .../fabric/fabric_submodule_build.gradle.html | 16 ++++++++-------- .../fabric_submodule_gradle.properties.html | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_build.gradle.html b/src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_build.gradle.html index eed639a2c..593dd2f98 100644 --- a/src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_build.gradle.html +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_build.gradle.html @@ -1,12 +1,12 @@ + Minecraft Dev for IntelliJ + + https://minecraftdev.org + + Copyright (c) 2020 minecraft-dev + + MIT License +--> diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_gradle.properties.html b/src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_gradle.properties.html index a8bb1f189..f9d48e8c8 100644 --- a/src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_gradle.properties.html +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_submodule_gradle.properties.html @@ -1,12 +1,12 @@ + Minecraft Dev for IntelliJ + + https://minecraftdev.org + + Copyright (c) 2020 minecraft-dev + + MIT License +--> From e61f6ccbf37d11d651446cfe0c17256553f534da Mon Sep 17 00:00:00 2001 From: Joseph Burton Date: Fri, 3 Jul 2020 10:14:03 +0100 Subject: [PATCH 17/23] Update src/main/resources/fileTemplates/j2ee/fabric/fabric_mixins.json.html Co-authored-by: comp500 --- .../resources/fileTemplates/j2ee/fabric/fabric_mixins.json.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/fileTemplates/j2ee/fabric/fabric_mixins.json.html b/src/main/resources/fileTemplates/j2ee/fabric/fabric_mixins.json.html index 64508a518..c3fb5e95b 100644 --- a/src/main/resources/fileTemplates/j2ee/fabric/fabric_mixins.json.html +++ b/src/main/resources/fileTemplates/j2ee/fabric/fabric_mixins.json.html @@ -10,6 +10,6 @@ -

This is a built-in file template used to create a new modoid.mixins.json file for Fabric projects.

+

This is a built-in file template used to create a new modid.mixins.json file for Fabric projects.

From c32a00676bfd7e84676499d9479d7104678a51c1 Mon Sep 17 00:00:00 2001 From: Joe Date: Fri, 3 Jul 2020 10:57:32 +0100 Subject: [PATCH 18/23] Update default gradle versions --- .../platform/fabric/creator/FabricProjectSettingsWizard.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt index a2bb6135c..8bce0fced 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt @@ -250,7 +250,8 @@ class FabricProjectSettingsWizard(private val creator: MinecraftProjectCreator) conf.apiMavenLocation = api?.mavenLocation conf.gradleVersion = when (dataProvider?.loomVersions?.firstOrNull { it.name == loomVersion }?.gradle) { 4 -> SemanticVersion.release(4, 10, 3) - else -> SemanticVersion.release(5, 5, 1) + 5 -> SemanticVersion.release(5, 6, 4) + else -> SemanticVersion.release(6, 5, 1) } val loomVer = loomVersion if (loomVer != null) { From c1eb2fad3beb7872f55eb3fda0abad8d565f0ed8 Mon Sep 17 00:00:00 2001 From: Joe Date: Fri, 3 Jul 2020 15:06:47 +0100 Subject: [PATCH 19/23] Fix semver parsing for snapshots --- .../fabric/creator/FabricProjectConfig.kt | 2 +- .../creator/FabricProjectSettingsWizard.kt | 2 +- .../platform/fabric/creator/FabricTemplate.kt | 2 +- .../demonwav/mcdev/util/SemanticVersion.kt | 99 +++++++++++++------ 4 files changed, 72 insertions(+), 33 deletions(-) diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectConfig.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectConfig.kt index 6cd3a567d..87939f06b 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectConfig.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectConfig.kt @@ -25,7 +25,7 @@ import java.nio.file.Path class FabricProjectConfig : ProjectConfig(), GradleCreator { - var yarnVersion = SemanticVersion.release() + var yarnVersion = "" var yarnClassifier: String? = "v2" // Minecraft does not follow semver in the snapshots var mcVersion = "" diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt index 8bce0fced..df22097b0 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt @@ -227,7 +227,7 @@ class FabricProjectSettingsWizard(private val creator: MinecraftProjectCreator) conf.setAuthors(authorsField.text) conf.modRepo = repositoryField.text - conf.yarnVersion = yarnVersion?.let { SemanticVersion.parse(it) } ?: SemanticVersion.release() + conf.yarnVersion = yarnVersion ?: "$mcVersion+build.1" val yarnVersionObj = dataProvider?.yarnVersions?.firstOrNull { it.name == yarnVersion } conf.yarnClassifier = if (yarnVersionObj?.hasV2Mappings == false) { null diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricTemplate.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricTemplate.kt index 05739783e..e27ffc347 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricTemplate.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricTemplate.kt @@ -37,7 +37,7 @@ object FabricTemplate : BaseTemplate() { "ARTIFACT_ID" to buildSystem.artifactId, "VERSION" to buildSystem.version, "MC_VERSION" to config.mcVersion, - "YARN_MAPPINGS" to config.yarnVersion.toString(), + "YARN_MAPPINGS" to config.yarnVersion, "LOADER_VERSION" to config.loaderVersion.toString(), "LOOM_VERSION" to config.loomVersion.toString() ) diff --git a/src/main/kotlin/com/demonwav/mcdev/util/SemanticVersion.kt b/src/main/kotlin/com/demonwav/mcdev/util/SemanticVersion.kt index bb904e1dc..a43a8c5bd 100644 --- a/src/main/kotlin/com/demonwav/mcdev/util/SemanticVersion.kt +++ b/src/main/kotlin/com/demonwav/mcdev/util/SemanticVersion.kt @@ -10,8 +10,7 @@ package com.demonwav.mcdev.util -import com.demonwav.mcdev.util.SemanticVersion.Companion.VersionPart.ReleasePart -import com.demonwav.mcdev.util.SemanticVersion.Companion.VersionPart.TextPart +import com.demonwav.mcdev.util.SemanticVersion.Companion.VersionPart.* /** * Represents a comparable and generalised "semantic version". @@ -100,28 +99,41 @@ class SemanticVersion( } // We need to support pre-releases/RCs and snapshots as well - fun parseTextPart(subParts: List, separator: Char): VersionPart = - if (subParts.size == 2) { - val version = parseInt(subParts[0]) - val (text, number) = subParts[1].span { !it.isDigit() } - // Pure text parts always are considered older than numbered ones - // Since we don't handle negative version numbers, -1 is guaranteed to be smaller than any numbered part - val versionNumber = if (number.isEmpty()) -1 else parseInt(number) - TextPart(version, separator, text, versionNumber) + fun parsePreReleasePart(versionPart: String, preReleasePart: String, separator: Char, versionString: String): VersionPart { + val version = parseInt(versionPart) + if (!preReleasePart.contains('.')) { + // support the case where pre-releases etc aren't separated by a dot + val (text, number) = preReleasePart.span { !it.isDigit() } + val subParts = when { + text.isEmpty() -> listOf(ReleasePart(parseInt(number), number)) + number.isEmpty() -> listOf(TextPart(text)) + else -> listOf(TextPart(text), ReleasePart(parseInt(number), number)) + } + return PreReleasePart(version, separator, subParts, versionString) } else { - throw IllegalArgumentException( - "Failed to split text version part into two: ${subParts.first()}$separator" - ) + val subParts = preReleasePart.split(".").map { subPart -> + val number = subPart.toIntOrNull() + if (number == null) { + TextPart(subPart) + } else { + ReleasePart(number, subPart) + } + } + return PreReleasePart(version, separator, subParts, versionString) } + } val mainPartAndMetadata = value.split("+", limit = 2) val mainPart = mainPartAndMetadata[0] val metadata = mainPartAndMetadata.getOrNull(1) ?: "" - val parts = mainPart.split('.').map { part -> - val separator = SEPARATORS.find { it in part } - if (separator != null) { - parseTextPart(part.split(separator, limit = 2), separator) + val separator = SEPARATORS.find { it in mainPart } + val beforeSeparator = if (separator == null) mainPart else mainPart.substringBefore(separator) + val partCount = beforeSeparator.count { it == '.' } + 1 + val parts = mainPart.split('.', limit = partCount).map { part -> + if (separator != null && separator in part) { + val subParts = part.split(separator, limit = 2) + parsePreReleasePart(subParts[0], subParts[1], separator, part) } else { // Forge has a single version which should be 14.8.* but is actually 14.v8.* val numberPart = if (part.startsWith('v')) { @@ -142,34 +154,61 @@ class SemanticVersion( override fun compareTo(other: VersionPart) = when (other) { is ReleasePart -> version - other.version - is TextPart -> if (version != other.version) version - other.version else 1 + is TextPart -> 1 + is PreReleasePart -> if (version != other.version) version - other.version else 1 } } - data class TextPart(val version: Int, val separator: Char, val text: String, val number: Int) : - VersionPart() { - private val priority = TEXT_PRIORITIES[text.toLowerCase()] ?: -1 - - override val versionString = "$version$separator$text${if (number == -1) "" else number.toString()}" + data class TextPart(override val versionString: String): VersionPart() { + private val priority = TEXT_PRIORITIES[versionString] ?: -1 override fun compareTo(other: VersionPart) = when (other) { - is ReleasePart -> if (version != other.version) version - other.version else -1 + is ReleasePart -> -1 + is PreReleasePart -> -1 is TextPart -> - when { - version != other.version -> version - other.version - text != other.text -> priority - other.priority - else -> number - other.number + if (priority != other.priority) { + priority - other.priority + } else { + versionString.compareTo(other.versionString) + } + } + + override fun hashCode() = versionString.hashCode() + + override fun equals(other: Any?) = + when (other) { + is TextPart -> versionString == other.versionString + else -> false + } + } + + data class PreReleasePart( + val version: Int, + val separator: Char, + val subParts: List, + override val versionString: String + ) : VersionPart() { + + override fun compareTo(other: VersionPart): Int = + when (other) { + is ReleasePart -> if (version != other.version) version - other.version else -1 + is TextPart -> 1 + is PreReleasePart -> + if (version != other.version) { + version - other.version + } else { + naturalOrder().lexicographical().compare(subParts, other.subParts) } } override fun hashCode(): Int { - return version + 31 * text.hashCode() + 31 * number + return version + 31 * subParts.hashCode() } override fun equals(other: Any?): Boolean { return when (other) { - is TextPart -> other.version == version && other.text == text && other.number == number + is PreReleasePart -> other.version == version && other.subParts == subParts else -> false } } From d40985e40fb64b9633a0a16b7aa187ba2ac26a00 Mon Sep 17 00:00:00 2001 From: Joe Date: Fri, 3 Jul 2020 15:27:22 +0100 Subject: [PATCH 20/23] Formatting --- .../com/demonwav/mcdev/util/SemanticVersion.kt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/demonwav/mcdev/util/SemanticVersion.kt b/src/main/kotlin/com/demonwav/mcdev/util/SemanticVersion.kt index a43a8c5bd..d42ee3aa8 100644 --- a/src/main/kotlin/com/demonwav/mcdev/util/SemanticVersion.kt +++ b/src/main/kotlin/com/demonwav/mcdev/util/SemanticVersion.kt @@ -10,7 +10,9 @@ package com.demonwav.mcdev.util -import com.demonwav.mcdev.util.SemanticVersion.Companion.VersionPart.* +import com.demonwav.mcdev.util.SemanticVersion.Companion.VersionPart.PreReleasePart +import com.demonwav.mcdev.util.SemanticVersion.Companion.VersionPart.ReleasePart +import com.demonwav.mcdev.util.SemanticVersion.Companion.VersionPart.TextPart /** * Represents a comparable and generalised "semantic version". @@ -99,7 +101,12 @@ class SemanticVersion( } // We need to support pre-releases/RCs and snapshots as well - fun parsePreReleasePart(versionPart: String, preReleasePart: String, separator: Char, versionString: String): VersionPart { + fun parsePreReleasePart( + versionPart: String, + preReleasePart: String, + separator: Char, + versionString: String + ): VersionPart { val version = parseInt(versionPart) if (!preReleasePart.contains('.')) { // support the case where pre-releases etc aren't separated by a dot @@ -159,7 +166,7 @@ class SemanticVersion( } } - data class TextPart(override val versionString: String): VersionPart() { + data class TextPart(override val versionString: String) : VersionPart() { private val priority = TEXT_PRIORITIES[versionString] ?: -1 override fun compareTo(other: VersionPart) = From 19ac4cb170f6ebfb91b7b4fbf2fae06f58ce59e0 Mon Sep 17 00:00:00 2001 From: Joe Date: Fri, 3 Jul 2020 15:52:44 +0100 Subject: [PATCH 21/23] Show plugin icon by using EntryPointReferences --- .../mcdev/platform/fabric/FabricModule.kt | 15 +++++++-------- .../fabric/reference/EntryPointReference.kt | 2 ++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/FabricModule.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/FabricModule.kt index 7fd574699..c44263e65 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/FabricModule.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/FabricModule.kt @@ -14,6 +14,7 @@ import com.demonwav.mcdev.asset.PlatformAssets import com.demonwav.mcdev.facet.MinecraftFacet import com.demonwav.mcdev.platform.AbstractModule import com.demonwav.mcdev.platform.PlatformType +import com.demonwav.mcdev.platform.fabric.reference.EntryPointReference import com.demonwav.mcdev.platform.fabric.util.FabricConstants import com.demonwav.mcdev.util.SourceType import com.demonwav.mcdev.util.nullable @@ -21,6 +22,7 @@ import com.intellij.psi.PsiClass import com.intellij.psi.PsiElement import com.intellij.psi.PsiIdentifier import com.intellij.psi.PsiMethod +import com.intellij.psi.search.searches.ReferencesSearch class FabricModule internal constructor(facet: MinecraftFacet) : AbstractModule(facet) { @@ -39,15 +41,12 @@ class FabricModule internal constructor(facet: MinecraftFacet) : AbstractModule( if (element !is PsiIdentifier) { return false } - - val psiClass = (element.parent as? PsiClass) ?: return false - - // TODO: check the mod json, and support method entrypoints - val interfaces = psiClass.interfaces - return interfaces.any { - it.qualifiedName == FabricConstants.MOD_INITIALIZER || - it.qualifiedName == FabricConstants.CLIENT_MOD_INITIALIZER + val parent = element.parent + if (parent !is PsiClass && parent !is PsiMethod) { + return false } + + return ReferencesSearch.search(parent).anyMatch { EntryPointReference.isEntryPointReference(it) } } override fun dispose() { diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/reference/EntryPointReference.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/reference/EntryPointReference.kt index 5b4df1505..e69d09230 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/reference/EntryPointReference.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/reference/EntryPointReference.kt @@ -43,6 +43,8 @@ object EntryPointReference : PsiReferenceProvider() { }.toTypedArray() } + fun isEntryPointReference(reference: PsiReference) = reference is Reference + private class Reference(element: JsonStringLiteral) : PsiReferenceBase(element), PsiPolyVariantReference, From 797887fc5d750a8550ac723b491da1bd19b1746a Mon Sep 17 00:00:00 2001 From: Joe Date: Fri, 3 Jul 2020 16:11:54 +0100 Subject: [PATCH 22/23] Apply review suggestions --- .../fabric/creator/FabricProjectCreator.kt | 2 +- .../creator/FabricProjectSettingsWizard.kt | 53 ++++--------------- .../framework/FabricPresentationProvider.kt | 5 +- .../UnresolvedReferenceInspection.kt | 2 +- 4 files changed, 14 insertions(+), 48 deletions(-) diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt index d314e350c..9ccd9384e 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectCreator.kt @@ -210,7 +210,7 @@ class FabricModJsonStep( contactObject.addBefore(generator.createComma(), contactObject.lastChild) } val key = StringUtil.escapeStringCharacters(properties[i].first) - val value = "\"${StringUtil.escapeStringCharacters(properties[i].second)}\"" + val value = "\"" + StringUtil.escapeStringCharacters(properties[i].second) + "\"" contactObject.addBefore(generator.createProperty(key, value), contactObject.lastChild) } } diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt index df22097b0..cc811da66 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/creator/FabricProjectSettingsWizard.kt @@ -306,59 +306,24 @@ class FabricProjectSettingsWizard(private val creator: MinecraftProjectCreator) private fun updateForm() { val dp = dataProvider ?: return - val mcVer = when { - mcVersion != null -> { - mcVersion ?: return - } - else -> { - dp.minecraftVersions.firstOrNull { it.stable }?.name - } - } + val mcVer = mcVersion ?: dp.minecraftVersions.firstOrNull { it.stable }?.name val mcVerObj = dp.minecraftVersions.firstOrNull { it.name == mcVer } - val yarnVer = when { - yarnVersion != null -> { - yarnVersion ?: return - } - else -> { - mcVerObj?.let { mvo -> - dp.getFilteredYarnVersions(mvo).firstOrNull()?.name - } - } + val yarnVer = yarnVersion ?: mcVerObj?.let { mvo -> + dp.getFilteredYarnVersions(mvo).firstOrNull()?.name } val yarnVerObj = dp.yarnVersions.firstOrNull { it.name == yarnVer } - val loomVer = when { - loomVersion != null -> { - loomVersion ?: return - } - else -> { - yarnVerObj?.let { dp.getDefaultLoomVersion(it) }?.name - } - } + val loomVer = loomVersion ?: yarnVerObj?.let { dp.getDefaultLoomVersion(it) }?.name val loomVerObj = dp.loomVersions.firstOrNull { it.name == loomVer } - val loaderVer = when { - loaderVersion != null -> { - loaderVersion ?: return - } - else -> { - loomVerObj?.let { lvo -> - dp.getFilteredLoaderVersions(lvo).firstOrNull()?.name - } - } + val loaderVer = loaderVersion ?: loomVerObj?.let { lvo -> + dp.getFilteredLoaderVersions(lvo).firstOrNull()?.name } - val fabricVer = when { - fabricApiVersion != null -> { - fabricApiVersion ?: return - } - else -> { - mcVerObj?.let { mvo -> - dp.getDefaultFabricApiVersion(mvo) - }?.let { dp.sortedFabricApiVersions[it] }?.name - } - } + val fabricVer = fabricApiVersion ?: mcVerObj?.let { mvo -> + dp.getDefaultFabricApiVersion(mvo) + }?.let { dp.sortedFabricApiVersions[it] }?.name minecraftVersionBox.removeActionListener(minecraftBoxActionListener) minecraftVersionBox.model = CollectionComboBoxModel(dp.minecraftVersions.map { it.name }) diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/framework/FabricPresentationProvider.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/framework/FabricPresentationProvider.kt index defe50325..6d2ebac01 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/framework/FabricPresentationProvider.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/framework/FabricPresentationProvider.kt @@ -24,8 +24,9 @@ class FabricPresentationProvider : LibraryPresentationProvider): LibraryVersionProperties? { for (classesRoot in classesRoots) { if (classesRoot.name.endsWith(".jar")) { - JarFile(classesRoot.localFile).runCatching { - val isFabricLib = entries().asSequence().any { + runCatching { + val jar = JarFile(classesRoot.localFile) + val isFabricLib = jar.entries().asSequence().any { it.name.startsWith("net/fabricmc/") && it.name.endsWith(".class") } if (isFabricLib) { diff --git a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/inspection/UnresolvedReferenceInspection.kt b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/inspection/UnresolvedReferenceInspection.kt index 94131950b..92822b13c 100644 --- a/src/main/kotlin/com/demonwav/mcdev/platform/fabric/inspection/UnresolvedReferenceInspection.kt +++ b/src/main/kotlin/com/demonwav/mcdev/platform/fabric/inspection/UnresolvedReferenceInspection.kt @@ -37,7 +37,7 @@ class UnresolvedReferenceInspection : LocalInspectionTool() { if (file.name == FabricConstants.FABRIC_MOD_JSON) { return super.processFile(file, manager) } - return listOf() + return emptyList() } private class Visitor(private val holder: ProblemsHolder) : JsonElementVisitor() { From 7520a9a59708552e9adafcbfc5585843084d2d02 Mon Sep 17 00:00:00 2001 From: Joe Date: Sat, 4 Jul 2020 08:55:37 +0100 Subject: [PATCH 23/23] Add fabric to readme --- readme.md | 1 + src/main/resources/META-INF/plugin.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 8176721ae..3a4a6c7cb 100644 --- a/readme.md +++ b/readme.md @@ -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) diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 825dd7d9a..aed51b224 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -20,7 +20,7 @@ DemonWav