Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch out spotless for an alternative #1530

Merged
merged 24 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
62f5add
Test replacing spotless with custom setup
lukebemish Jul 3, 2024
06f4c01
Make sure checks apply to main project and fix changes caused (presum…
lukebemish Jul 3, 2024
b8be9d1
Merge remote-tracking branch 'upstream/1.21.x' into no-more-spotless
lukebemish Jul 30, 2024
ca2d0cc
Update immaculate
lukebemish Jul 30, 2024
7bb51ad
Merge remote-tracking branch 'upstream/1.21.x' into no-more-spotless
lukebemish Jul 30, 2024
f2fb08e
Upgrade neogradle for lazy dependencies
lukebemish Jul 30, 2024
8285b5b
Update wrapper and fix all the stuff that broke with new NG versions
lukebemish Jul 30, 2024
ef4b331
Merge branch 'neoforged:1.21.x' into no-more-spotless
lukebemish Aug 12, 2024
995bc5a
Merge remote-tracking branch 'upstream/1.21.x' into no-more-spotless
lukebemish Sep 9, 2024
973a523
Switch to JDT version currently used by neoforge environment -- this …
lukebemish Sep 9, 2024
a80c431
Merge branch '1.21.x' into no-more-spotless
lukebemish Sep 9, 2024
44522ec
Merge branch '1.21.x' into no-more-spotless
lukebemish Sep 17, 2024
3f2746e
Merge branch '1.21.x' into no-more-spotless
lukebemish Nov 14, 2024
d8f75c3
Update to work with coremods project
lukebemish Nov 14, 2024
9c4e953
Revert unnecessary change
lukebemish Nov 18, 2024
322fb19
Merge branch '1.21.x' into no-more-spotless
lukebemish Nov 23, 2024
576d3d7
Merge branch '1.21.x' into no-more-spotless
Technici4n Dec 10, 2024
7eb15af
Update immaculate
lukebemish Dec 10, 2024
72e687c
Update immaculate to avoid deadlock possibility
lukebemish Dec 10, 2024
67d133f
Bump immaculate to version with refactored concurrency
lukebemish Dec 11, 2024
5a0c976
Update CONTRIBUTING.md
lukebemish Dec 11, 2024
16f56c6
Merge branch '1.21.x' into no-more-spotless
lukebemish Dec 11, 2024
693101a
Update to immaculate 0.1.6
lukebemish Dec 11, 2024
7d1e4dd
Change task mentioned in CONTRIBUTING.md
lukebemish Dec 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import java.util.regex.Pattern

plugins {
id 'net.neoforged.gradleutils' version '3.0.0'
id 'com.diffplug.spotless' version '6.22.0' apply false
id 'dev.lukebemish.immaculate' version '0.1.6' apply false
id 'net.neoforged.licenser' version '0.7.5'
id 'neoforge.formatting-conventions'
id 'neoforge.versioning'
Expand Down Expand Up @@ -56,14 +56,14 @@ license {
}

// Put spotless here because it wants the files to live inside the project root
spotless {
java {
target rootProject.fileTree("src", {
immaculate {
workflows.named("java") {
files.from rootProject.fileTree("src", {
include "**/*.java"
})
}
format 'patches', {
target rootProject.fileTree("patches")
workflows.register("patches") {
files.from(rootProject.fileTree("patches"))

custom 'noImportChanges', { String fileContents ->
if (fileContents.contains('+import') || fileContents.contains('-import')) {
Expand Down Expand Up @@ -152,7 +152,5 @@ spotless {
custom 'jetbrainsNullablePatches', { String fileContents ->
fileContents.replace('@javax.annotation.Nullable', '@org.jetbrains.annotations.Nullable')
}

bumpThisNumberIfACustomStepChanges(5)
}
}
31 changes: 17 additions & 14 deletions buildSrc/src/main/groovy/neoforge.formatting-conventions.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import java.util.regex.Matcher

project.plugins.apply('com.diffplug.spotless')
project.plugins.apply('dev.lukebemish.immaculate')

abstract class GeneratePackageInfos extends DefaultTask {
@InputFiles
Expand Down Expand Up @@ -36,15 +36,19 @@ final generatePackageInfos = tasks.register('generatePackageInfos', GeneratePack
it.files.from fileTree("src/main/java")
}

spotless {
java {
endWithNewline()
indentWithSpaces()
removeUnusedImports()
toggleOffOn()
// Pin version to 4.31 because of a Spotless bug https://github.com/diffplug/spotless/issues/1992
eclipse('4.31').configFile rootProject.file('codeformat/formatter-config.xml')
importOrder()
immaculate {
workflows.register('java') {
java()
trailingNewline()
noTabs()
googleFixImports()
sciwhiz12 marked this conversation as resolved.
Show resolved Hide resolved
toggleOff = 'spotless:off'
toggleOn = 'spotless:on'
eclipse {
version '3.37.0'
sciwhiz12 marked this conversation as resolved.
Show resolved Hide resolved
config = rootProject.file('codeformat/formatter-config.xml')
}


// courtesy of diffplug/spotless#240
// https://github.com/diffplug/spotless/issues/240#issuecomment-385206606
Expand All @@ -63,28 +67,27 @@ spotless {
custom 'jetbrainsNullable', { String fileContents ->
fileContents.replace('javax.annotation.Nullable', 'org.jetbrains.annotations.Nullable')
}
bumpThisNumberIfACustomStepChanges(3)
sciwhiz12 marked this conversation as resolved.
Show resolved Hide resolved
}
}

tasks.named('licenseFormat').configure {
mustRunAfter generatePackageInfos
}
tasks.named('spotlessApply').configure {
tasks.named('immaculateApply').configure {
mustRunAfter generatePackageInfos
mustRunAfter tasks.named('licenseFormat')
}

tasks.register('applyAllFormatting', Task) {
dependsOn generatePackageInfos
dependsOn tasks.named('licenseFormat')
dependsOn tasks.named('spotlessApply')
dependsOn tasks.named('immaculateApply')
group = 'verification'
}

tasks.register('checkFormatting', Task) {
dependsOn 'licenseCheck'
dependsOn 'spotlessCheck'
dependsOn 'immaculateCheck'
group = 'verification'
}

Expand Down
1 change: 0 additions & 1 deletion coremods/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id 'java-library'
id 'com.diffplug.spotless'
id 'net.neoforged.licenser'
id 'neoforge.formatting-conventions'
}
Expand Down
2 changes: 1 addition & 1 deletion docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Contributing to NeoForge
- If possible, write an automated test under the tests project. See [NEOGAMETESTS.md](NEOGAMETESTS.md) for more info.
10. Run `gradlew genPatches` to generate patch-files from the patched sources
11. Run `gradlew applyAllFormatting` to automatically format sources
12. Check correct formatting with `gradlew spotlessCheck`
12. Check correct formatting with `gradlew immaculateCheck`
lukebemish marked this conversation as resolved.
Show resolved Hide resolved
13. Commit & Push
14. Make PR

Expand Down
1 change: 0 additions & 1 deletion testframework/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
id 'java'
id 'maven-publish'
id 'com.diffplug.spotless'
id 'net.neoforged.licenser'
id 'neoforge.formatting-conventions'
}
Expand Down
1 change: 0 additions & 1 deletion tests/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id 'java'
id 'com.diffplug.spotless'
id 'net.neoforged.licenser'
id 'neoforge.formatting-conventions'
}
Expand Down
Loading