Skip to content

Commit

Permalink
Merge branch '2022.1' into 2022.2
Browse files Browse the repository at this point in the history
  • Loading branch information
DenWav committed Aug 15, 2022
2 parents 9fd411e + 6f8cb6a commit 52442b0
Show file tree
Hide file tree
Showing 861 changed files with 1,484 additions and 1,098 deletions.
43 changes: 37 additions & 6 deletions build.gradle.kts
Expand Up @@ -3,7 +3,7 @@
*
* https://minecraftdev.org
*
* Copyright (c) 2021 minecraft-dev
* Copyright (c) 2022 minecraft-dev
*
* MIT License
*/
Expand All @@ -14,16 +14,17 @@ import org.gradle.internal.os.OperatingSystem
import org.jetbrains.gradle.ext.settings
import org.jetbrains.gradle.ext.taskTriggers
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jlleitschuh.gradle.ktlint.tasks.BaseKtLintCheckTask

plugins {
kotlin("jvm") version "1.6.20"
kotlin("jvm") version "1.7.10"
java
mcdev
groovy
idea
id("org.jetbrains.intellij") version "1.7.0"
id("org.jetbrains.intellij") version "1.8.0"
id("org.cadixdev.licenser")
id("org.jlleitschuh.gradle.ktlint") version "10.0.0"
id("org.jlleitschuh.gradle.ktlint") version "10.3.0"
}

val ideaVersionName: String by project
Expand Down Expand Up @@ -109,6 +110,34 @@ dependencies {

testImplementation(libs.junit.api)
testRuntimeOnly(libs.junit.entine)
testRuntimeOnly(libs.junit.platform.launcher)
}

val artifactType = Attribute.of("artifactType", String::class.java)
val filtered = Attribute.of("filtered", Boolean::class.javaObjectType)

dependencies {
attributesSchema {
attribute(filtered)
}
artifactTypes.getByName("jar") {
attributes.attribute(filtered, false)
}

registerTransform(Filter::class) {
from.attribute(filtered, false).attribute(artifactType, "jar")
to.attribute(filtered, true).attribute(artifactType, "jar")

parameters {
ideaVersion.set(providers.gradleProperty("ideaVersion"))
ideaVersionName.set(providers.gradleProperty("ideaVersionName"))
depsFile.set(layout.projectDirectory.file(".gradle/intellij-deps.json"))
}
}
}

configurations.compileClasspath {
attributes.attribute(filtered, true)
}

intellij {
Expand Down Expand Up @@ -231,6 +260,8 @@ idea {
module {
generatedSourceDirs.add(file("build/gen"))
excludeDirs.add(file(intellij.sandboxDir.get()))
isDownloadJavadoc = true
isDownloadSources = true
}
}

Expand Down Expand Up @@ -267,8 +298,8 @@ license {
}
}

