Skip to content

Commit

Permalink
Merge branch '2021.2' into 2021.3
Browse files Browse the repository at this point in the history
  • Loading branch information
DenWav committed Dec 23, 2021
2 parents 08804d1 + 1eb56f7 commit ea1e431
Show file tree
Hide file tree
Showing 35 changed files with 201 additions and 120 deletions.
3 changes: 1 addition & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[*.{kt,kts}]
max_line_length=120
# noinspection EditorConfigKeyCorrectness
kotlin_imports_layout=ascii
ij_kotlin_imports_layout=*
107 changes: 65 additions & 42 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ import org.gradle.internal.os.OperatingSystem
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "1.4.32"
kotlin("jvm") version "1.6.10"
java
mcdev
groovy
idea
id("org.jetbrains.intellij") version "1.3.0"
val ijPluginVersion = if (System.getProperty("mcdev.localdev").toBoolean()) {
"1.1.3"
} else {
"1.3.0"
}
id("org.jetbrains.intellij") version ijPluginVersion
id("org.cadixdev.licenser") version "0.6.1"
id("org.jlleitschuh.gradle.ktlint") version "10.0.0"
}
Expand All @@ -46,6 +51,12 @@ val testLibs: Configuration by configurations.creating {
group = "com.demonwav.minecraft-dev"
version = "$ideaVersionName-$coreVersion"

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}

