Skip to content

Commit c458360

Browse files
committed
Bump versions of build tooling
The main thing of note is Spotless, which also bumps the version of Ktlint. I've been putting this off for a while[^1], as this changed a bunch of formatting, and Spotless's (broken) caching was making it hard to test. Ended up downloading ktlint and running it localy. [^1]: 8204944
1 parent 09ad6c1 commit c458360

File tree

9 files changed

+518
-548
lines changed

9 files changed

+518
-548
lines changed

.editorconfig

+12-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ indent_size = 2
2727
[*.yml]
2828
indent_size = 2
2929

30-
[{*.kt,*.kts}]
30+
[*.{kt,kts}]
3131
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
3232
ij_kotlin_continuation_indent_size = 4
3333
ij_kotlin_spaces_around_equality_operators = true
@@ -39,3 +39,14 @@ ij_kotlin_allow_trailing_comma_on_call_site = true
3939
ij_kotlin_method_parameters_wrap = off
4040
ij_kotlin_call_parameters_wrap = off
4141
ij_kotlin_extends_list_wrap = off
42+
43+
ktlint_code_style = intellij_idea
44+
ktlint_standard_class-naming = disabled
45+
ktlint_standard_class-signature = disabled
46+
ktlint_standard_function-naming = disabled
47+
ktlint_standard_no-wildcard-imports = disabled
48+
49+
# FIXME: These two are disable right now as they're over-eager in putting things
50+
# on the same line. We should set max_line_length and handle this properly.
51+
ktlint_standard_function-signature = disabled
52+
ktlint_standard_function-expression-body = disabled

buildSrc/src/main/kotlin/cc-tweaked.forge.gradle.kts

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import cc.tweaked.gradle.CCTweakedExtension
88
import cc.tweaked.gradle.CCTweakedPlugin
9-
import cc.tweaked.gradle.IdeaRunConfigurations
109
import cc.tweaked.gradle.MinecraftConfigurations
1110