ktlint {
enableExperimentalRules.set(true)
tasks.withType<BaseKtLintCheckTask>().configureEach {
workerMaxHeapSize.set("512m")
}

tasks.register("format") {
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/build.gradle.kts
Expand Up @@ -3,7 +3,7 @@
*
* https://minecraftdev.org
*
* Copyright (c) 2021 minecraft-dev
* Copyright (c) 2022 minecraft-dev
*
* MIT License
*/
Expand All @@ -18,6 +18,6 @@ repositories {
}

dependencies {
implementation("com.google.code.gson:gson:2.8.6")
implementation("com.google.code.gson:gson:2.9.1")
implementation("org.cadixdev.licenser:org.cadixdev.licenser.gradle.plugin:0.6.1")
}
11 changes: 11 additions & 0 deletions buildSrc/settings.gradle.kts
@@ -0,0 +1,11 @@
/*
* Minecraft Dev for IntelliJ
*
* https://minecraftdev.org
*
* Copyright (c) 2022 minecraft-dev
*
* MIT License
*/

rootProject.name = "buildSrc"
102 changes: 102 additions & 0 deletions buildSrc/src/main/kotlin/Filter.kt
@@ -0,0 +1,102 @@
/*
* Minecraft Dev for IntelliJ
*
* https://minecraftdev.org
*
* Copyright (c) 2022 minecraft-dev
*
* MIT License
*/

import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import java.nio.file.Files
import java.nio.file.Path
import javax.inject.Inject
import org.gradle.api.artifacts.transform.CacheableTransform
import org.gradle.api.artifacts.transform.InputArtifact
import org.gradle.api.artifacts.transform.TransformAction
import org.gradle.api.artifacts.transform.TransformOutputs
import org.gradle.api.artifacts.transform.TransformParameters
import org.gradle.api.file.FileSystemLocation
import org.gradle.api.file.ProjectLayout
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity

abstract class Filter : TransformAction<Filter.Params> {
interface Params : TransformParameters {
@get:Input
val ideaVersion: Property<String>
@get:Input
val ideaVersionName: Property<String>
@get:PathSensitive(PathSensitivity.NONE)
@get:InputFile
val depsFile: RegularFileProperty
}

@get:PathSensitive(PathSensitivity.NONE)
@get:InputArtifact
abstract val inputArtifact: Provider<FileSystemLocation>

@get:Inject
abstract val layout: ProjectLayout

private val deps: List<Dep>?

init {
deps = run {
val depsFile = parameters.depsFile.orNull?.asFile ?: return@run null
if (!depsFile.exists()) {
return@run null
}

val depList: DepList = depsFile.bufferedReader().use { reader ->
Gson().fromJson(reader, DepList::class.java)
}

if (
parameters.ideaVersion.orNull == depList.intellijVersion &&
parameters.ideaVersionName.orNull == depList.intellijVersionName
) {
depList.deps
} else {
null
}
}
}

override fun transform(outputs: TransformOutputs) {
val input = inputArtifact.get().asFile.toPath()

// exclude the coroutines jar
// We include our own - but also IntelliJ's jar breaks sources
val inputParts = input.map { it.toString() }
if (!inputParts.containsAll(pathParts)) {
outputs.file(inputArtifact)
return
}

val fileName = inputParts.last()
if (fileName.startsWith("kotlinx-coroutines")) {
return
}

deps?.forEach { d ->
if (fileName == "${d.artifactId}-${d.version}.jar") {
return
}
}

outputs.file(inputArtifact)
}

companion object {
private val pathParts = listOf("com.jetbrains.intellij.idea", "ideaIC", "lib")
}
}
7 changes: 2 additions & 5 deletions buildSrc/src/main/kotlin/mcdev.gradle.kts
Expand Up @@ -3,7 +3,7 @@
*
* https://minecraftdev.org
*
* Copyright (c) 2021 minecraft-dev
* Copyright (c) 2022 minecraft-dev
*
* MIT License
*/
Expand All @@ -28,12 +28,9 @@ val jsonFile = file("$projectDir/$fileName")
val ideaVersion: String by project
val ideaVersionName: String by project

data class DepList(val intellijVersion: String, val intellijVersionName: String, val deps: List<Dep>)
data class Dep(val groupId: String, val artifactId: String, val version: String)

if (jsonFile.exists()) {
val deps: DepList = jsonFile.bufferedReader().use { reader ->
Gson().fromJson(reader, object : TypeToken<DepList>() {}.type)
Gson().fromJson(reader, DepList::class.java)
}
if (ideaVersion != deps.intellijVersion || ideaVersionName != deps.intellijVersionName) {
println("IntelliJ library sources file definition is out of date, deleting")
Expand Down
5 changes: 4 additions & 1 deletion buildSrc/src/main/kotlin/util.kt
Expand Up @@ -3,7 +3,7 @@
*
* https://minecraftdev.org
*
* Copyright (c) 2021 minecraft-dev
* Copyright (c) 2022 minecraft-dev
*
* MIT License
*/
Expand Down Expand Up @@ -95,3 +95,6 @@ fun Project.parser(bnf: String, pack: String): TaskDelegate<JavaExec> {
)
}
}

data class DepList(val intellijVersion: String, val intellijVersionName: String, val deps: List<Dep>)
data class Dep(val groupId: String, val artifactId: String, val version: String)
2 changes: 1 addition & 1 deletion copyright.txt
Expand Up @@ -2,6 +2,6 @@ Minecraft Dev for IntelliJ

https://minecraftdev.org

Copyright (c) 2021 minecraft-dev
Copyright (c) 2022 minecraft-dev

MIT License
2 changes: 1 addition & 1 deletion gradle.properties
Expand Up @@ -3,7 +3,7 @@
#
# https://minecraftdev.org
#
# Copyright (c) 2021 minecraft-dev
# Copyright (c) 2022 minecraft-dev
#
# MIT License
#
Expand Down
15 changes: 9 additions & 6 deletions gradle/libs.versions.toml
@@ -1,10 +1,12 @@
[versions]
coroutines = "1.5.2"
junit = "5.7.1"
asm = "9.2"
coroutines = "1.6.3"
junit = "5.9.0"
junit-platform = "1.9.0"
asm = "9.3"

[libraries]
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" }

templateMakerFabric = "com.extracraftx.minecraft:TemplateMakerFabric:0.4.1"
Expand All @@ -17,8 +19,8 @@ grammarKit = "org.jetbrains.idea:grammar-kit:1.5.1"

# Gradle Tooling
gradleToolingExtension = "com.jetbrains.intellij.gradle:gradle-tooling-extension:222-EAP-SNAPSHOT"
annotations = "org.jetbrains:annotations:20.1.0"
groovy = "org.codehaus.groovy:groovy-all:2.5.14"
annotations = "org.jetbrains:annotations:23.0.0"
groovy = "org.codehaus.groovy:groovy-all:2.5.18"

asm = { module = "org.ow2.asm:asm", version.ref = "asm" }
asm-tree = { module = "org.ow2.asm:asm-tree", version.ref = "asm" }
Expand All @@ -32,7 +34,8 @@ 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" }
junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher", version.ref = "junit-platform" }

[bundles]
coroutines = ["coroutines-core", "coroutines-swing"]
coroutines = ["coroutines-core", "coroutines-jdk8", "coroutines-swing"]
asm = ["asm", "asm-tree", "asm-analysis"]
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 6 additions & 0 deletions gradlew
Expand Up @@ -205,6 +205,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
14 changes: 8 additions & 6 deletions gradlew.bat
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,7 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down
2 changes: 1 addition & 1 deletion license.txt
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2021 minecraft-dev
Copyright (c) 2022 minecraft-dev

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Expand Up @@ -3,7 +3,7 @@
*
* https://minecraftdev.org
*
* Copyright (c) 2021 minecraft-dev
* Copyright (c) 2022 minecraft-dev
*
* MIT License
*/
Expand Down

0 comments on commit 52442b0

Please sign in to comment.