val gradleToolingExtensionSourceSet: SourceSet = sourceSets.create("gradle-tooling-extension") {
configurations.named(compileOnlyConfigurationName) {
extendsFrom(gradleToolingExtension)
Expand All @@ -57,17 +68,8 @@ val gradleToolingExtensionJar = tasks.register<Jar>(gradleToolingExtensionSource
}

repositories {
mavenCentral()
maven("https://repo.denwav.dev/repository/maven-public/")
maven("https://repo.spongepowered.org/maven")
if (!ideaVersion.endsWith("SNAPSHOT")) {
maven("https://www.jetbrains.com/intellij-repository/releases")
} else {
maven("https://www.jetbrains.com/intellij-repository/snapshots")
}
maven("https://cache-redirector.jetbrains.com/intellij-dependencies")
maven("https://repo.gradle.org/gradle/libs-releases-local/")
maven("https://maven.extracraftx.com")
mavenCentral()
}

dependencies {
Expand All @@ -82,19 +84,28 @@ dependencies {
implementation(files(gradleToolingExtensionJar))

implementation(libs.templateMakerFabric)

implementation("org.ow2.asm:asm:9.2")
implementation("org.ow2.asm:asm-tree:9.2")
implementation("org.ow2.asm:asm-analysis:9.2")
implementation(libs.bundles.asm)

jflex(libs.jflex.lib)
jflexSkeleton("${libs.jflex.skeleton.text()}@skeleton")
jflexSkeleton(libs.jflex.skeleton) {
artifact {
extension = "skeleton"
}
}
grammarKit(libs.grammarKit)

testLibs(libs.test.mockJdk)
testLibs(libs.test.mixin)
testLibs("${libs.test.spongeapi.text()}:shaded")
testLibs("${libs.test.nbt.text()}@nbt")
testLibs(libs.test.spongeapi) {
artifact {
classifier = "shaded"
}
}
testLibs(libs.test.nbt) {
artifact {
extension = "nbt"
}
}
testLibs(project(":mixin-test-data"))

// For non-SNAPSHOT versions (unless Jetbrains fixes this...) find the version with:
Expand Down Expand Up @@ -155,7 +166,7 @@ java {
tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
options.compilerArgs = listOf("-proc:none")
options.release.set(8)
options.release.set(11)
}

tasks.withType<KotlinCompile>().configureEach {
Expand All @@ -165,6 +176,18 @@ tasks.withType<KotlinCompile>().configureEach {
}
}

// 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.
tasks.named(gradleToolingExtensionSourceSet.compileJavaTaskName, JavaCompile::class) {
val java7Compiler = javaToolchains.compilerFor { languageVersion.set(JavaLanguageVersion.of(8)) }
javaCompiler.set(java7Compiler)
options.release.set(null as Int?)
sourceCompatibility = "1.5"
targetCompatibility = "1.5"
options.bootstrapClasspath = files(java7Compiler.map { it.metadata.installationPath.file("jre/lib/rt.jar") })
options.compilerArgs = listOf("-Xlint:-options")
}
tasks.withType<GroovyCompile>().configureEach {
options.compilerArgs = listOf("-proc:none")
sourceCompatibility = "1.5"
Expand All @@ -189,26 +212,33 @@ tasks.processResources {
}

tasks.test {
dependsOn(testLibs)
dependsOn(tasks.jar, testLibs)
useJUnitPlatform()
doFirst {
testLibs.resolvedConfiguration.resolvedArtifacts.forEach {
systemProperty("testLibs.${it.name}", it.file.absolutePath)
}
}
systemProperty("NO_FS_ROOTS_ACCESS_CHECK", "true")
if (JavaVersion.current().isJava9Compatible) {
jvmArgs(
"--add-opens", "java.base/java.io=ALL-UNNAMED",
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
"--add-opens", "java.desktop/sun.awt=ALL-UNNAMED",
"--add-opens", "java.desktop/java.awt=ALL-UNNAMED",
"--add-opens", "java.desktop/javax.swing=ALL-UNNAMED",
"--add-opens", "java.desktop/javax.swing.plaf.basic=ALL-UNNAMED",
"--add-opens", "java.desktop/sun.font=ALL-UNNAMED",
"--add-opens", "java.desktop/sun.swing=ALL-UNNAMED"
)
}

jvmArgs(
"--add-opens", "java.base/java.io=ALL-UNNAMED",
"--add-opens", "java.base/java.lang.invoke=ALL-UNNAMED",
"--add-opens", "java.base/java.lang.ref=ALL-UNNAMED",
"--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED",
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
"--add-opens", "java.base/java.util.concurrent.atomic=ALL-UNNAMED",
"--add-opens", "java.base/java.util.concurrent.locks=ALL-UNNAMED",
"--add-opens", "java.base/java.util.concurrent=ALL-UNNAMED",
"--add-opens", "java.base/sun.nio.fs=ALL-UNNAMED",
"--add-opens", "java.desktop/java.awt.event=ALL-UNNAMED",
"--add-opens", "java.desktop/java.awt=ALL-UNNAMED",
"--add-opens", "java.desktop/javax.swing.plaf.basic=ALL-UNNAMED",
"--add-opens", "java.desktop/javax.swing=ALL-UNNAMED",
"--add-opens", "java.desktop/sun.awt=ALL-UNNAMED",
"--add-opens", "java.desktop/sun.font=ALL-UNNAMED",
"--add-opens", "java.desktop/sun.swing=ALL-UNNAMED",
)
}

idea {
Expand Down Expand Up @@ -342,10 +372,10 @@ tasks.buildSearchableOptions {
"--add-exports=java.base/jdk.internal.vm=ALL-UNNAMED",
"--add-opens=java.base/java.lang=ALL-UNNAMED",
"--add-opens=java.base/java.util=ALL-UNNAMED",
"--add-opens=java.desktop/java.awt=ALL-UNNAMED",
"--add-opens=java.desktop/java.awt.event=ALL-UNNAMED",
"--add-opens=java.desktop/javax.swing=ALL-UNNAMED",
"--add-opens=java.desktop/java.awt=ALL-UNNAMED",
"--add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED",
"--add-opens=java.desktop/javax.swing=ALL-UNNAMED",
"--add-opens=java.desktop/sun.awt=ALL-UNNAMED",
"--add-opens=java.desktop/sun.font=ALL-UNNAMED",
"--add-opens=java.desktop/sun.swing=ALL-UNNAMED"
Expand All @@ -355,10 +385,3 @@ tasks.buildSearchableOptions {
jvmArgs("--add-opens=java.desktop/com.apple.eawt.event=ALL-UNNAMED")
}
}

// version catalogs still have rough edges as it's still experimental
// this lets us get around some of that while still getting the benefits of using catalogs
fun Provider<MinimalExternalModuleDependency>.text(): String {
val dep = get()
return "${dep.module.group}:${dep.module.name}:${dep.versionConstraint}"
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ kotlin.code.style=official
ideaVersion = 2021.3
ideaVersionName = 2021.3

coreVersion = 1.5.17
coreVersion = 1.5.18
downloadIdeaSources = true

pluginTomlVersion = 213.5744.224
12 changes: 9 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[versions]
coroutines = "1.4.3"
coroutines = "1.5.2"
junit = "5.7.1"
asm = "9.2"

[libraries]
coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
Expand All @@ -18,14 +19,19 @@ gradleToolingExtension = "com.jetbrains.intellij.gradle:gradle-tooling-extension
annotations = "org.jetbrains:annotations:20.1.0"
groovy = "org.codehaus.groovy:groovy-all:2.5.14"

asm = { module = "org.ow2.asm:asm", version.ref = "asm" }
asm-tree = { module = "org.ow2.asm:asm-tree", version.ref = "asm" }
asm-analysis = { module = "org.ow2.asm:asm-analysis", version.ref = "asm" }

# Testing
test-mockJdk = "org.jetbrains.idea:mock-jdk:1.7-4d76c50"
test-mixin = "org.spongepowered:mixin:0.8-SNAPSHOT"
test-spongeapi = "org.spongepowered:spongeapi:7.0.0"
test-mixin = "org.spongepowered:mixin:0.8.5"
test-spongeapi = "org.spongepowered:spongeapi:7.4.0"
test-nbt = "com.demonwav.mcdev:all-types-nbt:1.0"

junit-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" }
junit-entine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" }

[bundles]
coroutines = ["coroutines-core", "coroutines-swing"]
asm = ["asm", "asm-tree", "asm-analysis"]
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Minecraft Development for IntelliJ
</tr>
</table>

Info and Documentation [![Current Release](https://img.shields.io/badge/release-1.5.16-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327)
Info and Documentation [![Current Release](https://img.shields.io/badge/release-1.5.18-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327)
----------------------

<a href="https://discord.gg/j6UNcfr"><img src="https://i.imgur.com/JXu9C1G.png" height="48px"></img></a>
Expand Down
2 changes: 1 addition & 1 deletion src/main/grammars/AwLexer.flex
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ HEADER_VERSION_ELEMENT=v\d+
HEADER_NAMESPACE_ELEMENT=named|intermediary
PRIMITIVE=[ZBCSIFDJV]
CLASS_VALUE=(\[+[ZBCSIFDJ]|(\[*L[^;\n]+;))
ACCESS_ELEMENT=accessible|extendable|mutable
ACCESS_ELEMENT=accessible|transitive-accessible|extendable|transitive-extendable|mutable|transitive-mutable
CLASS_ELEMENT=class
METHOD_ELEMENT=method
FIELD_ELEMENT=field
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/creator/MinecraftProjectCreator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.intellij.openapi.progress.Task
import com.intellij.openapi.vfs.VfsUtil
import java.nio.file.Files
import java.nio.file.Path
import java.util.Locale

class MinecraftProjectCreator {

Expand Down Expand Up @@ -116,7 +117,7 @@ class MinecraftProjectCreator {
for (config in configs) {
val log = newLog(config, workLog)

val dirName = config.type.normalName.toLowerCase()
val dirName = config.type.normalName.lowercase(Locale.ENGLISH)
val newArtifactId = "${build.artifactId}-$dirName"
val dir = Files.createDirectories(root.resolve(newArtifactId))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ class GradleBuildSystem(
): Iterable<CreatorStep> {
val project = module.project

val baseName = artifactId.toLowerCase(Locale.ENGLISH)
val baseName = artifactId.lowercase(Locale.ENGLISH)
val names = mutableListOf("$baseName-common")
names += types.map { "$baseName-${it.name.toLowerCase(Locale.ENGLISH)}" }
names += types.map { "$baseName-${it.name.lowercase(Locale.ENGLISH)}" }

val buildText = BuildSystemTemplate.applyBuildGradle(project, this)
val propText = BuildSystemTemplate.applyGradleProp(project)
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/creator/buildsystem/maven/MavenBuildSystem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class MavenBuildSystem(
val project = module.project
val pomText = BuildSystemTemplate.applyPom(project)

val baseName = artifactId.toLowerCase(Locale.ENGLISH)
val baseName = artifactId.lowercase(Locale.ENGLISH)
val moduleNames = mutableListOf("$baseName-common")
moduleNames += types.map { "$baseName-${it.name.toLowerCase(Locale.ENGLISH)}" }
moduleNames += types.map { "$baseName-${it.name.lowercase(Locale.ENGLISH)}" }

return listOf(
BasicMavenStep(
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/errorreporter/AnonymousFeedback.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ object AnonymousFeedback {
data class FeedbackData(val url: String, val token: Int, val isDuplicate: Boolean)

private const val authedUrl = "https://www.denwav.dev/errorReport"
private const val baseUrl = "https://api.github.com/repos/minecraft-dev/MinecraftDev/issues"
private const val baseUrl = "https://api.github.com/repos/minecraft-dev/mcdev-error-report/issues"

fun sendFeedback(
factory: HttpConnectionFactory,
Expand Down
3 changes: 0 additions & 3 deletions src/main/kotlin/errorreporter/ErrorData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ class ErrorData(var throwable: Throwable?, val lastAction: String?) {

var message: String? = null
get() = field ?: throwable?.message
set(value) {
field = value
}

var description: String? = null
var pluginName: String? = null
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/insight/ColorUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.intellij.psi.JVMElementFactories
import com.intellij.psi.PsiType
import com.intellij.psi.search.GlobalSearchScope
import java.awt.Color
import java.util.Locale
import kotlin.math.round
import org.jetbrains.uast.UCallExpression
import org.jetbrains.uast.UElement
Expand Down Expand Up @@ -216,7 +217,7 @@ fun ULiteralExpression.setColor(value: Int) {
val sourcePsi = this.sourcePsi ?: return
sourcePsi.containingFile.runWriteAction {
JVMElementFactories.requireFactory(sourcePsi.language, sourcePsi.project)
.createExpressionFromText("0x" + Integer.toHexString(value).toUpperCase(), sourcePsi)
.createExpressionFromText("0x" + Integer.toHexString(value).uppercase(Locale.ENGLISH), sourcePsi)
.let(sourcePsi::replace)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/nbt/tags/TagCompound.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import java.io.DataOutputStream
open class TagCompound(val tagMap: Map<String, NbtTag>) : NbtTag {
// If a tag doesn't have a name this will throw a NPE
// but all tags should have names in a compound
override val payloadSize = tagMap.entries.sumBy { 2 + it.key.toByteArray().size + it.value.payloadSize }
override val payloadSize = tagMap.entries.sumOf { 2 + it.key.toByteArray().size + it.value.payloadSize }
override val typeId = NbtTypeId.COMPOUND

override fun write(stream: DataOutputStream) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/nbt/tags/TagList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import java.util.Objects

class TagList(val type: NbtTypeId, val tags: List<NbtTag>) : NbtTag {
// TAG_List has nameless tags, so we don't need to do anything for the names of tags
override val payloadSize = 5 + tags.sumBy { it.payloadSize }
override val payloadSize = 5 + tags.sumOf { it.payloadSize }
override val typeId = NbtTypeId.LIST

override fun write(stream: DataOutputStream) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ class CreateEntryPointStep(
editor: Editor,
side: String
) {
val capsSide = side.toUpperCase(Locale.ROOT)
val capsSide = side.uppercase(Locale.ENGLISH)
var needsInterfaceFix = false
for (eps in entryPointsByInterface) {
if (eps.value.all { it.category == side }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ class FabricProjectSettingsWizard(private val creator: MinecraftProjectCreator)
// TemplateMakerFabric incorrectly indicates loom 0.8 requires Gradle 6...
conf.gradleVersion = SemanticVersion.release(7, 3)
}
conf.environment = when ((environmentBox.selectedItem as? String)?.toLowerCase(Locale.ROOT)) {
conf.environment = when ((environmentBox.selectedItem as? String)?.lowercase(Locale.ENGLISH)) {
"client" -> Side.CLIENT
"server" -> Side.SERVER
else -> Side.NONE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import java.nio.file.Path
import java.nio.file.StandardOpenOption.CREATE
import java.nio.file.StandardOpenOption.TRUNCATE_EXISTING
import java.nio.file.StandardOpenOption.WRITE
import java.util.Locale

class Fg2ProjectCreator(
private val rootDirectory: Path,
Expand Down Expand Up @@ -118,7 +119,7 @@ open class Fg3ProjectCreator(

protected fun transformModName(modName: String?): String {
modName ?: return "examplemod"
return modName.toLowerCase().replace(" ", "")
return modName.lowercase(Locale.ENGLISH).replace(" ", "")
}

protected fun createGradleFiles(hasData: Boolean): GradleFiles<String> {
Expand Down
Loading

0 comments on commit ea1e431

Please sign in to comment.