Skip to content

Commit

Permalink
Merge branch '2021.3' into 2022.1
Browse files Browse the repository at this point in the history
  • Loading branch information
DenWav committed Apr 13, 2022
2 parents efdc23b + bbafc31 commit da0fc78
Show file tree
Hide file tree
Showing 37 changed files with 157 additions and 838 deletions.
21 changes: 7 additions & 14 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,12 @@ import org.gradle.internal.os.OperatingSystem
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "1.6.10"
kotlin("jvm") version "1.6.20"
java
mcdev
groovy
idea
val ijPluginVersion = if (System.getProperty("mcdev.localdev").toBoolean()) {
"1.1.3"
} else {
"1.3.0"
}
id("org.jetbrains.intellij") version ijPluginVersion
id("org.jetbrains.intellij") version "1.5.2"
id("org.cadixdev.licenser") version "0.6.1"
id("org.jlleitschuh.gradle.ktlint") version "10.0.0"
}
Expand All @@ -41,9 +36,7 @@ val jflex by configurations
val jflexSkeleton by configurations
val grammarKit by configurations

val gradleToolingExtension: Configuration by configurations.creating {
extendsFrom(idea)
}
val gradleToolingExtension: Configuration by configurations.creating
val testLibs: Configuration by configurations.creating {
isTransitive = false
}
Expand Down Expand Up @@ -107,13 +100,13 @@ dependencies {
extension = "nbt"
}
}
testLibs(project(":mixin-test-data"))
testLibs(projects.mixinTestData)

// For non-SNAPSHOT versions (unless Jetbrains fixes this...) find the version with:
// afterEvaluate { println(intellij.ideaDependency.get().buildNumber.substring(intellij.type.get().length + 1)) }
gradleToolingExtension(libs.groovy)
gradleToolingExtension(libs.gradleToolingExtension)
gradleToolingExtension(libs.annotations)
gradleToolingExtension(libs.groovy)

testImplementation(libs.junit.api)
testRuntimeOnly(libs.junit.entine)
Expand Down Expand Up @@ -155,7 +148,7 @@ tasks.publishPlugin {
}

tasks.runPluginVerifier {
ideVersions.addAll("IC-2022.1")
ideVersions.addAll("IC-$ideaVersionName")
}

