Skip to content

Commit e4ae7da

Browse files
committed
Merge branch '2023.3' into 2024.1
# Conflicts: # build.gradle.kts # gradle.properties
2 parents 65098a4 + b7837c8 commit e4ae7da

File tree

326 files changed

+18477
-1159
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

326 files changed

+18477
-1159
lines changed

build.gradle.kts

Lines changed: 56 additions & 183 deletions
Original file line numberDiff line numberDiff line change
@@ -18,52 +18,33 @@
1818
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1919
*/
2020

21-
import org.cadixdev.gradle.licenser.header.HeaderStyle
22-
import org.cadixdev.gradle.licenser.tasks.LicenseUpdate
2321
import org.gradle.internal.jvm.Jvm
2422
import org.jetbrains.changelog.Changelog
2523
import org.jetbrains.gradle.ext.settings
2624
import org.jetbrains.gradle.ext.taskTriggers
27-
import org.jetbrains.intellij.tasks.PrepareSandboxTask
28-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
29-
import org.jlleitschuh.gradle.ktlint.tasks.BaseKtLintCheckTask
30-
import org.jlleitschuh.gradle.ktlint.tasks.KtLintFormatTask
25+
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
26+
import org.jetbrains.intellij.platform.gradle.tasks.PrepareSandboxTask
3127

3228
plugins {
33-
kotlin("jvm") version "1.9.22"
34-
java
35-
mcdev
3629
groovy
37-
idea
38-
id("org.jetbrains.intellij") version "1.17.2"
39-
id("org.cadixdev.licenser")
40-
id("org.jlleitschuh.gradle.ktlint") version "10.3.0"
41-
id("org.jetbrains.changelog") version "2.2.0"
30+
id(libs.plugins.changelog.get().pluginId)
31+
alias(libs.plugins.idea.ext)
32+
`mcdev-core`
33+
`mcdev-parsing`
34+
`mcdev-publishing`
4235
}
4336

4437
val ideaVersionName: String by project
4538
val coreVersion: String by project
46-
val pluginTomlVersion: String by project
4739

4840
val gradleToolingExtension: Configuration by configurations.creating
4941
val testLibs: Configuration by configurations.creating {
5042
isTransitive = false
5143
}
5244

53-
group = "com.demonwav.minecraft-dev"
45+
group = "com.demonwav.mcdev"
5446
version = "$ideaVersionName-$coreVersion"
5547

56-
java {
57-
toolchain {
58-
languageVersion.set(JavaLanguageVersion.of(17))
59-
}
60-
}
61-
kotlin {
62-
jvmToolchain {
63-
languageVersion.set(java.toolchain.languageVersion.get())
64-
}
65-
}
66-
6748
val gradleToolingExtensionSourceSet: SourceSet = sourceSets.create("gradle-tooling-extension") {
6849
configurations.named(compileOnlyConfigurationName) {
6950
extendsFrom(gradleToolingExtension)
@@ -72,6 +53,7 @@ val gradleToolingExtensionSourceSet: SourceSet = sourceSets.create("gradle-tooli
7253
val gradleToolingExtensionJar = tasks.register<Jar>(gradleToolingExtensionSourceSet.jarTaskName) {
7354
from(gradleToolingExtensionSourceSet.output)
7455
archiveClassifier.set("gradle-tooling-extension")
56+
exclude("META-INF/plugin.xml")
7557
}
7658

7759
val templatesSourceSet: SourceSet = sourceSets.create("templates") {
@@ -100,49 +82,47 @@ val externalAnnotationsJar = tasks.register<Jar>("externalAnnotationsJar") {
10082
archiveFileName.set("externalAnnotations.jar")
10183
}
10284

103-
repositories {
104-
maven("https://repo.denwav.dev/repository/maven-public/")
105-
maven("https://maven.fabricmc.net/") {
106-
content {
107-
includeModule("net.fabricmc", "mapping-io")
108-
includeModule("net.fabricmc", "fabric-loader")
109-
}
110-
}
111-
mavenCentral()
112-
maven("https://repo.spongepowered.org/maven/")
113-
}
114-
11585
dependencies {
11686
// Add tools.jar for the JDI API
11787
implementation(files(Jvm.current().toolsJar))
11888

89+
implementation(files(gradleToolingExtensionJar))
90+
11991
implementation(libs.mixinExtras.expressions)
12092
testLibs(libs.mixinExtras.common)
12193

122-
// Kotlin
123-
implementation(kotlin("stdlib-jdk8"))
124-
implementation(kotlin("reflect"))
125-
implementation(libs.bundles.coroutines) {
126-
exclude(module = "kotlinx-coroutines-core-jvm")
127-
}
128-
129-
implementation(files(gradleToolingExtensionJar))
130-
13194
implementation(libs.mappingIo)
13295
implementation(libs.bundles.asm)
13396

13497
implementation(libs.bundles.fuel)
13598

136-
jflex(libs.jflex.lib)
137-
jflexSkeleton(libs.jflex.skeleton) {
138-
artifact {
139-
extension = "skeleton"
140-
}
99+
intellijPlatform {
100+
intellijIdeaCommunity(libs.versions.intellij.ide)
101+
102+
// Bundled plugin dependencies
103+
bundledPlugin("com.intellij.java")
104+
bundledPlugin("org.jetbrains.idea.maven")
105+
bundledPlugin("com.intellij.gradle")
106+
bundledPlugin("org.intellij.groovy")
107+
bundledPlugin("ByteCodeViewer")
108+
bundledPlugin("org.intellij.intelliLang")
109+
bundledPlugin("com.intellij.properties")
110+
111+
// Optional dependencies
112+
bundledPlugin("org.jetbrains.kotlin")
113+
bundledPlugin("org.toml.lang")
114+
bundledPlugin("org.jetbrains.plugins.yaml")
115+
116+
testFramework(TestFrameworkType.JUnit5)
117+
testFramework(TestFrameworkType.Plugin.Java)
118+
119+
pluginVerifier()
141120
}
142-
grammarKit(libs.grammarKit)
143121

144122
testLibs(libs.test.mockJdk)
145123
testLibs(libs.test.mixin)
124+
testLibs(libs.test.spigotapi)
125+
testLibs(libs.test.bungeecord)
146126
testLibs(libs.test.spongeapi) {
147127
artifact {
148128
classifier = "shaded"
@@ -161,37 +141,6 @@ dependencies {
161141
gradleToolingExtension(libs.groovy)
162142
gradleToolingExtension(libs.gradleToolingExtension)
163143
gradleToolingExtension(libs.annotations)
164-
165-
testImplementation(libs.junit.api)
166-
testRuntimeOnly(libs.junit.entine)
167-
testRuntimeOnly(libs.junit.platform.launcher)
168-
}
169-
170-
val artifactType = Attribute.of("artifactType", String::class.java)
171-
val filtered = Attribute.of("filtered", Boolean::class.javaObjectType)
172-
173-
dependencies {
174-
attributesSchema {
175-
attribute(filtered)
176-
}
177-
artifactTypes.getByName("jar") {
178-
attributes.attribute(filtered, false)
179-
}
180-
181-
registerTransform(Filter::class) {
182-
from.attribute(filtered, false).attribute(artifactType, "jar")
183-
to.attribute(filtered, true).attribute(artifactType, "jar")
184-
185-
parameters {
186-
ideaVersion.set(providers.gradleProperty("ideaVersion"))
187-
ideaVersionName.set(providers.gradleProperty("ideaVersionName"))
188-
depsFile.set(layout.projectDirectory.file(".gradle/intellij-deps.json"))
189-
}
190-
}
191-
}
192-
193-
configurations.compileClasspath {
194-
attributes.attribute(filtered, true)
195144
}
196145

197146
changelog {
@@ -200,67 +149,21 @@ changelog {
200149
path = "changelog.md"
201150
}
202151

203-
intellij {
204-
// IntelliJ IDEA dependency
205-
version.set(providers.gradleProperty("ideaVersion"))
206-
// Bundled plugin dependencies
207-
plugins.addAll(
208-
"java",
209-
"maven",
210-
"gradle",
211-
"Groovy",
212-
"Kotlin",
213-
"org.toml.lang:$pluginTomlVersion",
214-
"ByteCodeViewer",
215-
"org.intellij.intelliLang",
216-
"properties",
217-
// needed dependencies for unit tests
218-
"junit"
219-
)
220-
221-
pluginName.set("Minecraft Development")
222-
updateSinceUntilBuild.set(true)
223-
224-
downloadSources.set(providers.gradleProperty("downloadIdeaSources").map { it.toBoolean() })
152+
intellijPlatform {
153+
projectName = "Minecraft Development"
225154

226-
sandboxDir.set(layout.projectDirectory.dir(".sandbox").toString())
155+
pluginVerification {
156+
ides {
157+
recommended()
158+
}
159+
}
227160
}
228161

229162
tasks.patchPluginXml {
230163
val changelog = project.changelog
231164
changeNotes = changelog.render(Changelog.OutputType.HTML)
232165
}
233166

234-
tasks.publishPlugin {
235-
// Build numbers are used for
236-
properties["buildNumber"]?.let { buildNumber ->
237-
project.version = "${project.version}-$buildNumber"
238-
}
239-
properties["mcdev.deploy.token"]?.let { deployToken ->
240-
token.set(deployToken.toString())
241-
}
242-
channels.add(properties["mcdev.deploy.channel"]?.toString() ?: "Stable")
243-
}
244-
245-
tasks.runPluginVerifier {
246-
ideVersions.addAll("IC-$ideaVersionName")
247-
}
248-
249-
tasks.withType<JavaCompile>().configureEach {
250-
options.encoding = "UTF-8"
251-
options.compilerArgs = listOf("-proc:none")
252-
options.release.set(17)
253-
}
254-
255-
tasks.withType<KotlinCompile>().configureEach {
256-
kotlinOptions {
257-
jvmTarget = JavaVersion.VERSION_17.toString()
258-
// K2 causes the following error: https://youtrack.jetbrains.com/issue/KT-52786
259-
freeCompilerArgs = listOf(/*"-Xuse-k2", */"-Xjvm-default=all", "-Xjdk-release=17")
260-
kotlinDaemonJvmArguments.add("-Xmx2G")
261-
}
262-
}
263-
264167
// Compile classes to be loaded into the Gradle VM to Java 5 to match Groovy
265168
// This is for maximum compatibility, these classes will be loaded into every Gradle import on all
266169
// projects (not just Minecraft), so we don't want to break that with an incompatible class version.
@@ -296,7 +199,6 @@ tasks.processResources {
296199

297200
tasks.test {
298201
dependsOn(tasks.jar, testLibs)
299-
useJUnitPlatform()
300202

301203
testLibs.resolvedConfiguration.resolvedArtifacts.forEach {
302204
systemProperty("testLibs.${it.name}", it.file.absolutePath)
@@ -312,26 +214,21 @@ tasks.test {
312214

313215
idea {
314216
project.settings.taskTriggers.afterSync("generate")
315-
module {
316-
generatedSourceDirs.add(file("build/gen"))
317-
excludeDirs.add(file(intellij.sandboxDir.get()))
318-
isDownloadJavadoc = true
319-
isDownloadSources = true
320-
}
321217
}
322218

323219
license {
324-
header.set(resources.text.fromFile(file("copyright.txt")))
325-
style["flex"] = HeaderStyle.BLOCK_COMMENT.format
326-
style["bnf"] = HeaderStyle.BLOCK_COMMENT.format
327-
328220
val endings = listOf("java", "kt", "kts", "groovy", "gradle.kts", "xml", "properties", "html", "flex", "bnf")
329221
exclude("META-INF/plugin.xml") // https://youtrack.jetbrains.com/issue/IDEA-345026
330222
include(endings.map { "**/*.$it" })
331223

332-
exclude("com/demonwav/mcdev/platform/mixin/invalidInjectorMethodSignature/*.java")
224+
val projectDir = layout.projectDirectory.asFile
225+
exclude {
226+
it.file.toRelativeString(projectDir)
227+
.replace("\\", "/")
228+
.startsWith("src/test/resources")
229+
}
333230

334-
this.tasks {
231+
tasks {
335232
register("gradle") {
336233
files.from(
337234
fileTree(project.projectDir) {
@@ -348,6 +245,14 @@ license {
348245
},
349246
)
350247
}
248+
register("mixinTestData") {
249+
files.from(
250+
project.fileTree(project.projectDir.resolve("mixin-test-data")) {
251+
include("**/*.java", "**/*.kts")
252+
exclude("**/build/**")
253+
},
254+
)
255+
}
351256
register("grammars") {
352257
files.from(project.fileTree("src/main/grammars"))
353258
}
@@ -357,19 +262,6 @@ license {
357262
}
358263
}
359264

360-
ktlint {
361-
disabledRules.add("filename")
362-
}
363-
tasks.withType<BaseKtLintCheckTask>().configureEach {
364-
workerMaxHeapSize.set("512m")
365-
}
366-
367-
tasks.register("format") {
368-
group = "minecraft"
369-
description = "Formats source code according to project style"
370-
dependsOn(tasks.withType<LicenseUpdate>(), tasks.withType<KtLintFormatTask>())
371-
}
372-
373265
val generateAtLexer by lexer("AtLexer", "com/demonwav/mcdev/platform/mcp/at/gen")
374266
val generateAtParser by parser("AtParser", "com/demonwav/mcdev/platform/mcp/at/gen")
375267

@@ -414,12 +306,6 @@ sourceSets.main { java.srcDir(generate) }
414306
// Remove gen directory on clean
415307
tasks.clean { delete(generate) }
416308

417-
tasks.register("cleanSandbox", Delete::class) {
418-
group = "intellij"
419-
description = "Deletes the sandbox directory."
420-
delete(layout.projectDirectory.dir(".sandbox"))
421-
}
422-
423309
tasks.withType<PrepareSandboxTask> {
424310
pluginJar.set(tasks.jar.get().archiveFile)
425311
from(externalAnnotationsJar) {
@@ -442,16 +328,3 @@ tasks.runIde {
442328
// systemProperty("user.language", "fr")
443329
// systemProperty("user.country", "FR")
444330
}
445-
446-
tasks.buildSearchableOptions {
447-
// not working atm
448-
enabled = false
449-
}
450-
451-
tasks.instrumentCode {
452-
enabled = false
453-
}
454-
455-
tasks.instrumentedJar {
456-
enabled = false
457-
}

buildSrc/build.gradle.kts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,30 @@
1818
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1919
*/
2020

21+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
22+
2123
plugins {
2224
`kotlin-dsl`
2325
}
2426

27+
tasks.withType<JavaCompile>().configureEach {
28+
options.release.set(8)
29+
}
30+
tasks.withType<KotlinCompile>().configureEach {
31+
kotlinOptions.jvmTarget = "1.8"
32+
}
33+
2534
repositories {
2635
mavenCentral()
2736
gradlePluginPortal()
2837
}
2938

3039
dependencies {
31-
implementation("com.google.code.gson:gson:2.9.1")
32-
implementation("org.cadixdev.licenser:org.cadixdev.licenser.gradle.plugin:0.6.1")
40+
// hack for version catalogs
41+
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
42+
implementation(libs.gson)
43+
implementation(libs.kotlin.plugin)
44+
implementation(libs.intellij.plugin)
45+
implementation(libs.licenser.plugin)
46+
implementation(libs.changelog.plugin)
3347
}

0 commit comments

Comments
 (0)