User: kyle wood
Date: 30 Jan 23 03:46
Revision: 63c93fe73a189c36c3dd875c1319b0d44f05611d
Summary:
Move more build logic to buildSrc
TeamCity URL: https://ci.mcdev.io/viewModification.html?tab=vcsModificationFiles&modId=9634&personal=false
Index: build.gradle.kts
===================================================================
--- build.gradle.kts (revision ef48c70086389b88b6a2afe9eb9e4e5b6f9e9430)
+++ build.gradle.kts (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
@@ -18,52 +18,37 @@
* along with this program. If not, see .
*/
-import org.cadixdev.gradle.licenser.header.HeaderStyle
-import org.cadixdev.gradle.licenser.tasks.LicenseUpdate
import org.gradle.internal.jvm.Jvm
import org.jetbrains.changelog.Changelog
import org.jetbrains.gradle.ext.settings
import org.jetbrains.gradle.ext.taskTriggers
import org.jetbrains.intellij.tasks.PrepareSandboxTask
-import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-import org.jlleitschuh.gradle.ktlint.tasks.BaseKtLintCheckTask
-import org.jlleitschuh.gradle.ktlint.tasks.KtLintFormatTask
plugins {
- kotlin("jvm") version "1.9.20"
java
- mcdev
groovy
idea
- id("org.jetbrains.intellij") version "1.17.2"
- id("org.cadixdev.licenser")
- id("org.jlleitschuh.gradle.ktlint") version "10.3.0"
- id("org.jetbrains.changelog") version "2.2.0"
+ id(libs.plugins.kotlin.get().pluginId)
+ id(libs.plugins.intellij.get().pluginId)
+ id(libs.plugins.licenser.get().pluginId)
+ id(libs.plugins.ktlint.get().pluginId)
+ id(libs.plugins.changelog.get().pluginId)
+ `mcdev-core`
+ `mcdev-parsing`
+ `mcdev-publishing`
}
val ideaVersionName: String by project
val coreVersion: String by project
-val pluginTomlVersion: String by project
val gradleToolingExtension: Configuration by configurations.creating
val testLibs: Configuration by configurations.creating {
isTransitive = false
}
-group = "com.demonwav.minecraft-dev"
+group = "com.demonwav.mcdev"
version = "$ideaVersionName-$coreVersion"
-java {
- toolchain {
- languageVersion.set(JavaLanguageVersion.of(17))
- }
-}
-kotlin {
- jvmToolchain {
- languageVersion.set(java.toolchain.languageVersion.get())
- }
-}
-
val gradleToolingExtensionSourceSet: SourceSet = sourceSets.create("gradle-tooling-extension") {
configurations.named(compileOnlyConfigurationName) {
extendsFrom(gradleToolingExtension)
@@ -100,59 +85,20 @@
archiveFileName.set("externalAnnotations.jar")
}
-repositories {
- maven("https://repo.denwav.dev/repository/maven-public/")
- maven("https://maven.fabricmc.net/") {
- content {
- includeModule("net.fabricmc", "mapping-io")
- includeModule("net.fabricmc", "fabric-loader")
- }
- }
- mavenCentral()
- maven("https://repo.spongepowered.org/maven/") {
- content {
- includeGroup("org.spongepowered")
- }
- }
- maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") {
- content {
- includeGroup("org.spigotmc")
- }
- }
- maven("https://oss.sonatype.org/content/repositories/snapshots/") {
- content {
- includeGroup("net.md-5")
- }
- }
-}
-
dependencies {
// Add tools.jar for the JDI API
implementation(files(Jvm.current().toolsJar))
+ implementation(files(gradleToolingExtensionJar))
+
implementation(libs.mixinExtras.expressions)
testLibs(libs.mixinExtras.common)
- // Kotlin
- implementation(kotlin("stdlib-jdk8"))
- implementation(kotlin("reflect"))
- implementation(libs.bundles.coroutines)
-
- implementation(files(gradleToolingExtensionJar))
-
implementation(libs.mappingIo)
implementation(libs.bundles.asm)
implementation(libs.bundles.fuel)
- jflex(libs.jflex.lib)
- jflexSkeleton(libs.jflex.skeleton) {
- artifact {
- extension = "skeleton"
- }
- }
- grammarKit(libs.grammarKit)
-
testLibs(libs.test.mockJdk)
testLibs(libs.test.mixin)
testLibs(libs.test.spigotapi)
@@ -197,7 +143,7 @@
to.attribute(filtered, true).attribute(artifactType, "jar")
parameters {
- ideaVersion.set(providers.gradleProperty("ideaVersion"))
+ ideaVersion.set(libs.versions.intellij.ide)
ideaVersionName.set(providers.gradleProperty("ideaVersionName"))
depsFile.set(layout.projectDirectory.file(".gradle/intellij-deps.json"))
}
@@ -215,8 +161,6 @@
}
intellij {
- // IntelliJ IDEA dependency
- version.set(providers.gradleProperty("ideaVersion"))
// Bundled plugin dependencies
plugins.addAll(
"java",
@@ -224,7 +168,6 @@
"gradle",
"Groovy",
"Kotlin",
- "org.toml.lang:$pluginTomlVersion",
"ByteCodeViewer",
"org.intellij.intelliLang",
"properties",
@@ -232,13 +175,9 @@
// needed dependencies for unit tests
"junit"
)
+ plugins.addProvider(libs.versions.pluginToml.map { "org.toml.lang:$it" })
pluginName.set("Minecraft Development")
- updateSinceUntilBuild.set(true)
-
- downloadSources.set(providers.gradleProperty("downloadIdeaSources").map { it.toBoolean() })
-
- sandboxDir.set(layout.projectDirectory.dir(".sandbox").toString())
}
tasks.patchPluginXml {
@@ -246,36 +185,10 @@
changeNotes = changelog.render(Changelog.OutputType.HTML)
}
-tasks.publishPlugin {
- // Build numbers are used for
- properties["buildNumber"]?.let { buildNumber ->
- project.version = "${project.version}-$buildNumber"
- }
- properties["mcdev.deploy.token"]?.let { deployToken ->
- token.set(deployToken.toString())
- }
- channels.add(properties["mcdev.deploy.channel"]?.toString() ?: "Stable")
-}
-
tasks.runPluginVerifier {
ideVersions.addAll("IC-$ideaVersionName")
}
-tasks.withType().configureEach {
- options.encoding = "UTF-8"
- options.compilerArgs = listOf("-proc:none")
- options.release.set(17)
-}
-
-tasks.withType().configureEach {
- kotlinOptions {
- jvmTarget = JavaVersion.VERSION_17.toString()
- // K2 causes the following error: https://youtrack.jetbrains.com/issue/KT-52786
- freeCompilerArgs = listOf(/*"-Xuse-k2", */"-Xjvm-default=all", "-Xjdk-release=17")
- kotlinDaemonJvmArguments.add("-Xmx2G")
- }
-}
-
// Compile classes to be loaded into the Gradle VM to Java 5 to match Groovy
// This is for maximum compatibility, these classes will be loaded into every Gradle import on all
// projects (not just Minecraft), so we don't want to break that with an incompatible class version.
@@ -311,11 +224,12 @@
tasks.test {
dependsOn(tasks.jar, testLibs)
- useJUnitPlatform()
+ doFirst {
- testLibs.resolvedConfiguration.resolvedArtifacts.forEach {
- systemProperty("testLibs.${it.name}", it.file.absolutePath)
- }
+ testLibs.resolvedConfiguration.resolvedArtifacts.forEach {
+ systemProperty("testLibs.${it.name}", it.file.absolutePath)
+ }
+ }
systemProperty("NO_FS_ROOTS_ACCESS_CHECK", "true")
systemProperty("java.awt.headless", "true")
@@ -327,19 +241,9 @@
idea {
project.settings.taskTriggers.afterSync("generate")
- module {
- generatedSourceDirs.add(file("build/gen"))
- excludeDirs.add(file(intellij.sandboxDir.get()))
- isDownloadJavadoc = true
- isDownloadSources = true
- }
+}
-}
license {
- header.set(resources.text.fromFile(file("copyright.txt")))
- style["flex"] = HeaderStyle.BLOCK_COMMENT.format
- style["bnf"] = HeaderStyle.BLOCK_COMMENT.format
-
val endings = listOf("java", "kt", "kts", "groovy", "gradle.kts", "xml", "properties", "html", "flex", "bnf")
exclude("META-INF/plugin.xml") // https://youtrack.jetbrains.com/issue/IDEA-345026
include(endings.map { "**/*.$it" })
@@ -385,19 +289,6 @@
}
}
-ktlint {
- disabledRules.add("filename")
-}
-tasks.withType().configureEach {
- workerMaxHeapSize.set("512m")
-}
-
-tasks.register("format") {
- group = "minecraft"
- description = "Formats source code according to project style"
- dependsOn(tasks.withType(), tasks.withType())
-}
-
val generateAtLexer by lexer("AtLexer", "com/demonwav/mcdev/platform/mcp/at/gen")
val generateAtParser by parser("AtParser", "com/demonwav/mcdev/platform/mcp/at/gen")
@@ -442,12 +333,6 @@
// Remove gen directory on clean
tasks.clean { delete(generate) }
-tasks.register("cleanSandbox", Delete::class) {
- group = "intellij"
- description = "Deletes the sandbox directory."
- delete(layout.projectDirectory.dir(".sandbox"))
-}
-
tasks.withType {
pluginJar.set(tasks.jar.get().archiveFile)
from(externalAnnotationsJar) {
Index: buildSrc/build.gradle.kts
===================================================================
--- buildSrc/build.gradle.kts (revision ef48c70086389b88b6a2afe9eb9e4e5b6f9e9430)
+++ buildSrc/build.gradle.kts (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
@@ -18,16 +18,51 @@
* along with this program. If not, see .
*/
+import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
+
+/*
+ * Minecraft Development for IntelliJ
+ *
+ * https://mcdev.io/
+ *
+ * Copyright (C) 2024 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 .
+ */
+
plugins {
`kotlin-dsl`
}
+tasks.withType().configureEach {
+ options.release.set(8)
+}
+tasks.withType().configureEach {
+ kotlinOptions.jvmTarget = "1.8"
+}
+
repositories {
mavenCentral()
gradlePluginPortal()
}
dependencies {
- implementation("com.google.code.gson:gson:2.9.1")
- implementation("org.cadixdev.licenser:org.cadixdev.licenser.gradle.plugin:0.6.1")
+ // hack for version catalogs
+ implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
+ implementation(libs.gson)
+ implementation(libs.kotlin.plugin)
+ implementation(libs.intellij.plugin)
+ implementation(libs.licenser.plugin)
+ implementation(libs.ktlint.plugin)
+ implementation(libs.changelog.plugin)
}
Index: buildSrc/settings.gradle.kts
===================================================================
--- buildSrc/settings.gradle.kts (revision ef48c70086389b88b6a2afe9eb9e4e5b6f9e9430)
+++ buildSrc/settings.gradle.kts (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
@@ -19,3 +19,11 @@
*/
rootProject.name = "buildSrc"
+
+dependencyResolutionManagement {
+ versionCatalogs {
+ create("libs") {
+ from(files("../gradle/libs.versions.toml"))
+ }
+ }
+}
Index: buildSrc/src/main/kotlin/ParserExec.kt
===================================================================
--- buildSrc/src/main/kotlin/ParserExec.kt (revision ef48c70086389b88b6a2afe9eb9e4e5b6f9e9430)
+++ buildSrc/src/main/kotlin/ParserExec.kt (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
@@ -62,6 +62,7 @@
init {
mainClass.set("org.intellij.grammar.Main")
+ @Suppress("LeakingThis")
jvmArgs(
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
"--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED",
Index: buildSrc/src/main/kotlin/mcdev-core.gradle.kts
===================================================================
--- buildSrc/src/main/kotlin/mcdev-core.gradle.kts (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
+++ buildSrc/src/main/kotlin/mcdev-core.gradle.kts (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
@@ -0,0 +1,241 @@
+/*
+ * Minecraft Development for IntelliJ
+ *
+ * https://mcdev.io/
+ *
+ * Copyright (C) 2024 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 .
+ */
+
+import com.google.gson.Gson
+import com.google.gson.GsonBuilder
+import java.net.HttpURLConnection
+import java.net.URI
+import java.util.Properties
+import java.util.zip.ZipFile
+import org.cadixdev.gradle.licenser.header.HeaderStyle
+import org.gradle.kotlin.dsl.maven
+import org.gradle.kotlin.dsl.repositories
+import org.gradle.kotlin.dsl.withType
+import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
+import org.gradle.accessors.dm.LibrariesForLibs
+import org.jetbrains.kotlin.gradle.dsl.JvmTarget
+import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
+import org.jlleitschuh.gradle.ktlint.tasks.BaseKtLintCheckTask
+
+plugins {
+ java
+ idea
+ id("org.jetbrains.kotlin.jvm")
+ id("org.jetbrains.intellij")
+ id("org.cadixdev.licenser")
+ id("org.jlleitschuh.gradle.ktlint")
+}
+
+java {
+ toolchain {
+ languageVersion.set(JavaLanguageVersion.of(17))
+ }
+}
+
+tasks.withType().configureEach {
+ options.encoding = "UTF-8"
+ options.compilerArgs = listOf("-proc:none")
+ options.release.set(17)
+}
+
+kotlin {
+ jvmToolchain {
+ languageVersion.set(JavaLanguageVersion.of(17))
+ }
+}
+
+tasks.withType().configureEach {
+ compilerOptions {
+ jvmTarget = JvmTarget.JVM_17
+ languageVersion = KotlinVersion.KOTLIN_2_0
+ freeCompilerArgs = listOf("-Xjvm-default=all", "-Xjdk-release=17")
+ optIn.add("kotlin.contracts.ExperimentalContracts")
+ }
+ kotlinDaemonJvmArguments.add("-Xmx2G")
+}
+
+repositories {
+ maven("https://repo.denwav.dev/repository/maven-public/")
+ maven("https://maven.fabricmc.net/") {
+ content {
+ includeModule("net.fabricmc", "mapping-io")
+ includeModule("net.fabricmc", "fabric-loader")
+ }
+ }
+ mavenCentral()
+ maven("https://repo.spongepowered.org/maven/") {
+ content {
+ includeGroup("org.spongepowered")
+ }
+ }
+ maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") {
+ content {
+ includeGroup("org.spigotmc")
+ }
+ }
+ maven("https://oss.sonatype.org/content/repositories/snapshots/") {
+ content {
+ includeGroup("net.md-5")
+ }
+ }
+}
+
+val libs = the()
+dependencies {
+ implementation(libs.kotlin.stdlib)
+ implementation(libs.kotlin.reflect)
+ implementation(libs.bundles.coroutines)
+
+ testImplementation(libs.junit.api)
+ testRuntimeOnly(libs.junit.entine)
+ testRuntimeOnly(libs.junit.platform.launcher)
+}
+
+intellij {
+ // IntelliJ IDEA dependency
+ version.set(libs.versions.intellij.ide)
+
+ updateSinceUntilBuild.set(true)
+ downloadSources.set(providers.gradleProperty("downloadIdeaSources").map { it.toBoolean() })
+
+ sandboxDir.set(layout.projectDirectory.dir(".sandbox").toString())
+}
+
+license {
+ header.set(resources.text.fromFile(rootProject.layout.projectDirectory.file("copyright.txt")))
+ style["flex"] = HeaderStyle.BLOCK_COMMENT.format
+ style["bnf"] = HeaderStyle.BLOCK_COMMENT.format
+
+ val endings = listOf("java", "kt", "kts", "groovy", "gradle.kts", "xml", "properties", "html", "flex", "bnf")
+ include(endings.map { "**/*.$it" })
+}
+
+idea {
+ module {
+ excludeDirs.add(file(intellij.sandboxDir.get()))
+ }
+}
+
+tasks.withType().configureEach {
+ workerMaxHeapSize = "512m"
+}
+
+tasks.runIde {
+ maxHeapSize = "2G"
+ jvmArgs("--add-exports=java.base/jdk.internal.vm=ALL-UNNAMED")
+}
+
+tasks.register("cleanSandbox", Delete::class) {
+ group = "intellij"
+ description = "Deletes the sandbox directory."
+ delete(layout.projectDirectory.dir(".sandbox"))
+}
+
+tasks.test {
+ useJUnitPlatform()
+}
+
+tasks.register("format") {
+ group = "minecraft"
+ description = "Formats source code according to project style"
+ dependsOn(tasks.licenseFormat, tasks.ktlintFormat)
+}
+
+// Analyze dependencies
+val fileName = ".gradle/intellij-deps.json"
+val jsonFile = file("$projectDir/$fileName")
+
+val ideaVersion: String by project
+val ideaVersionName: String by project
+
+if (jsonFile.exists()) {
+ val deps: DepList = jsonFile.bufferedReader().use { reader ->
+ Gson().fromJson(reader, DepList::class.java)
+ }
+ if (ideaVersion != deps.intellijVersion || ideaVersionName != deps.intellijVersionName) {
+ println("IntelliJ library sources file definition is out of date, deleting")
+ jsonFile.delete()
+ } else {
+ dependencies {
+ for ((groupId, artifactId, version) in deps.deps) {
+ compileOnly(
+ group = groupId,
+ name = artifactId,
+ version = version
+ )
+ }
+ }
+ }
+}
+
+tasks.register("resolveIntellijLibSources") {
+ group = "minecraft"
+ val compileClasspath by project.configurations
+ dependsOn(compileClasspath)
+
+ doLast {
+ val files = compileClasspath.resolvedConfiguration.files
+ val deps = files.asSequence()
+ .map { it.toPath() }
+ .filter {
+ it.map { part -> part.toString() }.containsAll(listOf("com.jetbrains.intellij.idea", "ideaIC", "lib"))
+ }
+ .filter { it.fileName.toString().endsWith(".jar") }
+ .mapNotNull { lib ->
+ val name = lib.fileName.toString()
+ return@mapNotNull ZipFile(lib.toFile()).use { zipFile ->
+ val pomEntry = zipFile.stream()
+ .filter { entry ->
+ val entryName = entry.name
+ entryName.contains("META-INF/maven")
+ && entryName.split('/').any { name.contains(it) }
+ && entryName.endsWith("pom.properties")
+ }
+ .findFirst()
+ .orElse(null) ?: return@use null
+ return@use zipFile.getInputStream(pomEntry).use { input ->
+ val props = Properties()
+ props.load(input)
+ Dep(props["groupId"].toString(), props["artifactId"].toString(), props["version"].toString())
+ }
+ }
+ }.filter { dep ->
+ // Check if this dependency is available in Maven Central
+ val groupPath = dep.groupId.replace('.', '/')
+ val (_, artifact, ver) = dep
+ val url = "https://repo.maven.apache.org/maven2/$groupPath/$artifact/$ver/$artifact-$ver-sources.jar"
+ return@filter with(URI.create(url).toURL().openConnection() as HttpURLConnection) {
+ try {
+ requestMethod = "GET"
+ val code = responseCode
+ return@with code in 200..299
+ } finally {
+ disconnect()
+ }
+ }
+ }.toList()
+
+ val depList = DepList(ideaVersion, ideaVersionName, deps.sortedWith(compareBy { it.groupId }.thenBy { it.artifactId }))
+ jsonFile.parentFile.mkdirs()
+ jsonFile.bufferedWriter().use { writer ->
+ GsonBuilder().setPrettyPrinting().create().toJson(depList, writer)
+ }
+ }
+}
Index: buildSrc/src/main/kotlin/mcdev-parsing.gradle.kts
===================================================================
--- buildSrc/src/main/kotlin/mcdev-parsing.gradle.kts (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
+++ buildSrc/src/main/kotlin/mcdev-parsing.gradle.kts (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
@@ -0,0 +1,46 @@
+/*
+ * Minecraft Development for IntelliJ
+ *
+ * https://mcdev.io/
+ *
+ * Copyright (C) 2024 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 .
+ */
+
+import org.gradle.accessors.dm.LibrariesForLibs
+
+plugins {
+ idea
+}
+
+val jflex: Configuration by configurations.creating
+val jflexSkeleton: Configuration by configurations.creating
+val grammarKit: Configuration by configurations.creating
+
+val libs = the()
+dependencies {
+ jflex(libs.jflex.lib)
+ jflexSkeleton(libs.jflex.skeleton) {
+ artifact {
+ extension = "skeleton"
+ }
+ }
+ grammarKit(libs.grammarKit)
+}
+
+idea {
+ module {
+ generatedSourceDirs.add(file("build/gen"))
+ }
+}
Index: buildSrc/src/main/kotlin/mcdev-publishing.gradle.kts
===================================================================
--- buildSrc/src/main/kotlin/mcdev-publishing.gradle.kts (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
+++ buildSrc/src/main/kotlin/mcdev-publishing.gradle.kts (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
@@ -0,0 +1,34 @@
+/*
+ * Minecraft Development for IntelliJ
+ *
+ * https://mcdev.io/
+ *
+ * Copyright (C) 2024 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 .
+ */
+
+plugins {
+ id("org.jetbrains.intellij")
+}
+
+tasks.publishPlugin {
+ // Build numbers are used for nightlies
+ properties["buildNumber"]?.let { buildNumber ->
+ project.version = "${project.version}-$buildNumber"
+ }
+ properties["mcdev.deploy.token"]?.let { deployToken ->
+ token.set(deployToken.toString())
+ }
+ channels.add(properties["mcdev.deploy.channel"]?.toString() ?: "Stable")
+}
Index: buildSrc/src/main/kotlin/mcdev.gradle.kts
===================================================================
--- buildSrc/src/main/kotlin/mcdev.gradle.kts (revision ef48c70086389b88b6a2afe9eb9e4e5b6f9e9430)
+++ buildSrc/src/main/kotlin/mcdev.gradle.kts (revision ef48c70086389b88b6a2afe9eb9e4e5b6f9e9430)
@@ -1,114 +0,0 @@
-/*
- * Minecraft Development for IntelliJ
- *
- * https://mcdev.io/
- *
- * Copyright (C) 2024 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 .
- */
-
-import com.google.gson.Gson
-import com.google.gson.GsonBuilder
-import com.google.gson.reflect.TypeToken
-import java.net.HttpURLConnection
-import java.net.URI
-import java.net.URL
-import java.util.Properties
-import java.util.zip.ZipFile
-
-val jflex: Configuration by configurations.creating
-val jflexSkeleton: Configuration by configurations.creating
-val grammarKit: Configuration by configurations.creating
-val compileOnly by configurations
-
-// Analyze dependencies
-val fileName = ".gradle/intellij-deps.json"
-val jsonFile = file("$projectDir/$fileName")
-
-val ideaVersion: String by project
-val ideaVersionName: String by project
-
-if (jsonFile.exists()) {
- val deps: DepList = jsonFile.bufferedReader().use { reader ->
- Gson().fromJson(reader, DepList::class.java)
- }
- if (ideaVersion != deps.intellijVersion || ideaVersionName != deps.intellijVersionName) {
- println("IntelliJ library sources file definition is out of date, deleting")
- jsonFile.delete()
- } else {
- dependencies {
- for ((groupId, artifactId, version) in deps.deps) {
- compileOnly(
- group = groupId,
- name = artifactId,
- version = version
- )
- }
- }
- }
-}
-
-tasks.register("resolveIntellijLibSources") {
- group = "minecraft"
- val compileClasspath by project.configurations
- dependsOn(compileClasspath)
-
- doLast {
- val files = compileClasspath.resolvedConfiguration.files
- val deps = files.asSequence()
- .map { it.toPath() }
- .filter {
- it.map { part -> part.toString() }.containsAll(listOf("com.jetbrains.intellij.idea", "ideaIC", "lib"))
- }
- .filter { it.fileName.toString().endsWith(".jar") }
- .mapNotNull { lib ->
- val name = lib.fileName.toString()
- return@mapNotNull ZipFile(lib.toFile()).use { zipFile ->
- val pomEntry = zipFile.stream()
- .filter { entry ->
- val entryName = entry.name
- entryName.contains("META-INF/maven")
- && entryName.split('/').any { name.contains(it) }
- && entryName.endsWith("pom.properties")
- }
- .findFirst()
- .orElse(null) ?: return@use null
- return@use zipFile.getInputStream(pomEntry).use { input ->
- val props = Properties()
- props.load(input)
- Dep(props["groupId"].toString(), props["artifactId"].toString(), props["version"].toString())
- }
- }
- }.filter { dep ->
- // Check if this dependency is available in Maven Central
- val groupPath = dep.groupId.replace('.', '/')
- val (_, artifact, ver) = dep
- val url = "https://repo.maven.apache.org/maven2/$groupPath/$artifact/$ver/$artifact-$ver-sources.jar"
- return@filter with(URI.create(url).toURL().openConnection() as HttpURLConnection) {
- try {
- requestMethod = "GET"
- val code = responseCode
- return@with code in 200..299
- } finally {
- disconnect()
- }
- }
- }.toList()
-
- val depList = DepList(ideaVersion, ideaVersionName, deps.sortedWith(compareBy { it.groupId }.thenBy { it.artifactId }))
- jsonFile.bufferedWriter().use { writer ->
- GsonBuilder().setPrettyPrinting().create().toJson(depList, writer)
- }
- }
-}
Index: buildSrc/src/main/kotlin/util.kt
===================================================================
--- buildSrc/src/main/kotlin/util.kt (revision ef48c70086389b88b6a2afe9eb9e4e5b6f9e9430)
+++ buildSrc/src/main/kotlin/util.kt (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
@@ -22,19 +22,23 @@
import org.cadixdev.gradle.licenser.LicenseExtension
import org.gradle.api.JavaVersion
import org.gradle.api.Project
+import org.gradle.api.provider.ListProperty
+import org.gradle.api.provider.Provider
import org.gradle.api.tasks.JavaExec
import org.gradle.api.tasks.TaskContainer
-import org.gradle.api.tasks.TaskProvider
+import org.gradle.api.tasks.util.PatternFilterable
import org.gradle.kotlin.dsl.RegisteringDomainObjectDelegateProviderWithTypeAndAction
import org.gradle.kotlin.dsl.getValue
import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.registering
import org.gradle.kotlin.dsl.configure
+fun ListProperty.addProvider(provider: Provider) = add(provider)
+
typealias TaskDelegate = RegisteringDomainObjectDelegateProviderWithTypeAndAction
fun Project.lexer(flex: String, pack: String): TaskDelegate {
- configure {
+ extensions.configure("license") {
exclude(pack.removeSuffix("/") + "/**")
}
@@ -53,7 +57,7 @@
}
fun Project.parser(bnf: String, pack: String): TaskDelegate {
- configure {
+ extensions.configure("license") {
exclude(pack.removeSuffix("/") + "/**")
}
Index: gradle.properties
===================================================================
--- gradle.properties (revision ef48c70086389b88b6a2afe9eb9e4e5b6f9e9430)
+++ gradle.properties (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
@@ -19,15 +19,10 @@
#
# suppress inspection "UnusedProperty" for whole file
-kotlin.code.style=official
-
-ideaVersion = 2023.2.2
ideaVersionName = 2023.2.2
coreVersion = 1.8.1
downloadIdeaSources = true
-pluginTomlVersion = 232.8660.88
-
# Silences a build-time warning because we are bundling our own kotlin library
kotlin.stdlib.default.dependency = false
Index: gradle/libs.versions.toml
===================================================================
--- gradle/libs.versions.toml (revision ef48c70086389b88b6a2afe9eb9e4e5b6f9e9430)
+++ gradle/libs.versions.toml (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
@@ -1,11 +1,35 @@
[versions]
-coroutines = "1.6.4"
-junit = "5.9.0"
-junit-platform = "1.9.0"
-asm = "9.3"
+kotlin = "2.0.0"
+coroutines = "1.8.0-RC2"
+junit = "5.10.2"
+junit-platform = "1.10.2"
+asm = "9.6"
fuel = "2.3.1"
+licenser = "0.6.1"
+ktlint = "10.3.0"
+changelog = "2.2.0"
+intellij-plugin = "1.17.2"
+intellij-ide = "2023.2.2"
+pluginToml = "232.8660.88"
+psiPlugin = "232.2-SNAPSHOT"
+[plugins]
+kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
+intellij = { id = "org.jetbrains.intellij", version.ref = "intellij-plugin" }
+licenser = { id = "org.cadixdev.licenser", version.ref = "licenser" }
+ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
+changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
+
[libraries]
+kotlin-plugin = { module = "org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin", version.ref = "kotlin" }
+kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
+kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
+
+intellij-plugin = { module = "org.jetbrains.intellij:org.jetbrains.intellij.gradle.plugin", version.ref = "intellij-plugin" }
+licenser-plugin = { module = "org.cadixdev.licenser:org.cadixdev.licenser.gradle.plugin", version.ref = "licenser" }
+ktlint-plugin = { module = "org.jlleitschuh.gradle.ktlint:org.jlleitschuh.gradle.ktlint.gradle.plugin", version.ref = "ktlint" }
+changelog-plugin = { module = "org.jetbrains.changelog:org.jetbrains.changelog.gradle.plugin", version.ref = "changelog" }
+
coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
coroutines-jdk8 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8", version.ref = "coroutines" }
coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-swing", version.ref = "coroutines" }
@@ -20,7 +44,7 @@
# Gradle Tooling
gradleToolingExtension = "com.jetbrains.intellij.gradle:gradle-tooling-extension:232-EAP-SNAPSHOT"
-annotations = "org.jetbrains:annotations:23.0.0"
+annotations = "org.jetbrains:annotations:24.0.0"
groovy = "org.codehaus.groovy:groovy-all:2.5.18"
asm = { module = "org.ow2.asm:asm", version.ref = "asm" }
@@ -28,6 +52,8 @@
asm-analysis = { module = "org.ow2.asm:asm-analysis", version.ref = "asm" }
asm-util = { module = "org.ow2.asm:asm-util", version.ref = "asm" }
+gson = "com.google.code.gson:gson:2.10.1"
+
fuel = { module = "com.github.kittinunf.fuel:fuel", version.ref = "fuel" }
fuel-coroutines = { module = "com.github.kittinunf.fuel:fuel-coroutines", version.ref = "fuel" }
Index: readme.md
===================================================================
--- readme.md (revision ef48c70086389b88b6a2afe9eb9e4e5b6f9e9430)
+++ readme.md (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
@@ -128,7 +128,7 @@
License
-------
-This project is licensed under [MIT](license.txt).
+This project is licensed under [LGPLv3.0-only](license.txt).
Supported Platforms
-------------------
Index: src/main/grammars/AtParser.bnf
===================================================================
--- src/main/grammars/AtParser.bnf (revision ef48c70086389b88b6a2afe9eb9e4e5b6f9e9430)
+++ src/main/grammars/AtParser.bnf (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
@@ -38,7 +38,7 @@
at_file ::= line*
private line ::= !<> entry? COMMENT? end_line
-private end_line ::= crlf | <>
+private end_line ::= CRLF | <>
entry ::= keyword class_name line_value? {
mixin="com.demonwav.mcdev.platform.mcp.at.psi.mixins.impl.AtEntryImplMixin"
Index: src/main/kotlin/facet/MinecraftFacet.kt
===================================================================
--- src/main/kotlin/facet/MinecraftFacet.kt (revision ef48c70086389b88b6a2afe9eb9e4e5b6f9e9430)
+++ src/main/kotlin/facet/MinecraftFacet.kt (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
@@ -250,7 +250,7 @@
val ID = FacetTypeId(TYPE_ID)
val facetType: MinecraftFacetType
- get() = FacetTypeRegistry.getInstance().findFacetType(ID) as MinecraftFacetType
+ get() = facetTypeOrNull as MinecraftFacetType
val facetTypeOrNull: MinecraftFacetType?
get() = FacetTypeRegistry.getInstance().findFacetType(TYPE_ID) as? MinecraftFacetType
Index: src/main/kotlin/nbt/filetype/NbtFileTypeDetector.kt
===================================================================
--- src/main/kotlin/nbt/filetype/NbtFileTypeDetector.kt (revision ef48c70086389b88b6a2afe9eb9e4e5b6f9e9430)
+++ src/main/kotlin/nbt/filetype/NbtFileTypeDetector.kt (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
@@ -31,6 +31,10 @@
class NbtFileTypeDetector : FileTypeRegistry.FileTypeDetector {
override fun detect(file: VirtualFile, firstBytes: ByteSequence, firstCharsIfText: CharSequence?): FileType? {
+ if (firstCharsIfText != null) {
+ return null
+ }
+
return try {
// 20 ms is plenty of time to parse most files
// Won't parse very large files, but if we fail on timeout then those files probably are NBT anyways
Index: src/main/kotlin/nbt/lang/colors/NbttSyntaxHighlighter.kt
===================================================================
--- src/main/kotlin/nbt/lang/colors/NbttSyntaxHighlighter.kt (revision ef48c70086389b88b6a2afe9eb9e4e5b6f9e9430)
+++ src/main/kotlin/nbt/lang/colors/NbttSyntaxHighlighter.kt (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
@@ -42,7 +42,7 @@
NbttTypes.LONG_LITERAL -> LONG_KEYS
NbttTypes.FLOAT_LITERAL -> FLOAT_KEYS
NbttTypes.DOUBLE_LITERAL -> DOUBLE_KEYS
- else -> EMPTY_KEYS
+ else -> TextAttributesKey.EMPTY_ARRAY
}
}
@@ -70,6 +70,5 @@
val LONG_KEYS = arrayOf(LONG)
val FLOAT_KEYS = arrayOf(FLOAT)
val DOUBLE_KEYS = arrayOf(DOUBLE)
- val EMPTY_KEYS = emptyArray()
}
}
Index: src/main/kotlin/platform/mcp/at/AtFile.kt
===================================================================
--- src/main/kotlin/platform/mcp/at/AtFile.kt (revision ef48c70086389b88b6a2afe9eb9e4e5b6f9e9430)
+++ src/main/kotlin/platform/mcp/at/AtFile.kt (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
@@ -47,6 +47,6 @@
}
override fun getFileType() = AtFileType
- override fun toString() = "Access Transformer File"
+ override fun toString() = AtFileType.description
override fun getIcon(flags: Int) = PlatformAssets.MCP_ICON
}
Index: src/main/kotlin/platform/mcp/at/AtFileType.kt
===================================================================
--- src/main/kotlin/platform/mcp/at/AtFileType.kt (revision ef48c70086389b88b6a2afe9eb9e4e5b6f9e9430)
+++ src/main/kotlin/platform/mcp/at/AtFileType.kt (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
@@ -26,7 +26,7 @@
object AtFileType : LanguageFileType(AtLanguage) {
override fun getName() = "Access Transformers"
- override fun getDescription() = "Access transformers"
+ override fun getDescription() = "Access Transformers"
override fun getDefaultExtension() = ""
override fun getIcon() = PlatformAssets.MCP_ICON
}
Index: src/main/kotlin/platform/mcp/at/AtParserDefinition.kt
===================================================================
--- src/main/kotlin/platform/mcp/at/AtParserDefinition.kt (revision ef48c70086389b88b6a2afe9eb9e4e5b6f9e9430)
+++ src/main/kotlin/platform/mcp/at/AtParserDefinition.kt (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
@@ -28,7 +28,6 @@
import com.intellij.openapi.project.Project
import com.intellij.psi.FileViewProvider
import com.intellij.psi.PsiElement
-import com.intellij.psi.TokenType
import com.intellij.psi.tree.IElementType
import com.intellij.psi.tree.IFileElementType
import com.intellij.psi.tree.TokenSet
@@ -36,7 +35,6 @@
class AtParserDefinition : ParserDefinition {
override fun createLexer(project: Project) = AtLexerAdapter()
- override fun getWhitespaceTokens() = WHITE_SPACES
override fun getCommentTokens() = COMMENTS
override fun getStringLiteralElements(): TokenSet = TokenSet.EMPTY
override fun createParser(project: Project) = AtParser()
@@ -49,7 +47,6 @@
?: ParserDefinition.SpaceRequirements.MUST_NOT
companion object {
- private val WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE)
private val COMMENTS = TokenSet.create(AtTypes.COMMENT)
private val FILE = IFileElementType(Language.findInstance(AtLanguage::class.java))
Index: src/main/kotlin/platform/mcp/at/AtSyntaxHighlighter.kt
===================================================================
--- src/main/kotlin/platform/mcp/at/AtSyntaxHighlighter.kt (revision ef48c70086389b88b6a2afe9eb9e4e5b6f9e9430)
+++ src/main/kotlin/platform/mcp/at/AtSyntaxHighlighter.kt (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
@@ -32,7 +32,7 @@
override fun getHighlightingLexer() = AtLexerAdapter()
- override fun getTokenHighlights(tokenType: IElementType) =
+ override fun getTokenHighlights(tokenType: IElementType?): Array =
when (tokenType) {
AtTypes.KEYWORD_ELEMENT -> KEYWORD_KEYS
AtTypes.CLASS_NAME_ELEMENT -> CLASS_NAME_KEYS
@@ -42,7 +42,7 @@
AtTypes.PRIMITIVE -> PRIMITIVE_KEYS
AtTypes.COMMENT -> COMMENT_KEYS
TokenType.BAD_CHARACTER -> BAD_CHARACTER_KEYS
- else -> EMPTY_KEYS
+ else -> TextAttributesKey.EMPTY_ARRAY
}
companion object {
@@ -70,6 +70,5 @@
private val PRIMITIVE_KEYS = arrayOf(PRIMITIVE)
private val COMMENT_KEYS = arrayOf(COMMENT)
private val BAD_CHARACTER_KEYS = arrayOf(BAD_CHARACTER)
- private val EMPTY_KEYS = emptyArray()
}
}
Index: src/main/kotlin/util/psi-utils.kt
===================================================================
--- src/main/kotlin/util/psi-utils.kt (revision ef48c70086389b88b6a2afe9eb9e4e5b6f9e9430)
+++ src/main/kotlin/util/psi-utils.kt (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
@@ -103,13 +103,9 @@
fun PsiElement.isAncestorOf(child: PsiElement): Boolean = child.ancestors.contains(this)
-private inline fun PsiElement.findParent(resolveReferences: Boolean): T? {
- return findParent(resolveReferences) { false }
-}
-
private inline fun PsiElement.findParent(
resolveReferences: Boolean,
- stop: (PsiElement) -> Boolean,
+ stop: (PsiElement) -> Boolean = { false },
): T? {
var el: PsiElement = this
Index: src/main/resources/META-INF/plugin.xml
===================================================================
--- src/main/resources/META-INF/plugin.xml (revision ef48c70086389b88b6a2afe9eb9e4e5b6f9e9430)
+++ src/main/resources/META-INF/plugin.xml (revision 63c93fe73a189c36c3dd875c1319b0d44f05611d)
@@ -102,13 +102,9 @@
implements="com.demonwav.mcdev.creator.custom.finalizers.CreatorFinalizer"/>
-
-
-
+
+
+