You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGES.md
+4
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,10 @@ This document is intended for Spotless developers.
10
10
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`).
11
11
12
12
## [Unreleased]
13
+
### Added
14
+
*`LicenseHeaderStep` now has an `updateYearWithLatest` parameter which can update copyright headers to today's date. ([#593](https://github.com/diffplug/spotless/pull/593))
15
+
* Parsing of existing years from headers is now more lenient.
16
+
* The `LicenseHeaderStep` constructor is now public, which allows capturing its state lazily, which is helpful for setting defaults based on `ratchetFrom`.
Copy file name to clipboardExpand all lines: plugin-gradle/CHANGES.md
+6
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,12 @@
3
3
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `3.27.0`).
4
4
5
5
## [Unreleased]
6
+
### Added
7
+
* If you use `ratchetFrom` and `licenseHeader`, 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](https://github.com/diffplug/spotless/pull/593))
* You can disable this behavior with `licenseHeader(...).updateYearWithLatest(false)`, or you can enable it without using `ratchetFrom` by using `updateYearWithLatest(true)` (not recommended).
6
12
### Fixed
7
13
*`ratchetFrom` had a bug (now fixed) such that it reported all files outside the root directory as changed. ([#594](https://github.com/diffplug/spotless/pull/594))
Copy file name to clipboardExpand all lines: plugin-gradle/README.md
+6-23
Original file line number
Diff line number
Diff line change
@@ -543,32 +543,15 @@ to true.
543
543
544
544
## License header options
545
545
546
-
If the license header (specified with `licenseHeader` or `licenseHeaderFile`) contains `$YEAR` or `$today.year`, then that token will be replaced with the current 4-digit year. For example, if Spotless is launched in 2017, then `/* Licensed under Apache-2.0 $YEAR. */` will produce `/* Licensed under Apache-2.0 2017. */`
546
+
If the license header (specified with `licenseHeader` or `licenseHeaderFile`) contains `$YEAR` or `$today.year`, then that token will be replaced with the current 4-digit year. For example, if Spotless is launched in 2020, then `/* Licensed under Apache-2.0 $YEAR. */` will produce `/* Licensed under Apache-2.0 2020. */`
547
547
548
-
The `licenseHeader` and `licenseHeaderFile` steps will generate license headers with automatic years according to the following rules:
549
-
* A generated license header will be updated with the current year when
550
-
* the generated license header is missing
551
-
* the generated license header is not formatted correctly
552
-
* A generated license header will _not_ be updated when
553
-
* a single year is already present, e.g.
554
-
`/* Licensed under Apache-2.0 1990. */`
555
-
* a year range is already present, e.g.
556
-
`/* Licensed under Apache-2.0 1990-2003. */`
557
-
* the `$YEAR` token is otherwise missing
548
+
Once a file's license header has a valid year, whether it is a year (`2020`) or a year range (`2017-2020`), it will not be changed. If you want the date to be updated when it changes, enable the [`ratchetFrom` functionality](#ratchet), and the year will be automatically set to today's year according to the following table (assuming the current year is 2020):
558
549
559
-
The separator for the year range defaults to the hyphen character, e.g `1990-2003`, but can be customized with the `yearSeparator` property.
550
+
* No license header -> `2020`
551
+
*`2017` -> `2017-2020`
552
+
*`2017-2019` -> `2017-2020`
560
553
561
-
For instance, the following configuration treats `1990, 2003` as a valid year range.
562
-
563
-
```gradle
564
-
spotless {
565
-
java {
566
-
licenseHeader('Licensed under Apache-2.0 $YEAR').yearSeparator(', ')
567
-
}
568
-
}
569
-
```
570
-
571
-
To update the copyright notice only for changed files, use the [`ratchetFrom` functionality](#ratchet).
554
+
See the [javadoc](https://javadoc.io/static/com.diffplug.spotless/spotless-plugin-gradle/4.1.0/com/diffplug/gradle/spotless/FormatExtension.LicenseHeaderConfig.html) for a complete listing of options.
0 commit comments