diff --git a/changelog.md b/changelog.md index 9e603ff54..b3a6fa9cd 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,6 @@ # Minecraft Development for IntelliJ -## [Unreleased] +## [1.8.2] ### Added @@ -13,6 +13,7 @@ - Mixin injection signature fix preview - Loom 1.8 support - K2 mode compatibility +- [#2385](https://github.com/minecraft-dev/MinecraftDev/issues/2385) ModDevGradle Vanilla-Mode support ### Changed @@ -28,6 +29,7 @@ - [#2376](https://github.com/minecraft-dev/MinecraftDev/issues/2376) Error when generating event listeners in read only file - [#2308](https://github.com/minecraft-dev/MinecraftDev/issues/2308) Mixin Inject signature fix adds last parameter as first local - [#1813](https://github.com/minecraft-dev/MinecraftDev/issues/1813) Single character Accessor targets aren't inferred correctly +- [#1886](https://github.com/minecraft-dev/MinecraftDev/issues/1886) Sync error in ForgeGradle composite builds ## [1.8.1] - 2024-08-10 diff --git a/gradle.properties b/gradle.properties index 6467feb6f..0c9cf132c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,7 +21,7 @@ # suppress inspection "UnusedProperty" for whole file ideaVersionName = 2024.1 -coreVersion = 1.8.1 +coreVersion = 1.8.2 # Silences a build-time warning because we are bundling our own kotlin library kotlin.stdlib.default.dependency = false diff --git a/src/gradle-tooling-extension/groovy/com/demonwav/mcdev/platform/mcp/gradle/tooling/neomoddev/NeoModDevGradleModelBuilderImpl.groovy b/src/gradle-tooling-extension/groovy/com/demonwav/mcdev/platform/mcp/gradle/tooling/neomoddev/NeoModDevGradleModelBuilderImpl.groovy index 46dc6669a..c9631e26c 100644 --- a/src/gradle-tooling-extension/groovy/com/demonwav/mcdev/platform/mcp/gradle/tooling/neomoddev/NeoModDevGradleModelBuilderImpl.groovy +++ b/src/gradle-tooling-extension/groovy/com/demonwav/mcdev/platform/mcp/gradle/tooling/neomoddev/NeoModDevGradleModelBuilderImpl.groovy @@ -47,10 +47,8 @@ final class NeoModDevGradleModelBuilderImpl implements ModelBuilderService { return null } - def neoforgeVersion = extension.version.get() - if (neoforgeVersion == null) { - return null - } + def neoforgeVersion = extension.version.getOrNull() + def neoFormVersion = extension.neoFormVersion.getOrNull() def accessTransformersRaw = extension.accessTransformers List accessTransformers @@ -74,7 +72,7 @@ final class NeoModDevGradleModelBuilderImpl implements ModelBuilderService { } //noinspection GroovyAssignabilityCheck - return new NeoModDevGradleModelImpl(neoforgeVersion, mappingsFile, accessTransformers) + return new NeoModDevGradleModelImpl(neoforgeVersion, neoFormVersion, mappingsFile, accessTransformers) } @Override diff --git a/src/gradle-tooling-extension/groovy/com/demonwav/mcdev/platform/mcp/gradle/tooling/neomoddev/NeoModDevGradleModelImpl.groovy b/src/gradle-tooling-extension/groovy/com/demonwav/mcdev/platform/mcp/gradle/tooling/neomoddev/NeoModDevGradleModelImpl.groovy index 5640af6fd..27770b087 100644 --- a/src/gradle-tooling-extension/groovy/com/demonwav/mcdev/platform/mcp/gradle/tooling/neomoddev/NeoModDevGradleModelImpl.groovy +++ b/src/gradle-tooling-extension/groovy/com/demonwav/mcdev/platform/mcp/gradle/tooling/neomoddev/NeoModDevGradleModelImpl.groovy @@ -20,24 +20,14 @@ package com.demonwav.mcdev.platform.mcp.gradle.tooling.neomoddev - import com.demonwav.mcdev.platform.mcp.gradle.tooling.McpModelNMD -import groovy.transform.CompileStatic +import groovy.transform.Immutable -@CompileStatic +@Immutable(knownImmutableClasses = [File]) final class NeoModDevGradleModelImpl implements McpModelNMD, Serializable { final String neoForgeVersion + final String neoFormVersion final File mappingsFile final List accessTransformers - - NeoModDevGradleModelImpl( - final String neoForgeVersion, - final File mappingsFile, - final List accessTransformers - ) { - this.neoForgeVersion = neoForgeVersion - this.mappingsFile = mappingsFile - this.accessTransformers = accessTransformers - } } diff --git a/src/gradle-tooling-extension/java/com/demonwav/mcdev/platform/mcp/gradle/tooling/McpModelNMD.java b/src/gradle-tooling-extension/java/com/demonwav/mcdev/platform/mcp/gradle/tooling/McpModelNMD.java index beff8af28..5eab5ba70 100644 --- a/src/gradle-tooling-extension/java/com/demonwav/mcdev/platform/mcp/gradle/tooling/McpModelNMD.java +++ b/src/gradle-tooling-extension/java/com/demonwav/mcdev/platform/mcp/gradle/tooling/McpModelNMD.java @@ -20,11 +20,14 @@ package com.demonwav.mcdev.platform.mcp.gradle.tooling; +import org.jetbrains.annotations.Nullable; + import java.io.File; import java.util.List; public interface McpModelNMD { - String getNeoForgeVersion(); + @Nullable String getNeoForgeVersion(); + @Nullable String getNeoFormVersion(); File getMappingsFile(); List getAccessTransformers(); } diff --git a/src/main/kotlin/platform/mcp/gradle/McpProjectResolverExtension.kt b/src/main/kotlin/platform/mcp/gradle/McpProjectResolverExtension.kt index 5d45a3d79..63d787d66 100644 --- a/src/main/kotlin/platform/mcp/gradle/McpProjectResolverExtension.kt +++ b/src/main/kotlin/platform/mcp/gradle/McpProjectResolverExtension.kt @@ -59,7 +59,7 @@ class McpProjectResolverExtension : AbstractProjectResolverExtension() { val projectDirPath = Paths.get(projectDataNode.data.linkedExternalProjectPath) runGradleTask(project, projectDirPath) { settings -> - settings.taskNames = allTaskNames + settings.taskNames = allTaskNames.distinct() } super.resolveFinished(projectDataNode) diff --git a/src/main/kotlin/platform/mcp/gradle/datahandler/McpModelFG3Handler.kt b/src/main/kotlin/platform/mcp/gradle/datahandler/McpModelFG3Handler.kt index 1be6dcb7c..fe13f2688 100644 --- a/src/main/kotlin/platform/mcp/gradle/datahandler/McpModelFG3Handler.kt +++ b/src/main/kotlin/platform/mcp/gradle/datahandler/McpModelFG3Handler.kt @@ -34,6 +34,7 @@ import com.intellij.openapi.vfs.LocalFileSystem import org.gradle.tooling.model.idea.IdeaModule import org.jetbrains.plugins.gradle.model.data.GradleSourceSetData import org.jetbrains.plugins.gradle.service.project.ProjectResolverContext +import org.jetbrains.plugins.gradle.util.gradleIdentityPath object McpModelFG3Handler : McpModelDataHandler { @@ -68,9 +69,10 @@ object McpModelFG3Handler : McpModelDataHandler { forgeVersion, ) - val gradleProjectPath = gradleModule.gradleProject.projectIdentifier.projectPath - val suffix = if (gradleProjectPath.endsWith(':')) "" else ":" - val taskName = gradleProjectPath + suffix + data.taskName + // gradleIdentityPath makes it work with composite builds + val identityPath = node.data.gradleIdentityPath + // But ignore it if it is the root project, as taskName already starts with a colon + val taskName = if (identityPath == ":") data.taskName else identityPath + ':' + data.taskName val ats = data.accessTransformers if (ats != null && ats.isNotEmpty()) { diff --git a/src/main/kotlin/platform/mcp/gradle/datahandler/McpModelNMDHandler.kt b/src/main/kotlin/platform/mcp/gradle/datahandler/McpModelNMDHandler.kt index 37e655c67..2275aeb91 100644 --- a/src/main/kotlin/platform/mcp/gradle/datahandler/McpModelNMDHandler.kt +++ b/src/main/kotlin/platform/mcp/gradle/datahandler/McpModelNMDHandler.kt @@ -44,8 +44,14 @@ object McpModelNMDHandler : McpModelDataHandler { ) { val data = resolverCtx.getExtraProject(gradleModule, McpModelNMD::class.java) ?: return + val minecraftVersion = when { + data.neoForgeVersion != null -> "1." + data.neoForgeVersion!!.substringBeforeLast('.').removeSuffix(".0") + data.neoFormVersion != null -> data.neoFormVersion!!.substringBeforeLast('-').removeSuffix(".0") + else -> null + } + val state = McpModuleSettings.State( - "1." + data.neoForgeVersion.substringBeforeLast('.').removeSuffix(".0"), + minecraftVersion, null, data.mappingsFile?.absolutePath, SrgType.TSRG, diff --git a/src/main/kotlin/platform/mixin/inspection/injector/InvalidInjectorMethodSignatureInspection.kt b/src/main/kotlin/platform/mixin/inspection/injector/InvalidInjectorMethodSignatureInspection.kt index e40188618..1f93e7b30 100644 --- a/src/main/kotlin/platform/mixin/inspection/injector/InvalidInjectorMethodSignatureInspection.kt +++ b/src/main/kotlin/platform/mixin/inspection/injector/InvalidInjectorMethodSignatureInspection.kt @@ -330,16 +330,17 @@ class InvalidInjectorMethodSignatureInspection : MixinInspection() { } val method = startElement as PsiMethod fixParameters(project, method.parameterList, false) - fixReturnType(method) - fixIntLikeTypes(method, editor ?: return) + fixReturnType(method, editor ?: return, file, false) + fixIntLikeTypes(method, editor, false) } override fun generatePreview(project: Project, editor: Editor, file: PsiFile): IntentionPreviewInfo { val method = PsiTreeUtil.findSameElementInCopy(startElement, file) as? PsiMethod ?: return IntentionPreviewInfo.EMPTY fixParameters(project, method.parameterList, true) - fixReturnType(method) - fixIntLikeTypes(method, editor) + // Pass the original startElement because the underlying fix gets the preview element itself + fixReturnType(startElement as PsiMethod, editor, file, true) + fixIntLikeTypes(method, editor, true) return IntentionPreviewInfo.DIFF } @@ -386,34 +387,43 @@ class InvalidInjectorMethodSignatureInspection : MixinInspection() { } } - private fun fixReturnType(method: PsiMethod) { + private fun fixReturnType(method: PsiMethod, editor: Editor, file: PsiFile, preview: Boolean) { if (expectedReturnType == null) { return } - QuickFixFactory.getInstance() - .createMethodReturnFix(method, expectedReturnType, false) - .applyFix() + val fix = QuickFixFactory.getInstance().createMethodReturnFix(method, expectedReturnType, false) + if (preview) { + fix.generatePreview(file.project, editor, file) + } else { + fix.applyFix() + } } - private fun fixIntLikeTypes(method: PsiMethod, editor: Editor) { + private fun fixIntLikeTypes(method: PsiMethod, editor: Editor, preview: Boolean) { if (intLikeTypePositions.isEmpty()) { return } - invokeLater { - WriteCommandAction.runWriteCommandAction( - method.project, - "Choose Int-Like Type", - null, - { - val template = makeIntLikeTypeTemplate(method, intLikeTypePositions) - if (template != null) { - editor.caretModel.moveToOffset(method.startOffset) - TemplateManager.getInstance(method.project) - .startTemplate(editor, template) - } - }, - method.parentOfType()!! - ) + val runnable = { + val template = makeIntLikeTypeTemplate(method, intLikeTypePositions) + if (template != null) { + editor.caretModel.moveToOffset(method.startOffset) + TemplateManager.getInstance(method.project) + .startTemplate(editor, template) + } + } + + if (preview) { + runnable() + } else { + invokeLater { + WriteCommandAction.runWriteCommandAction( + method.project, + "Choose Int-Like Type", + null, + runnable, + method.parentOfType()!! + ) + } } }