We adhere to the keepachangelog format (starting after version 3.27.0
).
5.6.0
introduced a bug where it was no longer possible to configure a single format twice, e.g. to have twojava{}
blocks in a single file. Fixed by #702.
withinBlocks
allows you to apply rules only to specific sections of files, for example formatting javascript within html, code examples within markdown, and things like that (implements #412 - formatting inception).
- Don't assume that file content passed into Prettier is at least 50 characters (#699).
- Improved JRE parsing to handle strings like
16-loom
(fixes #693).
- New option
toggleOffOn()
which allows the tagsspotless:off
andspotless:on
to protect sections of code from the rest of the formatters (#691).
- When applying license headers for the first time, we are now more lenient about parsing existing years from the header (#690).
googleJavaFormat()
default version is now1.9
on JDK 11+, while continuing to be1.7
on earlier JDKs. This is especially helpful toremoveUnusedImports()
, since it always uses the default version of GJF (fixes #681).
- We did not proactively check to ensure that the Gradle version was modern enough, now we do (fixes #684).
- Added support for eclipse-jdt 4.14.0, 4.15.0 and 4.16.0 (#678).
- Updated default eclipse-jdt from 4.13.0 to 4.16.0 (#678).
- It is now much easier for Spotless to integrate formatters with native executables. (#672)
- Added support for python, specifically black.
- Added support for clang-format for all formats.
- If you executed
gradlew spotlessCheck
multiple times within a single second (hard in practice, easy for a unit test) you could sometimes get an erroneous failure message. Fixed in #671.
ktlint()
is now more robust when parsing version string for version-dependent implementation details, fixes #668.
- Depending on the file system, executing
gradle spotlessApply
might change permission on the changed files from644
to755
; fixes (#656) - When using the
prettier
ortsfmt
steps, if any files were dirty thenspotlessCheck
would fail withjava.net.ConnectException: Connection refused
rather than the proper error message (#651).
- Bump default ktfmt from
0.15
to0.16
, and remove duplicated logic for the--dropbox-style
option (#642)
- Bump default ktfmt from 0.13 to 0.15, and add support for the --dropbox-style option (#641).
This release is exactly the same as 4.5.1
, except:
- it now has plugin id
com.diffplug.spotless
, rather thancom.diffplug.gradle.spotless
(why) - the minimum required Gradle has bumped from
2.14
to5.4
- all deprecated functionality has been removed
-PspotlessModern=true
(introduced in4.3.0
) is now always on
If id 'com.diffplug.gradle.spotless' version '4.5.1'
works without deprecation warnings, then you can upgrade to id 'com.diffplug.spotless' version '5.0.0'
and no changes will be required.
- BREAKING All deprecated functionality has been removed (#640).
- (dev-only)
SpotlessTask
was deleted, andSpotlessTaskModern
was renamed toSpotlessTask
(ditto forSpotlessPlugin
andSpotlessExtension
).
- (dev-only)
- Introduced in earlier versions, but formerly gated behind
-PspotlessModern=true
- We now calculate incremental builds using the new
InputChanges
rather than the deprecatedIncrementalTaskInputs
. (#607) - We now use Gradle's config avoidance APIs. (#617)
- Spotless no longer creates any tasks eagerly. (#622)
- BREAKING The closures inside each format specification are now executed lazily on task configuration. (#618)
- We now calculate incremental builds using the new
String isEager = 'nope'
spotless {
java {
isEager = 'yup'
}
}
println "isEager $isEager"
// 'com.diffplug.gradle.spotless' -> isEager yup
// 'com.diffplug.spotless' -> isEager nope
- Git-native handling of line endings was broken, now fixed (#639).
- Full support for the Gradle buildcache - previously only supported local, now supports remote too. Fixes #566 and #280, via changes in #621 and #571.
prettier
will now autodetect the parser (and formatter) to use based on the filename, unless you override this usingconfig()
orconfigFile()
with the optionparser
orfilepath
. (#620)- (user-invisible) moved the deprecated lib code which was only being used in deprecated parts of
plugin-gradle
into the.libdeprecated
package. (#630) - Added ANTLR4 support (#326).
- LineEndings.GIT_ATTRIBUTES is now a bit more efficient, and paves the way for remote build cache support in Gradle. (#621)
ratchetFrom
now ratchets from the merge base ofHEAD
and the specified branch. This fixes the surprising behavior when a remote branch advanced (#631 fixes #627).
- The default targets for
C/C++
,freshmark
,sql
, andtypescript
now generate a warning, asking the user to specify a target manually. There is no well-established convention for these languages in the gradle ecosystem, and the performance of the default target is far worse than a user-provided one. If you dislike this change, please complain in #634. customLazy
andcustomLazyGroovy
now generate a warning, asking the user to migrate tocustom
. There is no longer a performance advantage tocustomLazy
in the new modern plugin. See #635 for example migrations.- inside the
cpp { }
block, theeclipse
step now generates a warning, asking you to switch toeclipseCdt
. It is the same underlying step, but the new name clears up any confusion with the more common Javaeclipse
. #636
- It is now possible to have multiple language-specific formats. (9a02419)
import com.diffplug.gradle.spotless.KotlinExtension
spotless {
kotlin {
target 'src/**/*.kt'
ktlint()
}
format 'kotlinScript', KotlinExtension, {
target 'src/**/*.kts'
ktfmt()
}
}
- Nodejs-based formatters
prettier
andtsfmt
now use native node instead of the J2V8 approach. (#606)- This removes the dependency to the no-longer-maintained Linux/Windows/macOs variants of J2V8.
- This enables spotless to use the latest
prettier
versions (instead of being stuck at prettier version <=1.19.0
) - Bumped default versions, prettier
1.16.4
->2.0.5
, tslint5.12.1
->6.1.2
- Using
ratchetFrom 'origin/main'
on a bare checkout generated a cryptic error, now generates a clear error. (#608) - Using
ratchetFrom 'nonexistent-reference
generated a cryptic error, now generates a clear error. (#612)
-PspotlessFiles
has been deprecated and will be removed. It is slow and error-prone, especially for win/unix cross-platform, and we have better options available now:- If you are formatting just one file, try the much faster IDE hook
- If you are integrating with git, try the much easier (and faster)
ratchetFrom 'origin/main'
- If neither of these work for you, let us know in this PR.
- If you specify
-PspotlessSetLicenseHeaderYearsFromGitHistory=true
, Spotless will perform an expensive search through git history to determine the oldest and newest commits for each file, and uses that to determine license header years. (#604) - It is now possible for individual formats to set their own
ratchetFrom
value, similar to how formats can have their ownencoding
. (#605). - (spotless devs only) if you specify
-PspotlessModern=true
Spotless will run the in-progress Gradle5.4+
code. ThemodernTest
build task runs our test suite in this way. It will be weeks/months before this is recommended for end-users. (#598)
ratchetFrom
incorrectly marked every file as though it were clean on Windows. (#596)- Improved the warning message for
paddedCell
deprecation, along with many API-invisible fixes and cleanup. (#592)
- If you use
ratchetFrom
andlicenseHeader
, the year in your license header will now be automatically kept up-to-date for changed files. For example, if the current year is 2020: (#593)/** Copyright 2020 */
-> unchanged/** Copyright 1990 */
->/** Copyright 1990-2020 */
/** Copyright 1990-1993 */
->/** Copyright 1990-2020 */
- You can disable this behavior with
licenseHeader(...).updateYearWithLatest(false)
, or you can enable it without usingratchetFrom
by usingupdateYearWithLatest(true)
(not recommended).
ratchetFrom
had a bug (now fixed) such that it reported all files outside the root directory as changed. (#594)
- You can now ratchet a project's style by limiting Spotless only to files which have changed since a given git reference, e.g.
ratchetFrom 'origin/main'
. (#590) - Support for ktfmt in KotlinGradleExtension. (#583)
- Users can now run
spotlessCheck
andspotlessApply
in the same build. (#584) - Fixed intermittent
UnsatisfiedLinkError
in nodejs-based steps. (#586)- Also, a shared library used by the nodejs steps used to be extracted into the user home directory, but now it is extracted into
{rootProject}/build/spotless-nodejs-cache
.
- Also, a shared library used by the nodejs steps used to be extracted into the user home directory, but now it is extracted into
- Fixed intermittent
java.nio.file.DirectoryNotEmptyException
on incremental builds where folders had been removed. (#589) - Starting in
4.0
, it is no longer possible for a project to format files which are not within its project folder (for example,:a
can no longer format files in:b
). We did not explicitly note this in the changelog entry for4.0
, and we gave a very confusing error message if users tried. We now give a more helpful error message, and this breaking change has been retroactively noted in the changelog for4.0.0
. (#588)
- If the encoding was set incorrectly,
spotlessApply
could clobber special characters. Spotless now prevents this, and helps to suggest the correct encoding. (#575)
TLDR: This version improves performance and adds support for the local Gradle Build Cache. You will not need to make any changes in your buildscript. It is a breaking change only for a few users who have built other plugins on top of this one.
- Support for the gradle build cache. (#576)
- The local cache will work great, but the remote cache will always miss until #566 is resolved.
- BREAKING it used to be possible for any project to format files in any other project. For example,
:a
could format files in:b
. It is now only possible to format files within the project directory. It is okay (but not advised) to format files in subprojects, since they are within the project directory. - (Power users only) BREAKING
void SpotlessTask::setCheck()
andsetApply()
have been removed. (#576)- Previously, the
check
andapply
tasks were just marker tasks, and they calledsetCheck
andsetApply
on the "worker" task. Nowcheck
andapply
are real tasks in their own right, so the marker-task kludge is no longer necessary.
- Previously, the
- (Power users only) BREAKING
SpotlessTask FormatExtension::createIndependentTask
has been removed, and replaced withSpotlessApply::createIndependentApplyTask
. (#576) - Improve suggested gradle invocation for running
spotlessApply
. (#578)
-PspotlessIdeHook
which makes the VS Code extension faster and more reliable. SeeIDE_INTEGRATION.md
for more details. (#568)
- 🎉🎉🎉 VS Code Extension thanks to @badsyntax 🎉🎉🎉
- Support for google-java-format 1.8 (requires build to run on Java 11+) (#562)
- Support for ktfmt 0.13 (requires build to run on Java 11+) (#569)
- PaddedCell is now always enabled. It is strictly better than non-padded cell, and there is no performance penalty. See here for detailed explanation. (#561)
- Updated a bunch of dependencies, most notably jgit
5.5.0.201909110433-r
->5.7.0.202003110725-r
. (#564)
- Eclipse-WTP formatter (web tools platform, not java) handles some character encodings incorrectly on OS with non-unicode default file encoding #545. Fixed for Eclipse-WTP formatter Eclipse version 4.13.0 (default version).
- Enable IntelliJ-compatible token
$today.year
for specifying the year in license header files. (#542)
- Eclipse-WTP formatter (web tools platform, not java) could encounter errors in parallel multiproject builds #492. Fixed for Eclipse-WTP formatter Eclipse version 4.13.0 (default version).
- Add tests to
SpecificFilesTest
to fix #529 - If you applied spotless to a subproject, but not to the root project, then on Gradle 6+ you would get the deprecation warning
Using method Project#afterEvaluate(Action) when the project is already evaluated has been deprecated.
This has now been fixed. (#506)
licenseHeader
andlicenseHeaderFile
accidentally returned a package-private config object, which is now public, fixes (#505).
- Added method
FormatExtension.createIndependentTask(String taskName)
which allows creating a Spotless task outside of thecheck
/apply
lifecycle. See javadoc for details. (#500) - Running
clean
andspotlessCheck
during a parallel build could cause exceptions, fixed by (#501). - Fixed Gradle 7 deprecation warnings that started being emitted in Gradle 6. (#503)
- Even if you're using a pre-6.0 version of Gradle, you will probably see small performance and stability improvements. The PR above finally fixed the root problems of (#372).
- Revert the change in console display of errors from 3.26.0 (#485) because of these problems.
- Bugfix: Fix NPE in EclipseXmlFormatterStepImpl (#489)
- Fix project URLs in poms. (#478)
- Fix
ImportSorter
crashing with empty files. (#474)- Fixes #305 StringIndexOutOfBoundsException for empty Groovy file when performing importOrder
- Bugfix: CDT version
4.12.0
now properly uses9.8
, whereas before it used9.7
. (#482) - Updated default eclipse-wtp from 4.12.0 to 4.13.0 (#482).
- Updated default eclipse-groovy from 4.12.0 to 4.13.0 (#482).
- Updated default eclipse-jdt from 4.12.0 to 4.13.0 (#482).
- Updated default eclipse-cdt from 4.12.0 to 4.13.0 (#482).
- Bump default version of KtLint from
0.34.2
to0.35.0
. (#473) - Several improvements to the console display of formatting errors. (#465)
- Spotless no longer breaks configuration avoidance for other tasks (specifically the
check
task and all of its dependees) (#463).- Important change: Formerly, Spotless did not create its tasks until the
afterEvaluate
phase. Spotless now creates them as soon as the plugin is applied, and it creates the format-specific tasks as soon as the formats are defined. There is no performance degradation associated with this change, and it makes configuring Spotless easier.
- Important change: Formerly, Spotless did not create its tasks until the
- Add support for ktlint
0.34+
, and bump default version from0.32.0
to0.34.2
. (#469)
- Update jgit from
5.3.2.201906051522-r
to5.5.0.201909110433-r
. (#445)- Fixes #410 AccessDeniedException in MinGW/GitBash.
- Also fixes occasional hang on NFS due to filesystem timers.
- Eclipse-based formatters used to leave temporary files around (#447). This is now fixed, but only for eclipse 4.12+, no back-port to older Eclipse formatter versions is planned. (#451)
- Fixed a bad but simple bug in
paddedCell()
(#455)- if a formatter was behaving correctly on a given file (was idempotent)
- but the file was not properly formatted
spotlessCheck
would improperly say "all good" even thoughspotlessApply
would properly change them- combined with up-to-date checking, could lead to even more confusing results, (#338)
- Fixed now!
- When you specify
targetExclude()
, spotless no longer silently removesbuild
directories from the exclusion (#457). - Bumped
scalafmt
default version from1.1.0
to2.0.1
, since there are bugs in the old default (#458).
- Fixed
Warning deprecated usage found: Using the incremental task API without declaring any outputs has been deprecated.
that started appearing in Gradle 5.5 (#434).
- Fixes class loading issue with Java 9+ (#426).
- Updated default eclipse-wtp from 4.8.0 to 4.12.0 (#423).
- Updated default eclipse-groovy from 4.10 to 4.12.0 (#423).
- Updated default eclipse-jdt from 4.11.0 to 4.12.0 (#423).
- Updated default eclipse-cdt from 4.11.0 to 4.12.0 (#423).
- KNOWN BUG - accidentally published CDT 9.7 rather than 9.8 - fixed in 3.26.0
- Added new maven coordinates for scalafmt 2.0.0+, maintains backwards compatability (#415)
- Fixes incorrect M2 cache directory path handling of Eclipse based formatters (#401)
- Update jgit from
4.9.0.201710071750-r
to5.3.2.201906051522-r
because gradle project is sometimes broken byapache httpcomponents
in transitive dependency. (#407)
- Updated default ktlint from 0.21.0 to 0.32.0, and Maven coords to com.pinterest (#394)
- Updated default eclipse-cdt from 4.7.3a to 4.11.0 (#390).
- Fixes incorrect plugin and pom metadata in
3.21.0
(#388).
- Updated default eclipse-wtp from 4.7.3b to 4.8.0 (#382).
- Updated default eclipse-groovy from 4.8.1 to 4.10.0 (#382).
- Updated default eclipse-jdt from 4.10.0 to 4.11.0 (#384).
- Fixed intermittent concurrency error while downloading formatter dependencies in multi-project builds (#372).
- Made npm package versions of
prettier
andtsfmt
(and its internal packages) configurable. (#363)- Updated default npm package version of
prettier
from 1.13.4 to 1.16.4 - Updated default npm package version of internally used typescript package from 2.9.2 to 3.3.3 and tslint package from 5.1.0 to 5.12.0 (both used by
tsfmt
)
- Updated default npm package version of
- Updated default eclipse-wtp from 4.7.3a to 4.7.3b (#371).
- Default behavior of XML formatter changed to ignore external URIs (#369).
- WARNING RESOLVED: By default, xml formatter no longer downloads external entities. You can opt-in to resolve external entities by setting resolveExternalURI to true. However, if you do opt-in, be sure that all external entities are referenced over https and not http, or you may be vulnerable to XXE attacks.
WARNING: xml formatter in this version may be vulnerable to XXE attacks, fixed in 3.20.0 (see #358).
- Security fix: Updated groovy, c/c++, and eclipse WTP formatters so that they download their source jars securely using
https
rather thanhttp
(#360). - Updated default eclipse-jdt from 4.9.0 to 4.10.0 (#368)
WARNING: xml formatter in this version may be vulnerable to XXE attacks, fixed in 3.20.0 (see #358).
- Provided eclipse-wtp formatters in generic formatter extension. (#325). This change obsoletes the CSS and XML extensions.
- Improved configuration times for large projects (thanks to @oehme for finding #348).
- Updated default google-java-format from 1.5 to 1.7 (#335).
- Replacing a step no longer triggers early evaluation (#219).
importOrderFile(Object file)
for java and groovy is now lazy (#218).- added
targetExclude(Object...)
which excludes the given files from processing (#353).- This resolves several related issues:
- Our answer for a long time had been "just use
target(Object...)
to fix this" but there is clearly sufficient demand to justifytargetExclude
.
WARNING: xml formatter in this version may be vulnerable to XXE attacks, fixed in 3.20.0 (see #358).
- Updated default eclipse-jdt from 4.7.3a to 4.9.0 (#316). New version addresses enum-tab formatting bug in 4.8 (#314).
- Added
-spotlessFiles
switch to allow targeting specific files (#322)
WARNING: xml formatter in this version may be vulnerable to XXE attacks, fixed in 3.20.0 (see #358).
- Added support for Eclipse's CSS formatter from WTP (#311).
WARNING: xml formatter in this version may be vulnerable to XXE attacks, fixed in 3.20.0 (see #358).
- Added
xml
support (#140) using formatter of Eclipse WTP 3.9.5 (#241). - Added
prettier
andtsfmt
support (#283). - Added C/C++ support using formatter of Eclipse CDT 9.4.3 (#232).
- Updated default groovy-eclipse from 4.8.0 to 4.8.1 (#288). New version is based on Groovy-Eclipse 3.0.0.
- LicenseHeaderStep now wont attempt to add license to
module-info.java
(#272). - Updated JSR305 annotation from 3.0.0 to 3.0.2 (#274)
- Migrated from FindBugs annotations 3.0.0 to SpotBugs annotations 3.1.6 (#274)
- Gradle/Groovy
importOrder
no longer adds semicolons. (#237)
- Updated default eclipse-jdt from 4.7.2 to 4.7.3a (#263). New version fixes a bug preventing Java code formatting within JavaDoc comments (#191).
- Updated default groovy-eclipse from 4.6.3 to 4.8.0 (#244). New version allows to ignore internal formatter errors/warnings.
- Fixed integration with latest versions of scalafmt. (#260)
- Add line and column numbers to ktlint errors. (#251)
- Migrated
plugin-gradle
's tests away fromTaskInternal#execute
to a custom method to help with Gradle 5.0 migration later on. (#208) - Fixed a bug in
LicenseHeaderStep
which caused an exception with some malformed date-aware licenses. (#222) - Updated default ktlint from 0.14.0 to 0.21.0
- Add ability to pass custom options to ktlint. See README for details.
- Added interface
HasBuiltinDelimiterForLicense
to language extensions that have pre-defined licence header delimiter. (#235)
- LicenseHeaderStep now supports customizing the year range separator in copyright notices. (#199)
- Updated default ktlint from 0.6.1 to 0.14.0
- Updated default google-java-format from 1.3 to 1.5
- Updated default eclipse-jdt from 4.7.1 to 4.7.2
- Added a configuration option to
googleJavaFormat
to switch the formatter style (#193)- Use
googleJavaFormat().aosp()
to use AOSP-compliant style (4-space indentation) instead of the default Google Style
- Use
- Bugfix: if the specified target of a spotless task was reduced, Spotless could keep giving warnings until the cache file was deleted.
- LicenseHeader now supports time-aware license headers. (docs, #179, thanks to @baptistemesta)
- Updated default eclipse-jdt version to
4.7.1
from4.6.3
. - All spotless tasks now run before the
clean
task. (#159) - Added
sql
(#166) anddbeaverSql
. (#166)- Many thanks to Baptiste Mesta for porting to Spotless.
- Many thanks to DBeaver and the DBeaver contributors for building the implementation.
- Fix licenseHeader so it works with Kotlin files starting with
@file:...
instead ofpackage ...
(#136).
- Fixed
kotlinGradle
linting Gradle Kotlin DSL files throwingParseException
(#132).
- Changed
importOrder
interface from array to varargs (#125). - The
kotlin
extension was mis-spelled askotin
. - Added
kotlinGradle
method toSpotlessExtension
for linting Gradle Kotlin DSL files with ktlint (#115) - Added dedicated
groovyGradle
for formatting of Gradle files.
- Default eclipse version for
EclipseFormatterStep
bumped to4.6.3
from4.6.1
. (#116) - Default scalafmt version for
ScalaFmtStep
bumped to1.1.0
from0.5.7
(#124)- Also added support for the API change to scalafmt introduced in
0.7.0-RC1
- Also added support for the API change to scalafmt introduced in
- Fixed wildcard targets for
includeFlat
subprojects (#121) - When spotless needs to download a formatter, it now uses the buildscript repositories specified in the root buildscript. (#123, #120)
ImportOrderStep
can now handle multi-line comments and misplaced imports.- Groovy extension now checks for the
groovy
plugin to be applied. - Deprecated the old syntax for the the eclipse formatter:
- New syntax better separates the version from the other configuration options, and is more consistent with the other
eclipseFormatFile('format.xml')
->eclipse().configFile('format.xml')
eclipseFormatFile('4.4.0', 'format.xml')
->eclipse('4.4.0').configFile('format.xml')
- Fixed a bug in
paddedCell()
which causedspotlessCheck
to fail even afterspotlessApply
for cases where a rule is misbehaving and causing a cycle.
- Added support for groovy formatting (huge thanks to Frank Vennemeyer! #94, #89, #88, #85)
- When special-purpose formatters need to be downloaded from maven, they are now resolved using the buildscript repositories rather than the project repositories. (thanks to cal101 #100)
- Update default KtLint from 0.3.1 to 0.6.1 (thanks to @kvnxiao #93).
- This means we no longer look for rules in the typo package
com.gihub.shyiko
, now only incom.github.shyiko
(note thet
).
- This means we no longer look for rules in the typo package
- Added an
enforceCheck
property which allows users to disable addingspotlessCheck
as a dependency ofcheck
(thanks to @gdecaso #95). - Any errors in a step will now fail the build] - 201x-xx-xx previously they were only warned.
- We claimed that we implemented this in 3.1.0, but it was broken. We really fixed it this time.
- Added support for Scala via scalafmt.
- Added support for Kotlin via ktlint.
- Added
FormatExtension::replaceStep
. paddedCell()
is no longer required if a misbehaving rule converges.- Any errors in a step will now fail the build] - 201x-xx-xx previously they were only warned.
- Added
FormatExtension::ignoreErrorForStep
andFormatExtension::ignoreErrorForPath
. - Bumped
google-java-format
to1.3
.
- BREAKING CHANGE:
customReplace
andcustomReplaceRegex
renamed to justreplace
andreplaceRegex
. - BREAKING CHANGE: Plugin portal ID is still
com.diffplug.gradle.spotless
, but maven coordinate has changed tocom.diffplug.spotless:spotless-plugin-gradle
. - HUGE SPEEDUP: Now supports incremental build / up-to-date-checking.
- If you are using
custom
orcustomLazy
, you might want to take a look at this javadoc.
- If you are using
- BREAKING CHANGE:
freshmark
no longer includes all project properties by default. All properties must now be added manually:
spotless {
freshmark {
propertiesFile('gradle.properties')
properties {
it.put('key', 'value')
}
}
}
- Fixed googleJavaFormat so that it can now sort imports and remove unused imports.
- Added an à la carte
removeUnusedImports()
step.
- Java files under the
src/main/groovy
folder are now formatted by default. (Issue #59, PR #60, thanks @ajoberstar).
- If a formatter step throws an
Error
or any of its subclasses, such as theAssertionError
s thrown by JUnit, AssertJ, etc. that error will kill the build (#46)- This allows custom rules like this:
custom 'no swearing', {
if (it.toLowerCase().contains('fubar')) {
throw new AssertionError('No swearing!');
}
}
- When
spotlessCheck
fails, the error message now contains a short diff of what is neccessary to fix the issue (#10, thanks to Jonathan Bluett-Duncan). - Added a padded-cell mode which allows spotless to band-aid over misbehaving rules, and generate error reports for these rules (See #37 for an example).
- Character encoding is now configurable (spotless-global or format-by-format).
- Line endings were previously only spotless-global, they now also support format-by-format.
- Upgraded eclipse formatter from 4.6.0 to 4.6.1
- Added support for google-java-format.
spotless {
java {
googleJavaFormat() // googleJavaFormat('1.1') to specify a specific version
}
}
- Added the method
FormatExtension::customLazyGroovy
which fixes the Groovy closure problem.
spotlessApply
now writes out a file only if it needs to be changed (big performance improvement).- Java import sorting now removes duplicate imports.
- Eclipse formatter now warns if the formatter xml contains multiple profiles.
- Updated eclipse formatter to Eclipse Neon (4.6).
- BREAKING CHANGE: Eclipse formatter now formats javadoc comments.
- You might want to look at the following settings in your
spotless.eclipseformat.xml
:
- You might want to look at the following settings in your
org.eclipse.jdt.core.formatter.join_lines_in_comments=true/false
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true/false
org.eclipse.jdt.core.formatter.comment.format_line_comments=true/false
org.eclipse.jdt.core.formatter.comment.format_block_comments=true/false
The most important breaking change of 2.0 is the new default line ending mode, GIT_ATTRIBUTES
. This line ending mode copies git's behavior exactly. This change should require no intervention from users, and should be significantly easier to adopt for users who are already using .gitattributes
or the core.eol
property.
If you aren't using git, you can still use .gitattributes
files for fine-grained control of line endings. If no git information is found, it behaves the same as PLATFORM_NATIVE (the old default).
Below is the algorithm used by git and spotless to determine the proper line ending for a file. As soon as a step succeeds in finding a line ending, the other steps will not take place.
- If the code is a git repository, look in the
$GIT_DIR/info/attributes
file for theeol
attribute. - Look at the
.gitattributes
in the file's directory, going up the directory tree. - Look at the global
.gitattributes
file, if any. - Look at the
core.eol
property in the git config (looking first at repo-specific, then user-specific, then system-specific). - Use the PLATFORM_NATIVE line ending.
- Upgraded Eclipse formatter to 4.5.2, which fixes 37 bugs compared to the previous 4.5.0.
- If you have been using
custom 'Lambda fix', { it.replace('} )', '})').replace('} ,', '},') }
, you don't need it anymore.
- Spotless no longer clobbers package-info.java, fixes #1.
- Added some infrastructure which allows
FormatterStep
s to peek at the filename if they really need to.
- Bumped the FreshMark dependency to 1.3.0, because it offers improved error reporting.
- Added native support for FreshMark.
- Updated from Eclipse 4.5 M6 to the official Eclipse 4.5 release, which fixes several bugs in the formatter.
- Fixed a bug in the import sorter which made it impossible to deal with "all unmatched type imports".
- Formatting is now relative to the project directory rather than the root directory.
- Improved the logging levels.
- No functional changes, probably not worth the time for an upgrade.
- First version which is available on plugins.gradle.org as well as jcenter.
- Removed some code that was copy-pasted from Durian, and added a Durian dependency.
- Initial release.
- First release, to test out that we can release to jcenter and whatnot.