⁠
kyle wood: Standardize HTTP requests through Jetbrains HttpRequests
The McdevHttp util allows us to serve mocked results for tests in the
future.
The McdevHttp util allows us to serve mocked results for tests in the
future.
- /*
- * Minecraft Development for IntelliJ
- *
- * https://mcdev.io/
- *
- * Copyright (C) 2026 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 <https://www.gnu.org/licenses/>.
- */
-
- import io.sentry.android.gradle.extensions.SentryPluginExtension
- import java.util.concurrent.atomic.AtomicInteger
- import kotlin.concurrent.atomics.AtomicInt
- import org.gradle.kotlin.dsl.configure
- import org.jetbrains.changelog.Changelog
- import org.jetbrains.gradle.ext.settings
- import org.jetbrains.gradle.ext.taskTriggers
- import org.jetbrains.intellij.platform.gradle.TestFrameworkType
- import org.jetbrains.intellij.platform.gradle.tasks.PrepareSandboxTask
-
- plugins {
- id(libs.plugins.changelog.get().pluginId)
- alias(libs.plugins.idea.ext)
- `mcdev-core`
- `mcdev-parsing`
- `mcdev-publishing`
- alias(libs.plugins.sentry) apply (System.getenv("CI") == "true" && System.getenv("NO_SENTRY") != "true")
- }
-
- val coreVersion: String by project
-
- val gradleToolingExtension: Configuration by configurations.creating
- val testLibs: Configuration by configurations.creating {
- isTransitive = false
- }
-
- group = "com.demonwav.mcdev"
-
- val gradleToolingExtensionSourceSet: SourceSet = sourceSets.create("gradle-tooling-extension", Action<SourceSet> {
- configurations.named(compileOnlyConfigurationName) {
- extendsFrom(gradleToolingExtension)
- }
- })
- val gradleToolingExtensionJar = tasks.register<Jar>(gradleToolingExtensionSourceSet.jarTaskName) {
- from(gradleToolingExtensionSourceSet.output)
- archiveClassifier.set("gradle-tooling-extension")
- exclude("META-INF/plugin.xml")
- }
-
- val templatesSourceSet: SourceSet = sourceSets.create("templates", Action<SourceSet> {
- resources {
- srcDir("templates")
- compileClasspath += sourceSets.main.get().output
- }
- })
-
- val templateSourceSets: List<SourceSet> = (file("templates").listFiles() ?: emptyArray()).mapNotNull { file ->
- if (file.isDirectory() && (file.listFiles() ?: emptyArray()).any { it.name.endsWith(".mcdev.template.json") }) {
- sourceSets.create("templates-${file.name}", Action<SourceSet> {
- resources {
- srcDir(file)
- compileClasspath += sourceSets.main.get().output
- }
- })
- } else {
- null
- }
- }
-
- val externalAnnotationsJar = tasks.register<Jar>("externalAnnotationsJar") {
- from("externalAnnotations")
- destinationDirectory.set(layout.buildDirectory.dir("externalAnnotations"))
- archiveFileName.set("externalAnnotations.jar")
- }
-
- dependencies {
- implementation(files(gradleToolingExtensionJar))
-
- implementation(libs.mixinExtras.expressions) {
- exclude(group = "org.ow2.asm", module = "asm-debug-all")
- }
- testLibs(libs.mixinExtras.common)
- implementation(libs.jgraphx)
-
- implementation(libs.mappingIo)
- implementation(libs.bundles.asm)
-
- implementation(libs.bundles.fuel) {
- exclude(group = "org.jetbrains.kotlin")
- exclude(group = "org.jetbrains.kotlinx")
- }
- implementation(libs.sentry) {
- exclude(group = "org.slf4j")
- }
-
- implementation(libs.jspecify)
-
- intellijPlatform {
- intellijIdea(libs.versions.intellij.ide) {
- useInstaller = false
- }
-
- // Bundled plugin dependencies
- bundledPlugin("com.intellij.java")
- bundledPlugin("org.jetbrains.idea.maven")
- bundledPlugin("com.intellij.gradle")
- bundledPlugin("org.jetbrains.idea.reposearch")
- bundledPlugin("org.intellij.groovy")
- bundledPlugin("ByteCodeViewer")
- bundledModule("intellij.platform.langInjection")
- bundledPlugin("com.intellij.properties")
- bundledPlugin("Git4Idea")
- bundledModule("intellij.platform.collaborationTools")
- bundledPlugin("com.intellij.modules.json")
-
- // Optional dependencies
- bundledPlugin("org.jetbrains.kotlin")
- bundledPlugin("org.toml.lang")
- bundledPlugin("org.jetbrains.plugins.yaml")
-
- testFramework(TestFrameworkType.JUnit5)
- testFramework(TestFrameworkType.Platform)
- testFramework(TestFrameworkType.Plugin.Java)
-
- pluginVerifier()
- }
-
- testLibs(libs.test.mixin)
- testLibs(libs.test.spigotapi)
- testLibs(libs.test.bungeecord)
- testLibs(libs.test.spongeapi) {
- artifact {
- classifier = "shaded"
- }
- }
- testLibs(libs.test.fabricloader)
- testLibs(libs.test.nbt) {
- artifact {
- extension = "nbt"
- }
- }
- testLibs(projects.mixinTestData)
-
- gradleToolingExtension(libs.gradleToolingExtension)
- gradleToolingExtension(libs.annotations)
- }
-
- changelog {
- version = coreVersion
- groups.empty()
- path = "changelog.md"
- }
-
- intellijPlatform {
- projectName = "Minecraft Development"
-
- pluginVerification {
- ides {
- recommended()
- }
- }
- }
-
- tasks.patchPluginXml {
- val changelog = project.changelog
- changeNotes = changelog.render(Changelog.OutputType.HTML)
- }
-
- // Compile classes to be loaded into the Gradle VM to Java 8
- // 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.
- tasks.named(gradleToolingExtensionSourceSet.compileJavaTaskName, JavaCompile::class) {
- options.release = 8
- options.compilerArgs = listOf("-Xlint:-options")
- }
-
- tasks.processResources {
- // These templates aren't allowed to be in a directory structure in the output jar
- // But we have a lot of templates that would get real hard to deal with if we didn't have some structure
- // So this just flattens out the fileTemplates/j2ee directory in the jar, while still letting us have directories
- exclude("fileTemplates/j2ee/**")
- from(fileTree("src/main/resources/fileTemplates/j2ee").files) {
- eachFile {
- relativePath = RelativePath(true, "fileTemplates", "j2ee", this.name)
- }
- }
- }
-
- // Run unit tests in paralllel. Unfortunately, to accomplish this, we also need separate sandboxes for each test fork.
- // All of this is still worth doing since the IntelliJ test fixtures themselves are rather slow.
- val testForks = 6
- val sandboxTestTasks = mutableListOf<TaskProvider<PrepareSandboxTask>>()
- repeat(testForks) {
- sandboxTestTasks += tasks.register<PrepareSandboxTask>("prepareTestSandboxFork$it") {
- sandboxSuffix.set("-fork-$it")
- doFirst {
- sandboxDirectory.get().asFile.listFiles()
- ?.filter { f -> f.name.endsWith("-fork-$it") }
- ?.forEach { f -> f.deleteRecursively() }
- }
- }
- }
- tasks.prepareTestSandbox {
- doFirst {
- sandboxDirectory.get().asFile.listFiles()
- ?.filter { f -> f.name.endsWith("-test") }
- ?.forEach { f -> f.deleteRecursively() }
- }
- }
-
- val cleanTestSandboxForks by tasks.registering(Delete::class) {
- doFirst {
- tasks.prepareTestSandbox.flatMap { it.sandboxDirectory }
- .get().asFile.listFiles()
- ?.filter { it.name.matches(Regex(".*-(?:fork-\\d+|test)")) }
- ?.let { delete(it) }
- }
- }
- tasks.test {
- dependsOn(tasks.jar, testLibs, sandboxTestTasks)
- finalizedBy(cleanTestSandboxForks)
-
- testLibs.resolvedConfiguration.resolvedArtifacts.forEach {
- systemProperty("testLibs.${it.name}", it.file.absolutePath)
- }
- systemProperty("NO_FS_ROOTS_ACCESS_CHECK", "true")
- systemProperty("java.awt.headless", "true")
-
- jvmArgs(
- "-Dsun.io.useCanonCaches=false",
- "-Dsun.io.useCanonPrefixCache=false",
- )
-
- val sandboxDir = tasks.prepareTestSandbox.flatMap { it.sandboxDirectory }.get().asFile
-
- maxParallelForks = testForks
- systemProperty("sandboxDir", sandboxDir.absolutePath)
- systemProperty("forks", testForks.toString())
- }
-
- idea {
- project.settings.taskTriggers.afterSync("generate")
- }
-
- license {
- val endings = listOf("java", "kt", "kts", "gradle.kts", "xml", "properties", "html", "flex", "bnf")
- exclude("META-INF/plugin.xml") // https://youtrack.jetbrains.com/issue/IDEA-345026
- exclude("sentry-debug-meta.properties", "sentry-external-modules.txt")
- include(endings.map { "**/*.$it" })
-
- val projectDir = layout.projectDirectory.asFile
- exclude {
- it.file.toRelativeString(projectDir)
- .replace("\\", "/")
- .startsWith("src/test/resources")
- }
-
- tasks {
- register("gradle") {
- files.from(
- fileTree(project.projectDir) {
- include("*.gradle.kts", "gradle.properties")
- exclude("**/buildSrc/**", "**/build/**")
- },
- )
- }
- register("buildSrc") {
- files.from(
- project.fileTree(project.projectDir.resolve("buildSrc")) {
- include("**/*.kt", "**/*.kts")
- exclude("**/build/**")
- },
- )
- }
- register("mixinTestData") {
- files.from(
- project.fileTree(project.projectDir.resolve("mixin-test-data")) {
- include("**/*.java", "**/*.kts")
- exclude("**/build/**")
- },
- )
- }
- register("grammars") {
- files.from(project.fileTree("src/main/grammars"))
- }
- register("externalAnnotations") {
- files.from(project.fileTree("externalAnnotations"))
- }
- }
- }
-
- val generateAtLexer by lexer("AtLexer", "com/demonwav/mcdev/platform/minecraft/at/gen")
- val generateAtParser by parser("AtParser", "com/demonwav/mcdev/platform/minecraft/at/gen")
-
- val generateCtLexer by lexer("CtLexer", "com/demonwav/mcdev/platform/minecraft/ct/gen")
- val generateCtParser by parser("CtParser", "com/demonwav/mcdev/platform/minecraft/ct/gen")
-
- val generateNbttLexer by lexer("NbttLexer", "com/demonwav/mcdev/nbt/lang/gen")
- val generateNbttParser by parser("NbttParser", "com/demonwav/mcdev/nbt/lang/gen")
-
- val generateLangLexer by lexer("LangLexer", "com/demonwav/mcdev/translations/lang/gen")
- val generateLangParser by parser("LangParser", "com/demonwav/mcdev/translations/lang/gen")
-
- val generateMEExpressionLexer by lexer("MEExpressionLexer", "com/demonwav/mcdev/platform/mixin/expression/gen")
- val generateMEExpressionParser by parser("MEExpressionParser", "com/demonwav/mcdev/platform/mixin/expression/gen")
-
- val generateTranslationTemplateLexer by lexer(
- "TranslationTemplateLexer",
- "com/demonwav/mcdev/translations/template/gen"
- )
-
- val generate by tasks.registering {
- group = "minecraft"
- description = "Generates sources needed to compile the plugin."
- outputs.dir(layout.buildDirectory.dir("gen"))
- dependsOn(
- generateAtLexer,
- generateAtParser,
- generateCtLexer,
- generateCtParser,
- generateNbttLexer,
- generateNbttParser,
- generateLangLexer,
- generateLangParser,
- generateMEExpressionLexer,
- generateMEExpressionParser,
- generateTranslationTemplateLexer,
- )
- }
-
- sourceSets.main { java.srcDir(generate) }
-
- // Remove gen directory on clean
- tasks.clean { delete(generate) }
-
- tasks.withType<PrepareSandboxTask> {
- pluginJar.set(tasks.jar.get().archiveFile)
- val pluginDirName = intellijPlatform.projectName.get()
- from(externalAnnotationsJar) {
- into("$pluginDirName/lib/resources")
- }
- from("templates") {
- exclude(".git")
- into("$pluginDirName/lib/resources/builtin-templates")
- }
- }
-
- tasks.runIde {
- maxHeapSize = "4G"
-
- System.getProperty("debug")?.let {
- systemProperty("idea.ProcessCanceledException", "disabled")
- systemProperty("idea.debug.mode", "true")
- }
-
- // Kotlin K2 is enabled by default, uncomment to switch to K1
- // jvmArgumentProviders += CommandLineArgumentProvider {
- // listOf("-Didea.kotlin.plugin.use.k2=false")
- // }
-
- // Set these properties to test different languages
- // systemProperty("user.language", "fr")
- // systemProperty("user.country", "FR")
- }
-
- if (System.getenv("CI") == "true" && System.getenv("NO_SENTRY") != "true") {
- configure<SentryPluginExtension> {
- includeSourceContext = true
- includeDependenciesReport = true
- autoInstallation {
- enabled = false
- }
-
- url = "https://sentry.mcdev.io/"
- org = "mcdev"
- projectName = "mcdev"
- authToken = providers.gradleProperty("mcdev.sentry.token")
- }
-
- // Wire together some tasks to make Gradle happy
- tasks.named("generateSentryBundleIdJava") {
- dependsOn(generate)
- }
- tasks.named("sentryCollectSourcesJava") {
- dependsOn(generate)
- }
- tasks.checkLicenseMain {
- dependsOn(tasks.named("generateSentryDebugMetaPropertiesjava"), tasks.named("collectExternalDependenciesForSentry"))
- }
- }
- /*
- * Minecraft Development for IntelliJ
- *
- * https://mcdev.io/
- *
- * Copyright (C) 2026 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 <https://www.gnu.org/licenses/>.
- */
-
- import io.sentry.android.gradle.extensions.SentryPluginExtension
- import org.gradle.kotlin.dsl.configure
- import org.jetbrains.changelog.Changelog
- import org.jetbrains.gradle.ext.settings
- import org.jetbrains.gradle.ext.taskTriggers
- import org.jetbrains.intellij.platform.gradle.TestFrameworkType
- import org.jetbrains.intellij.platform.gradle.tasks.PrepareSandboxTask
-
- plugins {
- id(libs.plugins.changelog.get().pluginId)
- alias(libs.plugins.idea.ext)
- `mcdev-core`
- `mcdev-parsing`
- `mcdev-publishing`
- alias(libs.plugins.sentry) apply (System.getenv("CI") == "true" && System.getenv("NO_SENTRY") != "true")
- }
-
- val coreVersion = project.property("coreVersion") as String
-
- val gradleToolingExtension = configurations.create("gradleToolingExtension")
- val testLibs = configurations.create("testLibs") {
- isTransitive = false
- }
-
- group = "com.demonwav.mcdev"
-
- val gradleToolingExtensionSourceSet: SourceSet = sourceSets.create("gradle-tooling-extension", Action<SourceSet> {
- configurations.named(compileOnlyConfigurationName) {
- extendsFrom(gradleToolingExtension)
- }
- })
- val gradleToolingExtensionJar = tasks.register<Jar>(gradleToolingExtensionSourceSet.jarTaskName) {
- description = "Package Gradle tooling extension jar"
- from(gradleToolingExtensionSourceSet.output)
- archiveClassifier.set("gradle-tooling-extension")
- exclude("META-INF/plugin.xml")
- }
-
- val templatesSourceSet: SourceSet = sourceSets.create("templates", Action<SourceSet> {
- resources {
- srcDir("templates")
- compileClasspath += sourceSets.main.get().output
- }
- })
-
- val templateSourceSets: List<SourceSet> = (file("templates").listFiles() ?: emptyArray()).mapNotNull { file ->
- if (file.isDirectory() && (file.listFiles() ?: emptyArray()).any { it.name.endsWith(".mcdev.template.json") }) {
- sourceSets.create("templates-${file.name}", Action<SourceSet> {
- resources {
- srcDir(file)
- compileClasspath += sourceSets.main.get().output
- }
- })
- } else {
- null
- }
- }
-
- val externalAnnotationsJar = tasks.register<Jar>("externalAnnotationsJar") {
- description = "Package external annotations jar"
- from("externalAnnotations")
- destinationDirectory.set(layout.buildDirectory.dir("externalAnnotations"))
- archiveFileName.set("externalAnnotations.jar")
- }
-
- dependencies {
- implementation(files(gradleToolingExtensionJar))
-
- implementation(libs.mixinExtras.expressions) {
- exclude(group = "org.ow2.asm", module = "asm-debug-all")
- }
- testLibs(libs.mixinExtras.common)
- implementation(libs.jgraphx)
-
- implementation(libs.mappingIo)
- implementation(libs.bundles.asm)
-
- implementation(libs.sentry) {
- exclude(group = "org.slf4j")
- }
-
- implementation(libs.jspecify)
-
- intellijPlatform {
- intellijIdea(libs.versions.intellij.ide) {
- useInstaller = false
- }
-
- // Bundled plugin dependencies
- bundledPlugin("com.intellij.java")
- bundledPlugin("org.jetbrains.idea.maven")
- bundledPlugin("com.intellij.gradle")
- bundledPlugin("org.jetbrains.idea.reposearch")
- bundledPlugin("org.intellij.groovy")
- bundledPlugin("ByteCodeViewer")
- bundledModule("intellij.platform.langInjection")
- bundledPlugin("com.intellij.properties")
- bundledPlugin("Git4Idea")
- bundledModule("intellij.platform.collaborationTools")
- bundledPlugin("com.intellij.modules.json")
-
- // Optional dependencies
- bundledPlugin("org.jetbrains.kotlin")
- bundledPlugin("org.toml.lang")
- bundledPlugin("org.jetbrains.plugins.yaml")
-
- testFramework(TestFrameworkType.JUnit5)
- testFramework(TestFrameworkType.Platform)
- testFramework(TestFrameworkType.Plugin.Java)
-
- pluginVerifier()
- }
-
- testLibs(libs.test.mixin)
- testLibs(libs.test.spigotapi)
- testLibs(libs.test.bungeecord)
- testLibs(libs.test.spongeapi) {
- artifact {
- classifier = "shaded"
- }
- }
- testLibs(libs.test.fabricloader)
- testLibs(libs.test.nbt) {
- artifact {
- extension = "nbt"
- }
- }
- testLibs(projects.mixinTestData)
-
- gradleToolingExtension(libs.gradleToolingExtension)
- gradleToolingExtension(libs.annotations)
- }
-
- changelog {
- version = coreVersion
- groups.empty()
- path = "changelog.md"
- }
-
- intellijPlatform {
- projectName = "Minecraft Development"
-
- pluginVerification {
- ides {
- recommended()
- }
- }
- }
-
- tasks.patchPluginXml {
- val changelog = project.changelog
- changeNotes = changelog.render(Changelog.OutputType.HTML)
- }
-
- // Compile classes to be loaded into the Gradle VM to Java 8
- // 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.
- tasks.named(gradleToolingExtensionSourceSet.compileJavaTaskName, JavaCompile::class) {
- options.release = 8
- options.compilerArgs = listOf("-Xlint:-options")
- }
-
- tasks.processResources {
- // These templates aren't allowed to be in a directory structure in the output jar
- // But we have a lot of templates that would get real hard to deal with if we didn't have some structure
- // So this just flattens out the fileTemplates/j2ee directory in the jar, while still letting us have directories
- exclude("fileTemplates/j2ee/**")
- from(fileTree("src/main/resources/fileTemplates/j2ee").files) {
- eachFile {
- relativePath = RelativePath(true, "fileTemplates", "j2ee", this.name)
- }
- }
- }
-
- // Run unit tests in paralllel. Unfortunately, to accomplish this, we also need separate sandboxes for each test fork.
- // All of this is still worth doing since the IntelliJ test fixtures themselves are rather slow.
- val testForks = 6
- val sandboxTestTasks = mutableListOf<TaskProvider<PrepareSandboxTask>>()
- repeat(testForks) {
- sandboxTestTasks += tasks.register<PrepareSandboxTask>("prepareTestSandboxFork$it") {
- description = "Prepare sandbox for test fork #$it"
- sandboxSuffix.set("-fork-$it")
- doFirst {
- sandboxDirectory.get().asFile.listFiles()
- ?.filter { f -> f.name.endsWith("-fork-$it") }
- ?.forEach { f -> f.deleteRecursively() }
- }
- }
- }
- tasks.prepareTestSandbox {
- doFirst {
- sandboxDirectory.get().asFile.listFiles()
- ?.filter { f -> f.name.endsWith("-test") }
- ?.forEach { f -> f.deleteRecursively() }
- }
- }
-
- val cleanTestSandboxForks = tasks.register("cleanTestSandboxForks", Delete::class) {
- description = "Delete all test fork sandboxes"
- doFirst {
- tasks.prepareTestSandbox.flatMap { it.sandboxDirectory }
- .get().asFile.listFiles()
- ?.filter { it.name.matches(Regex(".*-(?:fork-\\d+|test)")) }
- ?.let { delete(it) }
- }
- }
- tasks.test {
- dependsOn(tasks.jar, testLibs, sandboxTestTasks)
- finalizedBy(cleanTestSandboxForks)
-
- testLibs.resolvedConfiguration.resolvedArtifacts.forEach {
- systemProperty("testLibs.${it.name}", it.file.absolutePath)
- }
- systemProperty("NO_FS_ROOTS_ACCESS_CHECK", "true")
- systemProperty("java.awt.headless", "true")
-
- jvmArgs(
- "-Dsun.io.useCanonCaches=false",
- "-Dsun.io.useCanonPrefixCache=false",
- )
-
- val sandboxDir = tasks.prepareTestSandbox.flatMap { it.sandboxDirectory }.get().asFile
-
- maxParallelForks = testForks
- systemProperty("sandboxDir", sandboxDir.absolutePath)
- systemProperty("forks", testForks.toString())
- }
-
- idea {
- project.settings.taskTriggers.afterSync("generate")
- }
-
- license {
- val endings = listOf("java", "kt", "kts", "gradle.kts", "xml", "properties", "html", "flex", "bnf")
- exclude("META-INF/plugin.xml") // https://youtrack.jetbrains.com/issue/IDEA-345026
- exclude("sentry-debug-meta.properties", "sentry-external-modules.txt")
- include(endings.map { "**/*.$it" })
-
- val projectDir = layout.projectDirectory.asFile
- exclude {
- it.file.toRelativeString(projectDir)
- .replace("\\", "/")
- .startsWith("src/test/resources")
- }
-
- @Suppress("UnstableApiUsage")
- tasks {
- register("gradle") {
- files.from(
- fileTree(project.projectDir) {
- include("*.gradle.kts", "gradle.properties")
- exclude("**/buildSrc/**", "**/build/**")
- },
- )
- }
- register("buildSrc") {
- files.from(
- project.fileTree(project.projectDir.resolve("buildSrc")) {
- include("**/*.kt", "**/*.kts")
- exclude("**/build/**")
- },
- )
- }
- register("mixinTestData") {
- files.from(
- project.fileTree(project.projectDir.resolve("mixin-test-data")) {
- include("**/*.java", "**/*.kts")
- exclude("**/build/**")
- },
- )
- }
- register("grammars") {
- files.from(project.fileTree("src/main/grammars"))
- }
- register("externalAnnotations") {
- files.from(project.fileTree("externalAnnotations"))
- }
- }
- }
-
- val generateAtLexer = lexer("generateAtLexer", "AtLexer", "com/demonwav/mcdev/platform/minecraft/at/gen")
- val generateAtParser = parser("generateAtParser", "AtParser", "com/demonwav/mcdev/platform/minecraft/at/gen")
-
- val generateCtLexer = lexer("generateCtLexer", "CtLexer", "com/demonwav/mcdev/platform/minecraft/ct/gen")
- val generateCtParser = parser("generateCtParser", "CtParser", "com/demonwav/mcdev/platform/minecraft/ct/gen")
-
- val generateNbttLexer = lexer("generateNbttLexer", "NbttLexer", "com/demonwav/mcdev/nbt/lang/gen")
- val generateNbttParser = parser("generateNbttParser", "NbttParser", "com/demonwav/mcdev/nbt/lang/gen")
-
- val generateLangLexer = lexer("generateLangLexer", "LangLexer", "com/demonwav/mcdev/translations/lang/gen")
- val generateLangParser = parser("generateLangParser", "LangParser", "com/demonwav/mcdev/translations/lang/gen")
-
- val generateMEExpressionLexer = lexer("generateMEExpressionLexer", "MEExpressionLexer", "com/demonwav/mcdev/platform/mixin/expression/gen")
- val generateMEExpressionParser = parser("generateMEExpressionParser", "MEExpressionParser", "com/demonwav/mcdev/platform/mixin/expression/gen")
-
- val generateTranslationTemplateLexer = lexer(
- "generateTranslationTemplateLexer",
- "TranslationTemplateLexer",
- "com/demonwav/mcdev/translations/template/gen"
- )
-
- val generate = tasks.register("generate") {
- group = "minecraft"
- description = "Generate sources needed to compile the plugin."
- outputs.dir(layout.buildDirectory.dir("gen"))
- dependsOn(
- generateAtLexer,
- generateAtParser,
- generateCtLexer,
- generateCtParser,
- generateNbttLexer,
- generateNbttParser,
- generateLangLexer,
- generateLangParser,
- generateMEExpressionLexer,
- generateMEExpressionParser,
- generateTranslationTemplateLexer,
- )
- }
-
- sourceSets.main { java.srcDir(generate) }
-
- // Remove gen directory on clean
- tasks.clean { delete(generate) }
-
- tasks.withType<PrepareSandboxTask> {
- pluginJar.set(tasks.jar.get().archiveFile)
- val pluginDirName = intellijPlatform.projectName.get()
- from(externalAnnotationsJar) {
- into("$pluginDirName/lib/resources")
- }
- from("templates") {
- exclude(".git")
- into("$pluginDirName/lib/resources/builtin-templates")
- }
- }
-
- tasks.runIde {
- maxHeapSize = "4G"
-
- System.getProperty("debug")?.let {
- systemProperty("idea.ProcessCanceledException", "disabled")
- systemProperty("idea.debug.mode", "true")
- }
-
- // Kotlin K2 is enabled by default, uncomment to switch to K1
- // jvmArgumentProviders += CommandLineArgumentProvider {
- // listOf("-Didea.kotlin.plugin.use.k2=false")
- // }
-
- // Set these properties to test different languages
- // systemProperty("user.language", "fr")
- // systemProperty("user.country", "FR")
- }
-
- if (System.getenv("CI") == "true" && System.getenv("NO_SENTRY") != "true") {
- configure<SentryPluginExtension> {
- includeSourceContext = true
- includeDependenciesReport = true
- autoInstallation {
- enabled = false
- }
-
- url = "https://sentry.mcdev.io/"
- org = "mcdev"
- projectName = "mcdev"
- authToken = providers.gradleProperty("mcdev.sentry.token")
- }
-
- // Wire together some tasks to make Gradle happy
- tasks.named("generateSentryBundleIdJava") {
- dependsOn(generate)
- }
- tasks.named("sentryCollectSourcesJava") {
- dependsOn(generate)
- }
- tasks.checkLicenseMain {
- dependsOn(tasks.named("generateSentryDebugMetaPropertiesjava"), tasks.named("collectExternalDependenciesForSentry"))
- }
- }