1211
plugins {
@@ -20,7 +19,7 @@ val mcVersion: String by extra
2019

2120
legacyForge {
2221
val libs = project.extensions.getByType<VersionCatalogsExtension>().named("libs")
23-
version = "${mcVersion}-${libs.findVersion("forge").get()}"
22+
version = "$mcVersion-${libs.findVersion("forge").get()}"
2423

2524
parchment {
2625
minecraftVersion = libs.findVersion("parchmentMc").get().toString()

buildSrc/src/main/kotlin/cc-tweaked.java-convention.gradle.kts

+7-14
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ base.archivesName.convention("cc-tweaked-$mcVersion-${project.name}")
2929

3030
java {
3131
toolchain {
32-
languageVersion= CCTweakedPlugin.JAVA_VERSION
32+
languageVersion = CCTweakedPlugin.JAVA_VERSION
3333
}
3434

3535
withSourcesJar()
@@ -86,6 +86,7 @@ sourceSets.all {
8686
check("InvalidBlockTag", CheckSeverity.OFF) // Broken by @cc.xyz
8787
check("InlineMeSuggester", CheckSeverity.OFF) // Minecraft uses @Deprecated liberally
8888
// Too many false positives right now. Maybe we need an indirection for it later on.
89+
check("AssignmentExpression", CheckSeverity.OFF) // I'm a bad person.
8990
check("ReferenceEquality", CheckSeverity.OFF)
9091
check("EnumOrdinal", CheckSeverity.OFF) // For now. We could replace most of these with EnumMap.
9192
check("OperatorPrecedence", CheckSeverity.OFF) // For now.
@@ -114,7 +115,6 @@ tasks.compileTestJava {
114115
}
115116
}
116117

117-
118118
tasks.withType(JavaCompile::class.java).configureEach {
119119
options.encoding = "UTF-8"
120120
}
@@ -163,7 +163,7 @@ tasks.test {
163163

164164
tasks.withType(JacocoReport::class.java).configureEach {
165165
reports.xml.required = true
166-
reports.html.required =true
166+
reports.html.required = true
167167
}
168168

169169
project.plugins.withType(CCTweakedPlugin::class.java) {
@@ -187,30 +187,23 @@ spotless {
187187
fun FormatExtension.defaults() {
188188
endWithNewline()
189189
trimTrailingWhitespace()
190-
indentWithSpaces(4)
190+
leadingTabsToSpaces(4)
191191
}
192192

193193
java {
194194
defaults()
195+
importOrder("", "javax|java", "\\#")
195196
removeUnusedImports()
196197
}
197198

198-
val ktlintConfig = mapOf(
199-
"ktlint_standard_no-wildcard-imports" to "disabled",
200-
"ktlint_standard_class-naming" to "disabled",
201-
"ktlint_standard_function-naming" to "disabled",
202-
"ij_kotlin_allow_trailing_comma" to "true",
203-
"ij_kotlin_allow_trailing_comma_on_call_site" to "true",
204-
)
205-
206199
kotlinGradle {
207200
defaults()
208-
ktlint().editorConfigOverride(ktlintConfig)
201+
ktlint()
209202
}
210203

211204
kotlin {
212205
defaults()
213-
ktlint().editorConfigOverride(ktlintConfig)
206+
ktlint()
214207
}
215208
}
216209

buildSrc/src/main/kotlin/cc/tweaked/gradle/ExecTasks.kt

-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
package cc.tweaked.gradle
66

77
import org.gradle.api.file.DirectoryProperty
8-
import org.gradle.api.provider.Property
98
import org.gradle.api.tasks.AbstractExecTask
109
import org.gradle.api.tasks.OutputDirectory
11-
import java.io.File
1210

1311
abstract class ExecToDir : AbstractExecTask<ExecToDir>(ExecToDir::class.java) {
1412
@get:OutputDirectory

buildSrc/src/main/kotlin/cc/tweaked/gradle/IdeaRunConfigurations.kt

+1-89
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import javax.xml.xpath.XPathFactory
2525
* Would be good to PR some (or all) of these changes upstream at some point.
2626
*
2727
* @see net.fabricmc.loom.configuration.ide.idea.IdeaSyncTask
28-
* @see net.minecraftforge.gradle.common.util.runs.IntellijRunGenerator
2928
*/
3029
internal class IdeaRunConfigurations(project: Project) {
3130
private val rootProject = project.rootProject
@@ -35,33 +34,16 @@ internal class IdeaRunConfigurations(project: Project) {
3534
private val writer = TransformerFactory.newInstance().newTransformer()
3635

3736
private val ideaDir = rootProject.file(".idea/")
38-
private val buildDir: Lazy<String?> = lazy {
39-
val ideaMisc = ideaDir.resolve("misc.xml")
40-
41-
try {
42-
val doc = Files.newBufferedReader(ideaMisc.toPath()).use {
43-
documentBuilder.parse(InputSource(it))
44-
}
45-
val node =
46-
xpath.evaluate("//component[@name=\"ProjectRootManager\"]/output", doc, XPathConstants.NODE) as Node
47-
val attr = node.attributes.getNamedItem("url") as Attr
48-
attr.value.removePrefix("file://")
49-
} catch (e: Exception) {
50-
LOGGER.error("Failed to find root directory", e)
51-
null
52-
}
53-
}
5437

5538
fun patch() = synchronized(LOCK) {
5639
val runConfigDir = ideaDir.resolve("runConfigurations")
5740
if (!runConfigDir.isDirectory) return
5841

5942
Files.list(runConfigDir.toPath()).use {
6043
for (configuration in it) {
61-
val filename = configuration.fileName.toString();
44+
val filename = configuration.fileName.toString()
6245
when {
6346
filename.endsWith("_fabric.xml") -> patchFabric(configuration)
64-
filename.startsWith("forge_") && filename.endsWith(".xml") -> patchForge(configuration)
6547
else -> {}
6648
}
6749
}
@@ -72,65 +54,6 @@ internal class IdeaRunConfigurations(project: Project) {
7254
setXml("//configuration", "folderName") { "Fabric" }
7355
}
7456

75-
private fun patchForge(path: Path) = withXml(path) {
76-
val configId = path.fileName.toString().removePrefix("forge_").removeSuffix(".xml")
77-
val sourceSet = forgeConfigs[configId]
78-
if (sourceSet == null) {
79-
LOGGER.error("[{}] Cannot map run configuration to a known source set", path)
80-
return@withXml
81-
}
82-
83-
setXml("//configuration", "folderName") { "Forge" }
84-
setXml("//configuration/module", "name") { "${rootProject.name}.forge.$sourceSet" }
85-
86-
if (buildDir.value == null) return@withXml
87-
setXml("//configuration/envs/env[@name=\"MOD_CLASSES\"]", "value") { classpath ->
88-
val classes = classpath!!.split(':')
89-
val newClasses = mutableListOf<String>()
90-
fun appendUnique(x: String) {
91-
if (!newClasses.contains(x)) newClasses.add(x)
92-
}
93-
94-
for (entry in classes) {
95-
if (!entry.contains("/out/")) {
96-
appendUnique(entry)
97-
continue
98-
}
99-
100-
val match = CLASSPATH_ENTRY.matchEntire(entry)
101-
if (match != null) {
102-
val modId = match.groups["modId"]!!.value
103-
val proj = match.groups["proj"]!!.value
104-
var component = match.groups["component"]!!.value
105-
if (component == "production") component = "main"
106-
107-
appendUnique(forgeModEntry(modId, proj, component))
108-
} else {
109-
LOGGER.warn("[{}] Unknown classpath entry {}", path, entry)
110-
appendUnique(entry)
111-
}
112-
}
113-
114-
// Ensure common code is on the classpath
115-
for (proj in listOf("common", "common-api")) {
116-
for (component in listOf("main", "client")) {
117-
appendUnique(forgeModEntry("computercraft", proj, component))
118-
}
119-
}
120-
121-
if (newClasses.any { it.startsWith("cctest%%") }) {
122-
appendUnique(forgeModEntry("cctest", "core", "testFixtures"))
123-
appendUnique(forgeModEntry("cctest", "common", "testFixtures"))
124-
appendUnique(forgeModEntry("cctest", "common", "testMod"))
125-
}
126-
127-
newClasses.joinToString(":")
128-
}
129-
}
130-
131-
private fun forgeModEntry(mod: String, project: String, component: String) =
132-
"$mod%%${buildDir.value}/production/${rootProject.name}.$project.$component"
133-
13457
private fun LocatedDocument.setXml(xpath: String, attribute: String, value: (String?) -> String) {
13558
val node = this@IdeaRunConfigurations.xpath.evaluate(xpath, document, XPathConstants.NODE) as Node?
13659
if (node == null) {
@@ -159,16 +82,5 @@ internal class IdeaRunConfigurations(project: Project) {
15982
companion object {
16083
private val LOGGER = Logging.getLogger(IdeaRunConfigurations::class.java)
16184
private val LOCK = Any()
162-
163-
private val CLASSPATH_ENTRY =
164-
Regex("(?<modId>[a-z]+)%%\\\$PROJECT_DIR\\\$/projects/(?<proj>[a-z-]+)/out/(?<component>\\w+)/(?<type>[a-z]+)\$")
165-
166-
private val forgeConfigs = mapOf(
167-
"runClient" to "client",
168-
"runData" to "main",
169-
"runGameTestServer" to "testMod",
170-
"runServer" to "main",
171-
"runTestClient" to "testMod",
172-
)
17385
}
17486
}

gradle/libs.versions.toml

+7-7
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,20 @@ jmh = "1.37"
5858

5959
# Build tools
6060
cctJavadoc = "1.8.4"
61-
checkstyle = "10.21.2"
62-
errorProne-core = "2.36.0"
61+
checkstyle = "10.21.4"
62+
errorProne-core = "2.37.0"
6363
errorProne-plugin = "4.1.0"
64-
fabric-loom = "1.10.3"
64+
fabric-loom = "1.10.4"
6565
githubRelease = "2.5.2"
6666
gradleVersions = "0.50.0"
6767
ideaExt = "1.1.7"
68-
illuaminate = "0.1.0-74-gf1551d5"
68+
illuaminate = "0.1.0-83-g1131f68"
6969
lwjgl = "3.3.3"
7070
minotaur = "2.8.7"
71-
modDevGradle = "2.0.74"
72-
nullAway = "0.12.3"
71+
modDevGradle = "2.0.78"
72+
nullAway = "0.12.4"
7373
shadow = "8.3.1"
74-
spotless = "6.23.3"
74+
spotless = "7.0.2"
7575
taskTree = "2.1.1"
7676
teavm = "0.11.0-SQUID.1"
7777
vanillaExtract = "0.2.1"

0 commit comments

Comments
 (0)