Spotless: year format string not working as expected

Created on 8 Jan 2019  路  2Comments  路  Source: diffplug/spotless

I have the following spotless configuration:

spotless {
        scala {
            scalafmt()
            licenseHeader('// Copyright (C) $YEAR ', 'package ')
        }
    }

Version is:

plugins {
  id "com.diffplug.gradle.spotless" version "3.16.0"
}

however, the generated output is still 2018 and 2019. What is causing this mixup? how can I fix it?

question

Most helpful comment

For existing well-formed license headers the year is not changed:
https://github.com/diffplug/spotless/tree/master/plugin-gradle#license-header-options
so it's possible to end up with multiple years in the same code base.
If you want always a specific year you can set it in the license (e.g. hardcode it or get the current year programmatically) instead of using the year token.

All 2 comments

For existing well-formed license headers the year is not changed:
https://github.com/diffplug/spotless/tree/master/plugin-gradle#license-header-options
so it's possible to end up with multiple years in the same code base.
If you want always a specific year you can set it in the license (e.g. hardcode it or get the current year programmatically) instead of using the year token.

You should checkout our new ratchetFrom 'origin/master' feature.

Was this page helpful?
0 / 5 - 0 ratings