mirror of
https://github.com/neoforged/NeoForge
synced 2026-08-20 08:23:13 -04:00
Switch out Spotless for Immaculate, an alternative formatting plugin (#1530)
This commit is contained in:
parent
304415bb17
commit
df48b4d653
6 changed files with 24 additions and 26 deletions
14
build.gradle
14
build.gradle
|
|
@ -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'
|
||||
|
|
@ -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')) {
|
||||
|
|
@ -152,7 +152,5 @@ spotless {
|
|||
custom 'jetbrainsNullablePatches', { String fileContents ->
|
||||
fileContents.replace('@javax.annotation.Nullable', '@org.jetbrains.annotations.Nullable')
|
||||
}
|
||||
|
||||
bumpThisNumberIfACustomStepChanges(5)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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()
|
||||
toggleOff = 'spotless:off'
|
||||
toggleOn = 'spotless:on'
|
||||
eclipse {
|
||||
version '3.37.0'
|
||||
config = rootProject.file('codeformat/formatter-config.xml')
|
||||
}
|
||||
|
||||
|
||||
// courtesy of diffplug/spotless#240
|
||||
// https://github.com/diffplug/spotless/issues/240#issuecomment-385206606
|
||||
|
|
@ -63,14 +67,13 @@ spotless {
|
|||
custom 'jetbrainsNullable', { String fileContents ->
|
||||
fileContents.replace('javax.annotation.Nullable', 'org.jetbrains.annotations.Nullable')
|
||||
}
|
||||
bumpThisNumberIfACustomStepChanges(3)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named('licenseFormat').configure {
|
||||
mustRunAfter generatePackageInfos
|
||||
}
|
||||
tasks.named('spotlessApply').configure {
|
||||
tasks.named('immaculateApply').configure {
|
||||
mustRunAfter generatePackageInfos
|
||||
mustRunAfter tasks.named('licenseFormat')
|
||||
}
|
||||
|
|
@ -78,13 +81,13 @@ tasks.named('spotlessApply').configure {
|
|||
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'
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
plugins {
|
||||
id 'java-library'
|
||||
id 'com.diffplug.spotless'
|
||||
id 'net.neoforged.licenser'
|
||||
id 'neoforge.formatting-conventions'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 checkFormatting`
|
||||
13. Commit & Push
|
||||
14. Make PR
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
plugins {
|
||||
id 'java'
|
||||
id 'maven-publish'
|
||||
id 'com.diffplug.spotless'
|
||||
id 'net.neoforged.licenser'
|
||||
id 'neoforge.formatting-conventions'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
plugins {
|
||||
id 'java'
|
||||
id 'com.diffplug.spotless'
|
||||
id 'net.neoforged.licenser'
|
||||
id 'neoforge.formatting-conventions'
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue