Skip to content

Commit

Permalink
Merge branch '2023.2' into 2023.3
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/kotlin/insight/generation/ui/EventListenerWizard.kt
  • Loading branch information
RedNesto committed Jul 14, 2024
2 parents ee7b9ac + 11fceec commit ccc0c77
Show file tree
Hide file tree
Showing 272 changed files with 17,473 additions and 1,485 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Fetch latest submodule updates
run: git submodule update --remote
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "templates"]
path = templates
branch = v1
url = https://github.com/minecraft-dev/templates
68 changes: 65 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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
Expand All @@ -37,6 +38,7 @@ plugins {
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"
}

val ideaVersionName: String by project
Expand Down Expand Up @@ -72,6 +74,26 @@ val gradleToolingExtensionJar = tasks.register<Jar>(gradleToolingExtensionSource
archiveClassifier.set("gradle-tooling-extension")
}

val templatesSourceSet: SourceSet = sourceSets.create("templates") {
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}") {
resources {
srcDir(file)
compileClasspath += sourceSets.main.get().output
}
}
} else {
null
}
}

val externalAnnotationsJar = tasks.register<Jar>("externalAnnotationsJar") {
from("externalAnnotations")
destinationDirectory.set(layout.buildDirectory.dir("externalAnnotations"))
Expand All @@ -83,15 +105,21 @@ repositories {
maven("https://maven.fabricmc.net/") {
content {
includeModule("net.fabricmc", "mapping-io")
includeModule("net.fabricmc", "fabric-loader")
}
}
mavenCentral()
maven("https://repo.spongepowered.org/maven/")
}

dependencies {
// Add tools.jar for the JDI API
implementation(files(Jvm.current().toolsJar))

implementation(libs.mixinExtras.expressions)
testLibs(libs.mixinExtras.common)
implementation("org.ow2.asm:asm-util:9.3")

// Kotlin
implementation(kotlin("stdlib-jdk8"))
implementation(kotlin("reflect"))
Expand Down Expand Up @@ -121,6 +149,7 @@ dependencies {
classifier = "shaded"
}
}
testLibs(libs.test.fabricloader)
testLibs(libs.test.nbt) {
artifact {
extension = "nbt"
Expand Down Expand Up @@ -166,6 +195,12 @@ configurations.compileClasspath {
attributes.attribute(filtered, true)
}

changelog {
version = coreVersion
groups.empty()
path = "changelog.md"
}

intellij {
// IntelliJ IDEA dependency
version.set(providers.gradleProperty("ideaVersion"))
Expand All @@ -178,6 +213,7 @@ intellij {
"Kotlin",
"org.toml.lang:$pluginTomlVersion",
"ByteCodeViewer",
"org.intellij.intelliLang",
"properties",
// needed dependencies for unit tests
"junit"
Expand All @@ -191,6 +227,11 @@ intellij {
sandboxDir.set(layout.projectDirectory.dir(".sandbox").toString())
}

tasks.patchPluginXml {
val changelog = project.changelog
changeNotes = changelog.render(Changelog.OutputType.HTML)
}

tasks.publishPlugin {
// Build numbers are used for
properties["buildNumber"]?.let { buildNumber ->
Expand Down Expand Up @@ -343,7 +384,13 @@ 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 generateTranslationTemplateLexer by lexer("TranslationTemplateLexer", "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"
Expand All @@ -358,6 +405,8 @@ val generate by tasks.registering {
generateNbttParser,
generateLangLexer,
generateLangParser,
generateMEExpressionLexer,
generateMEExpressionParser,
generateTranslationTemplateLexer,
)
}
Expand All @@ -374,9 +423,14 @@ tasks.register("cleanSandbox", Delete::class) {
}

tasks.withType<PrepareSandboxTask> {
pluginJar.set(tasks.jar.get().archiveFile)
from(externalAnnotationsJar) {
into("Minecraft Development/lib/resources")
}
from("templates") {
exclude(".git")
into("Minecraft Development/lib/resources/builtin-templates")
}
}

tasks.runIde {
Expand All @@ -387,11 +441,19 @@ tasks.runIde {
systemProperty("idea.debug.mode", "true")
}
// Set these properties to test different languages
// systemProperty("user.language", "en")
// systemProperty("user.country", "US")
// systemProperty("user.language", "fr")
// systemProperty("user.country", "FR")
}

tasks.buildSearchableOptions {
// not working atm
enabled = false
}

tasks.instrumentCode {
enabled = false
}

tasks.instrumentedJar {
enabled = false
}
84 changes: 84 additions & 0 deletions buildSrc/src/main/kotlin/JFlexExec.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/

import java.io.ByteArrayOutputStream
import javax.inject.Inject
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.ConfigurableFileTree
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.FileCollection
import org.gradle.api.file.FileSystemOperations
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.JavaExec
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.OutputFile

abstract class JFlexExec : JavaExec() {

@get:InputFile
abstract val sourceFile: RegularFileProperty

@get:InputFiles
abstract val jflex: ConfigurableFileCollection

@get:InputFile
abstract val skeletonFile: RegularFileProperty

@get:OutputDirectory
abstract val destinationDirectory: DirectoryProperty

@get:OutputFile
abstract val destinationFile: RegularFileProperty

@get:Internal
abstract val logFile: RegularFileProperty

@get:Inject
abstract val fs: FileSystemOperations

init {
mainClass.set("jflex.Main")
}

override fun exec() {
classpath = jflex

args(
"--skel", skeletonFile.get().asFile.absolutePath,
"-d", destinationDirectory.get().asFile.absolutePath,
sourceFile.get().asFile.absolutePath
)

fs.delete { delete(destinationDirectory) }

val taskOutput = ByteArrayOutputStream()
standardOutput = taskOutput
errorOutput = taskOutput

super.exec()

val log = logFile.get().asFile
log.parentFile.mkdirs()
log.writeBytes(taskOutput.toByteArray())
}
}
88 changes: 88 additions & 0 deletions buildSrc/src/main/kotlin/ParserExec.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/

import java.io.ByteArrayOutputStream
import javax.inject.Inject
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.FileSystemOperations
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.JavaExec
import org.gradle.api.tasks.OutputDirectory

abstract class ParserExec : JavaExec() {

@get:InputFile
abstract val sourceFile: RegularFileProperty

@get:InputFiles
abstract val grammarKit: ConfigurableFileCollection

@get:OutputDirectory
abstract val destinationRootDirectory: DirectoryProperty

@get:OutputDirectory
abstract val destinationDirectory: DirectoryProperty

@get:OutputDirectory
abstract val psiDirectory: DirectoryProperty

@get:OutputDirectory
abstract val parserDirectory: DirectoryProperty

@get:Internal
abstract val logFile: RegularFileProperty

@get:Inject
abstract val fs: FileSystemOperations

init {
mainClass.set("org.intellij.grammar.Main")

jvmArgs(
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
"--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED",
"--add-opens", "java.base/java.util=ALL-UNNAMED"
)
}

override fun exec() {
classpath = grammarKit
args(
destinationRootDirectory.get().asFile,
sourceFile.get().asFile
)

fs.delete { delete(psiDirectory, parserDirectory) }

val taskOutput = ByteArrayOutputStream()
standardOutput = taskOutput
errorOutput = taskOutput

super.exec()

val log = logFile.get().asFile
log.parentFile.mkdirs()
log.writeBytes(taskOutput.toByteArray())
}
}
Loading

0 comments on commit ccc0c77

Please sign in to comment.