Skip to content

Commit

Permalink
Create obfuscation-explorer project
Browse files Browse the repository at this point in the history
This is a separate plugin to support all different Java mapping
formats. This plugin will provide a extension points for the Minecraft
Development plugin to hook into and provide mapping information. It
will also provide a generic settings page to allow users to configure
their own mappings for the project.
  • Loading branch information
DenWav committed Aug 2, 2024
1 parent 40d6b84 commit 2355523
Show file tree
Hide file tree
Showing 260 changed files with 16,708 additions and 453 deletions.
138 changes: 17 additions & 121 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,52 +18,37 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

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)
Expand Down Expand Up @@ -100,45 +85,20 @@ val externalAnnotationsJar = tasks.register<Jar>("externalAnnotationsJar") {
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/")
}

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.spongeapi) {
Expand Down Expand Up @@ -181,7 +141,7 @@ dependencies {
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"))
}
Expand All @@ -199,66 +159,33 @@ changelog {
}

intellij {
// IntelliJ IDEA dependency
version.set(providers.gradleProperty("ideaVersion"))
// Bundled plugin dependencies
plugins.addAll(
"java",
"maven",
"gradle",
"Groovy",
"Kotlin",
"org.toml.lang:$pluginTomlVersion",
"ByteCodeViewer",
"org.intellij.intelliLang",
"properties",
// 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 {
val changelog = project.changelog
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<JavaCompile>().configureEach {
options.encoding = "UTF-8"
options.compilerArgs = listOf("-proc:none")
options.release.set(17)
}

tasks.withType<KotlinCompile>().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.
Expand Down Expand Up @@ -294,10 +221,11 @@ tasks.processResources {

tasks.test {
dependsOn(tasks.jar, testLibs)
useJUnitPlatform()

testLibs.resolvedConfiguration.resolvedArtifacts.forEach {
systemProperty("testLibs.${it.name}", it.file.absolutePath)
doFirst {
testLibs.resolvedConfiguration.resolvedArtifacts.forEach {
systemProperty("testLibs.${it.name}", it.file.absolutePath)
}
}
systemProperty("NO_FS_ROOTS_ACCESS_CHECK", "true")
systemProperty("java.awt.headless", "true")
Expand All @@ -310,23 +238,10 @@ tasks.test {

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" })

exclude("com/demonwav/mcdev/platform/mixin/invalidInjectorMethodSignature/*.java")

this.tasks {
Expand Down Expand Up @@ -355,19 +270,6 @@ license {
}
}

ktlint {
disabledRules.add("filename")
}
tasks.withType<BaseKtLintCheckTask>().configureEach {
workerMaxHeapSize.set("512m")
}

tasks.register("format") {
group = "minecraft"
description = "Formats source code according to project style"
dependsOn(tasks.withType<LicenseUpdate>(), tasks.withType<KtLintFormatTask>())
}

val generateAtLexer by lexer("AtLexer", "com/demonwav/mcdev/platform/mcp/at/gen")
val generateAtParser by parser("AtParser", "com/demonwav/mcdev/platform/mcp/at/gen")

Expand Down Expand Up @@ -412,12 +314,6 @@ sourceSets.main { java.srcDir(generate) }
// 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<PrepareSandboxTask> {
pluginJar.set(tasks.jar.get().archiveFile)
from(externalAnnotationsJar) {
Expand Down
39 changes: 37 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
/*
* 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 org.jetbrains.kotlin.gradle.tasks.KotlinCompile

/*
* Minecraft Development for IntelliJ
*
Expand All @@ -22,12 +44,25 @@ plugins {
`kotlin-dsl`
}

tasks.withType<JavaCompile>().configureEach {
options.release.set(8)
}
tasks.withType<KotlinCompile>().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)
}
8 changes: 8 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@
*/

rootProject.name = "buildSrc"

dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/ParserExec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ abstract class ParserExec : JavaExec() {
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",
Expand Down
Loading

0 comments on commit 2355523

Please sign in to comment.