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

Add spotless to the MDK #52

Open
wants to merge 1 commit into
base: 1.21
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 24 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
id 'idea'
id 'maven-publish'
id 'net.neoforged.gradle.userdev' version '7.0.109'
id 'com.diffplug.spotless' version '6.22.0'
}

version = mod_version
Expand Down Expand Up @@ -162,3 +163,26 @@ idea {
downloadJavadoc = true
}
}

// Spotless Java is an automated code formatter https://github.com/diffplug/spotless
// It can be used to enforce a consistent style across the entire project by running the spotlessApply task
spotless {
java {
// Format all java files in the src/ directory
target rootProject.fileTree("src", {
include "**/*.java"
})
// Force files to end with a newline (prevents diff changes on the last line when new content is added)
endWithNewline()
// Forces indentation to be done with spaces due to inconsistent tab sizes
indentWithSpaces()
// Removes unused imports
removeUnusedImports()
// Enables "skip-formatting" blocks - https://github.com/diffplug/spotless/blob/main/plugin-gradle/README.md#spotlessoff-and-spotlesson
toggleOffOn()
// Read the eclipse formatter XML at formatter-config.xml
eclipse().configFile rootProject.file('formatter-config.xml')
// Use the default import order provided by spotless. https://github.com/diffplug/spotless/blob/main/plugin-gradle/README.md#java
importOrder()
}
}
Loading
Loading