User: kyle wood
Date: 05 Sep 24 01:28
Revision: b2eab2cf0edd059f8fcb4eeabd12ebd3c228562f
Summary:
Remove ktlint and dependency analyzer
TeamCity URL: https://ci.mcdev.io/viewModification.html?tab=vcsModificationFiles&modId=9657&personal=false
Index: build.gradle.kts
===================================================================
--- build.gradle.kts (revision 8467b15ed8602608c662281b957f1cdb3b5609a5)
+++ build.gradle.kts (revision b2eab2cf0edd059f8fcb4eeabd12ebd3c228562f)
@@ -143,33 +143,6 @@
gradleToolingExtension(libs.annotations)
}
-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(libs.versions.intellij.ide)
- ideaVersionName.set(providers.gradleProperty("ideaVersionName"))
- depsFile.set(layout.projectDirectory.file(".gradle/intellij-deps.json"))
- }
- }
-}
-
-configurations.compileClasspath {
- attributes.attribute(filtered, true)
-}
-
changelog {
version = coreVersion
groups.empty()
@@ -255,7 +228,7 @@
.startsWith("src/test/resources")
}
- this.tasks {
+ tasks {
register("gradle") {
files.from(
fileTree(project.projectDir) {
Index: buildSrc/build.gradle.kts
===================================================================
--- buildSrc/build.gradle.kts (revision 8467b15ed8602608c662281b957f1cdb3b5609a5)
+++ buildSrc/build.gradle.kts (revision b2eab2cf0edd059f8fcb4eeabd12ebd3c228562f)
@@ -43,6 +43,5 @@
implementation(libs.kotlin.plugin)
implementation(libs.intellij.plugin)
implementation(libs.licenser.plugin)
- implementation(libs.ktlint.plugin)
implementation(libs.changelog.plugin)
}
Index: buildSrc/src/main/kotlin/Filter.kt
===================================================================
--- buildSrc/src/main/kotlin/Filter.kt (revision 8467b15ed8602608c662281b957f1cdb3b5609a5)
+++ buildSrc/src/main/kotlin/Filter.kt (revision 8467b15ed8602608c662281b957f1cdb3b5609a5)
@@ -1,112 +0,0 @@
-/*
- * 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 .
- */
-
-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 {
- interface Params : TransformParameters {
- @get:Input
- val ideaVersion: Property
- @get:Input
- val ideaVersionName: Property
- @get:PathSensitive(PathSensitivity.NONE)
- @get:InputFile
- val depsFile: RegularFileProperty
- }
-
- @get:PathSensitive(PathSensitivity.NONE)
- @get:InputArtifact
- abstract val inputArtifact: Provider
-
- @get:Inject
- abstract val layout: ProjectLayout
-
- private val deps: List?
-
- 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")
- }
-}
Index: buildSrc/src/main/kotlin/ParserExec.kt
===================================================================
--- buildSrc/src/main/kotlin/ParserExec.kt (revision 8467b15ed8602608c662281b957f1cdb3b5609a5)
+++ buildSrc/src/main/kotlin/ParserExec.kt (revision b2eab2cf0edd059f8fcb4eeabd12ebd3c228562f)
@@ -27,7 +27,6 @@
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.Classpath
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
Index: buildSrc/src/main/kotlin/mcdev-core.gradle.kts
===================================================================
--- buildSrc/src/main/kotlin/mcdev-core.gradle.kts (revision 8467b15ed8602608c662281b957f1cdb3b5609a5)
+++ buildSrc/src/main/kotlin/mcdev-core.gradle.kts (revision b2eab2cf0edd059f8fcb4eeabd12ebd3c228562f)
@@ -18,12 +18,6 @@
* along with this program. If not, see .
*/
-import com.google.gson.Gson
-import com.google.gson.GsonBuilder
-import java.net.HttpURLConnection
-import java.net.URI
-import java.util.Properties
-import java.util.zip.ZipFile
import org.cadixdev.gradle.licenser.header.HeaderStyle
import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.kotlin.dsl.maven
@@ -32,7 +26,6 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-import org.jlleitschuh.gradle.ktlint.tasks.BaseKtLintCheckTask
plugins {
java
@@ -40,7 +33,6 @@
id("org.jetbrains.kotlin.jvm")
id("org.jetbrains.intellij.platform")
id("org.cadixdev.licenser")
- id("org.jlleitschuh.gradle.ktlint")
}
java {
@@ -105,7 +97,7 @@
dependencies {
implementation(libs.kotlin.stdlib)
implementation(libs.kotlin.reflect)
- implementation(libs.bundles.coroutines)
+ compileOnly(libs.bundles.coroutines)
testImplementation(libs.junit.api)
testCompileOnly(libs.junit.vintage) // Hack to get tests to compile and run
@@ -135,10 +127,6 @@
}
}
-tasks.withType().configureEach {
- workerMaxHeapSize = "512m"
-}
-
tasks.runIde {
maxHeapSize = "2G"
jvmArgs("--add-exports=java.base/jdk.internal.vm=ALL-UNNAMED")
@@ -157,87 +145,5 @@
tasks.register("format") {
group = "minecraft"
description = "Formats source code according to project style"
- dependsOn(tasks.licenseFormat, tasks.ktlintFormat)
+ dependsOn(tasks.licenseFormat)
}
-
-// Analyze dependencies
-val fileName = ".gradle/intellij-deps.json"
-val jsonFile = file("$projectDir/$fileName")
-
-val ideaVersion: String by project
-val ideaVersionName: String by project
-
-if (jsonFile.exists()) {
- val deps: DepList = jsonFile.bufferedReader().use { reader ->
- Gson().fromJson(reader, DepList::class.java)
- }
- if (ideaVersion != deps.intellijVersion || ideaVersionName != deps.intellijVersionName) {
- println("IntelliJ library sources file definition is out of date, deleting")
- jsonFile.delete()
- } else {
- dependencies {
- for ((groupId, artifactId, version) in deps.deps) {
- compileOnly(
- group = groupId,
- name = artifactId,
- version = version
- )
- }
- }
- }
-}
-
-tasks.register("resolveIntellijLibSources") {
- group = "minecraft"
- val compileClasspath by project.configurations
- dependsOn(compileClasspath)
-
- doLast {
- val files = compileClasspath.resolvedConfiguration.files
- val deps = files.asSequence()
- .map { it.toPath() }
- .filter {
- it.map { part -> part.toString() }.containsAll(listOf("com.jetbrains.intellij.idea", "ideaIC", "lib"))
- }
- .filter { it.fileName.toString().endsWith(".jar") }
- .mapNotNull { lib ->
- val name = lib.fileName.toString()
- return@mapNotNull ZipFile(lib.toFile()).use { zipFile ->
- val pomEntry = zipFile.stream()
- .filter { entry ->
- val entryName = entry.name
- entryName.contains("META-INF/maven")
- && entryName.split('/').any { name.contains(it) }
- && entryName.endsWith("pom.properties")
- }
- .findFirst()
- .orElse(null) ?: return@use null
- return@use zipFile.getInputStream(pomEntry).use { input ->
- val props = Properties()
- props.load(input)
- Dep(props["groupId"].toString(), props["artifactId"].toString(), props["version"].toString())
- }
- }
- }.filter { dep ->
- // Check if this dependency is available in Maven Central
- val groupPath = dep.groupId.replace('.', '/')
- val (_, artifact, ver) = dep
- val url = "https://repo.maven.apache.org/maven2/$groupPath/$artifact/$ver/$artifact-$ver-sources.jar"
- return@filter with(URI.create(url).toURL().openConnection() as HttpURLConnection) {
- try {
- requestMethod = "GET"
- val code = responseCode
- return@with code in 200..299
- } finally {
- disconnect()
- }
- }
- }.toList()
-
- val depList = DepList(ideaVersion, ideaVersionName, deps.sortedWith(compareBy { it.groupId }.thenBy { it.artifactId }))
- jsonFile.parentFile.mkdirs()
- jsonFile.bufferedWriter().use { writer ->
- GsonBuilder().setPrettyPrinting().create().toJson(depList, writer)
- }
- }
-}
Index: buildSrc/src/main/kotlin/util.kt
===================================================================
--- buildSrc/src/main/kotlin/util.kt (revision 8467b15ed8602608c662281b957f1cdb3b5609a5)
+++ buildSrc/src/main/kotlin/util.kt (revision b2eab2cf0edd059f8fcb4eeabd12ebd3c228562f)
@@ -18,23 +18,14 @@
* along with this program. If not, see .
*/
-import java.io.ByteArrayOutputStream
-import org.cadixdev.gradle.licenser.LicenseExtension
-import org.gradle.api.JavaVersion
import org.gradle.api.Project
-import org.gradle.api.provider.ListProperty
-import org.gradle.api.provider.Provider
-import org.gradle.api.tasks.JavaExec
import org.gradle.api.tasks.TaskContainer
import org.gradle.api.tasks.util.PatternFilterable
import org.gradle.kotlin.dsl.RegisteringDomainObjectDelegateProviderWithTypeAndAction
import org.gradle.kotlin.dsl.getValue
import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.registering
-import org.gradle.kotlin.dsl.configure
-fun ListProperty.addProvider(provider: Provider) = add(provider)
-
typealias TaskDelegate = RegisteringDomainObjectDelegateProviderWithTypeAndAction
fun Project.lexer(flex: String, pack: String): TaskDelegate {
@@ -74,6 +65,3 @@
this.grammarKit.setFrom(grammarKit)
}
}
-
-data class DepList(val intellijVersion: String, val intellijVersionName: String, val deps: List)
-data class Dep(val groupId: String, val artifactId: String, val version: String)
Index: gradle/libs.versions.toml
===================================================================
--- gradle/libs.versions.toml (revision 8467b15ed8602608c662281b957f1cdb3b5609a5)
+++ gradle/libs.versions.toml (revision b2eab2cf0edd059f8fcb4eeabd12ebd3c228562f)
@@ -6,7 +6,6 @@
asm = "9.6"
fuel = "2.3.1"
licenser = "0.6.1"
-ktlint = "10.3.0"
changelog = "2.2.0"
intellij-plugin = "2.0.1"
intellij-ide = "2023.2.2"
@@ -18,7 +17,6 @@
intellij-platform = { id = "org.jetbrains.intellij.platform", version.ref = "intellij-plugin" }
idea-ext = { id = "org.jetbrains.gradle.plugin.idea-ext", version.ref = "idea-ext" }
licenser = { id = "org.cadixdev.licenser", version.ref = "licenser" }
-ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
[libraries]
@@ -28,7 +26,6 @@
intellij-plugin = { module = "org.jetbrains.intellij.platform:org.jetbrains.intellij.platform.gradle.plugin", version.ref = "intellij-plugin" }
licenser-plugin = { module = "org.cadixdev.licenser:org.cadixdev.licenser.gradle.plugin", version.ref = "licenser" }
-ktlint-plugin = { module = "org.jlleitschuh.gradle.ktlint:org.jlleitschuh.gradle.ktlint.gradle.plugin", version.ref = "ktlint" }
changelog-plugin = { module = "org.jetbrains.changelog:org.jetbrains.changelog.gradle.plugin", version.ref = "changelog" }
coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }