User: joe
Date: 28 May 25 19:33
Revision: 29e926b5e11b36dac39efc95f989c947d1d5cf59
Summary:
Update mock JDK to 21
TeamCity URL: https://ci.mcdev.io/viewModification.html?tab=vcsModificationFiles&modId=10031&personal=false
Index: build.gradle.kts
===================================================================
--- build.gradle.kts (revision b45618334f64fc6a8bab04c0d5bd94faf54e3644)
+++ build.gradle.kts (revision 29e926b5e11b36dac39efc95f989c947d1d5cf59)
@@ -121,7 +121,6 @@
pluginVerifier()
}
- testLibs(libs.test.mockJdk)
testLibs(libs.test.mixin)
testLibs(libs.test.spigotapi)
testLibs(libs.test.bungeecord)
Index: gradle/libs.versions.toml
===================================================================
--- gradle/libs.versions.toml (revision b45618334f64fc6a8bab04c0d5bd94faf54e3644)
+++ gradle/libs.versions.toml (revision 29e926b5e11b36dac39efc95f989c947d1d5cf59)
@@ -57,7 +57,6 @@
fuel-coroutines = { module = "com.github.kittinunf.fuel:fuel-coroutines", version.ref = "fuel" }
# Testing
-test-mockJdk = "org.jetbrains.idea:mock-jdk:1.7-4d76c50"
test-mixin = "org.spongepowered:mixin:0.8.5"
test-spigotapi = "org.spigotmc:spigot-api:1.21-R0.1-SNAPSHOT"
test-bungeecord = "net.md-5:bungeecord-api:1.21-R0.3-SNAPSHOT"
Index: src/test/kotlin/framework/MockJdk.kt
===================================================================
--- src/test/kotlin/framework/MockJdk.kt (revision b45618334f64fc6a8bab04c0d5bd94faf54e3644)
+++ src/test/kotlin/framework/MockJdk.kt (revision b45618334f64fc6a8bab04c0d5bd94faf54e3644)
@@ -1,71 +0,0 @@
-/*
- * Minecraft Development for IntelliJ
- *
- * https://mcdev.io/
- *
- * Copyright (C) 2025 minecraft-dev
- *
- * 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, version 3.0 only.
- *
- * 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
- * along with this program. If not, see .
- */
-
-package com.demonwav.mcdev.framework
-
-import com.intellij.openapi.Disposable
-import com.intellij.openapi.projectRoots.JavaSdk
-import com.intellij.openapi.projectRoots.Sdk
-import com.intellij.openapi.projectRoots.SdkAdditionalData
-import com.intellij.openapi.projectRoots.impl.ProjectJdkImpl
-import com.intellij.openapi.roots.OrderRootType
-import com.intellij.openapi.roots.RootProvider
-import com.intellij.openapi.vfs.VirtualFile
-import com.intellij.util.ArrayUtil
-import com.intellij.util.IncorrectOperationException
-
-@Suppress("NonExtendableApiUsage")
-class MockJdk(private val name: String, jar: VirtualFile, private val home: VirtualFile) :
- ProjectJdkImpl(name, JavaSdk.getInstance(), home.path, name), Sdk, RootProvider {
-
- private val urls = arrayOf(jar.url)
- private val roots = arrayOf(jar)
-
- override fun getVersionString() = name
-
- override fun getHomePath() = this.home.path
- override fun getHomeDirectory() = this.home
-
- override fun getRootProvider() = this
-
- override fun getSdkModificator() =
- throw IncorrectOperationException("Can't modify, MockJDK is read-only")
-
- override fun getSdkAdditionalData(): SdkAdditionalData? = null
-
- override fun clone() = throw CloneNotSupportedException()
-
- // Root provider
-
- override fun getUrls(rootType: OrderRootType): Array =
- if (rootType == OrderRootType.CLASSES) urls else ArrayUtil.EMPTY_STRING_ARRAY
-
- override fun getFiles(rootType: OrderRootType): Array =
- if (rootType == OrderRootType.CLASSES) roots else VirtualFile.EMPTY_ARRAY
-
- override fun addRootSetChangedListener(listener: RootProvider.RootSetChangedListener) {}
- override fun addRootSetChangedListener(
- listener: RootProvider.RootSetChangedListener,
- parentDisposable: Disposable,
- ) {
- }
-
- override fun removeRootSetChangedListener(listener: RootProvider.RootSetChangedListener) {}
-}
Index: src/test/kotlin/framework/test-util.kt
===================================================================
--- src/test/kotlin/framework/test-util.kt (revision b45618334f64fc6a8bab04c0d5bd94faf54e3644)
+++ src/test/kotlin/framework/test-util.kt (revision 29e926b5e11b36dac39efc95f989c947d1d5cf59)
@@ -36,6 +36,7 @@
import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.psi.PsiFile
import com.intellij.psi.impl.DebugUtil
+import com.intellij.testFramework.IdeaTestUtil
import com.intellij.testFramework.LexerTestCase
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture
import com.intellij.util.ReflectionUtil
@@ -50,11 +51,7 @@
const val BASE_DATA_PATH_2 = "\$PROJECT_ROOT/$BASE_DATA_PATH/"
val mockJdk by lazy {
- val path = findLibraryPath("mock-jdk")
- val rtFile = StandardFileSystems.local().findFileByPath(path)!!
- val rt = JarFileSystem.getInstance().getRootByLocal(rtFile)!!
- val home = rtFile.parent!!
- MockJdk("1.7", rt, home)
+ IdeaTestUtil.getMockJdk21()
}
fun findLibraryPath(name: String) = FileUtil.toSystemIndependentName(System.getProperty("testLibs.$name")!!)