java {
Expand All @@ -173,7 +166,7 @@ tasks.withType<JavaCompile>().configureEach {
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
freeCompilerArgs = listOf("-Xjvm-default=enable")
freeCompilerArgs = listOf("-Xjvm-default=all")
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ kotlin.code.style=official
ideaVersion = 221-EAP-SNAPSHOT
ideaVersionName = 2022.1

coreVersion = 1.5.18
coreVersion = 1.5.19
downloadIdeaSources = true

pluginTomlVersion = 221.3427.87
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Minecraft Development for IntelliJ
</tr>
</table>

Info and Documentation [![Current Release](https://img.shields.io/badge/release-1.5.18-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327)
Info and Documentation [![Current Release](https://img.shields.io/badge/release-1.5.19-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327)
----------------------

<a href="https://discord.gg/j6UNcfr"><img src="https://i.imgur.com/JXu9C1G.png" height="48px"></img></a>
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ rootProject.name = "MinecraftDev"

gradle.startParameter.showStacktrace = ShowStacktrace.ALWAYS_FULL

enableFeaturePreview("VERSION_CATALOGS")
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

include("mixin-test-data")
25 changes: 4 additions & 21 deletions src/main/kotlin/creator/BuildSystemWizardStep.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ class BuildSystemWizardStep(private val creator: MinecraftProjectCreator) : Modu
buildSystemBox.removeAllItems()
buildSystemBox.isEnabled = true

val creatorConfig = creator.config ?: return

val types = BuildSystemType.values().filter { type ->
creator.configs.all { type.creatorType.isInstance(it) }
type.creatorType.isInstance(creatorConfig)
}

for (type in types) {
Expand All @@ -59,26 +61,7 @@ class BuildSystemWizardStep(private val creator: MinecraftProjectCreator) : Modu

buildSystemBox.selectedIndex = 0

// We prefer Gradle, so if it's included, choose it
// If Gradle is not included, luck of the draw
if (creator.configs.any { it.preferredBuildSystem == BuildSystemType.GRADLE }) {
buildSystemBox.selectedItem = BuildSystemType.GRADLE
return
}

val counts = creator.configs.asSequence()
.mapNotNull { it.preferredBuildSystem }
.groupingBy { it }
.eachCount()

val maxValue = counts.maxByOrNull { it.value }?.value ?: return
counts.asSequence()
.filter { it.value == maxValue }
.map { it.key }
.firstOrNull()
?.let { mostPopularType ->
buildSystemBox.selectedItem = mostPopularType
}
creatorConfig.preferredBuildSystem?.let { buildSystemBox.selectedItem = it }
}

override fun updateDataModel() {
Expand Down
9 changes: 0 additions & 9 deletions src/main/kotlin/creator/MinecraftModuleWizardStep.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ abstract class MinecraftModuleWizardStep : ModuleWizardStep() {

protected fun basicUpdateStep(
creator: MinecraftProjectCreator,
config: ProjectConfig,
pluginNameField: JTextField,
mainClassField: JTextField
) {
Expand All @@ -66,14 +65,6 @@ abstract class MinecraftModuleWizardStep : ModuleWizardStep() {
val name = WordUtils.capitalize(buildSystem.artifactId.replace('-', ' '))
pluginNameField.text = name

if (creator.configs.indexOf(config) != 0) {
pluginNameField.isEditable = false
}

mainClassField.text = generateClassName(buildSystem, name)

if (creator.configs.size > 1) {
mainClassField.text = mainClassField.text + config.type.normalName
}
}
}
69 changes: 8 additions & 61 deletions src/main/kotlin/creator/MinecraftProjectCreator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.progress.ProgressManager
import com.intellij.openapi.progress.Task
import com.intellij.openapi.vfs.VfsUtil
import java.nio.file.Files
import java.nio.file.Path
import java.util.Locale

class MinecraftProjectCreator {

var buildSystem: BuildSystem? = null

val configs = LinkedHashSet<ProjectConfig>()
var config: ProjectConfig? = null

fun create(root: Path, module: Module) {
val build = buildSystem ?: throw IllegalStateException("buildSystem not initialized")
Expand Down Expand Up @@ -94,67 +92,16 @@ class MinecraftProjectCreator {
VfsUtil.markDirtyAndRefresh(false, true, true, root.virtualFileOrError)
}

build.configure(configs, root)
val config = this@MinecraftProjectCreator.config ?: return

if (configs.size == 1) {
val config = configs.first()
val log = newLog(config, workLog)
if (!build.buildCreator(config, root, module).getSingleModuleSteps().run(indicator, log)) {
return
}
config.type.type.performCreationSettingSetup(module.project)
CreatorStep.runAllReformats()
} else {
val types = configs.map { it.type }
newLog(build.javaClass.name + "::multiModuleBaseSteps", workLog).let { log ->
if (!build.multiModuleBaseSteps(module, types, root).run(indicator, log)) {
return
}
}

val postMultiModuleAwares = mutableListOf<PostMultiModuleAware>()

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

val dirName = config.type.normalName.lowercase(Locale.ENGLISH)
val newArtifactId = "${build.artifactId}-$dirName"
val dir = Files.createDirectories(root.resolve(newArtifactId))

val newBuild = build.createSub(newArtifactId)
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"
val commonDir = Files.createDirectories(root.resolve(commonArtifactId))
val commonBuild = build.createSub(commonArtifactId)
build.configure(config, root)

newLog(commonBuild.javaClass.name + "::multiModuleCommonSteps", workLog).let { log ->
if (!commonBuild.multiModuleCommonSteps(module, commonDir).run(indicator, log)) {
return
}
}

CreatorStep.runAllReformats()

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
}
}
val log = newLog(config, workLog)
if (!build.buildCreator(config, root, module).getSteps().run(indicator, log)) {
return
}
config.type.type.performCreationSettingSetup(module.project)
CreatorStep.runAllReformats()

// Tell IntelliJ about everything we've done
invokeLater {
Expand Down
Loading

0 comments on commit da0fc78

Please sign in to comment.