Environment:
- Java
- Spotless Maven Plugin
Background
Our project contains both new and legacy Java files:
- New files contain only the new license header:
- Legacy files contain multiple historical license headers, for example:
// New License Header
// Old License Header
Problem
When configuring Spotless with:
<licenseHeader>
<file>${project.basedir}/tools/spotless/license-header.txt</file>
<delimiter>package |import |module </delimiter>
</licenseHeader>
Spotless replaces all license headers in all files, including legacy files that should keep their original headers.
This causes two issues:
- Legacy files lose their historical license information
- If I exclude legacy files from
licenseHeader, then other formatters (googleJavaFormat, eclipse, prettier, idea, tableTestFormatter, importOrder) will also stop applying to them
Expected Behavior
- New files should receive the new license header
- Legacy files should keep their existing headers, but still be formatted by other Spotless steps
Question
Is there a recommended way to configure Spotless so that:
licenseHeader applies only to new files
- Other formatters still apply to all files
- Legacy files are not modified by the license step
Environment:
Background
Our project contains both new and legacy Java files:
// New License HeaderProblem
When configuring Spotless with:
Spotless replaces all license headers in all files, including legacy files that should keep their original headers.
This causes two issues:
licenseHeader, then other formatters (googleJavaFormat,eclipse,prettier,idea,tableTestFormatter,importOrder) will also stop applying to themExpected Behavior
Question
Is there a recommended way to configure Spotless so that:
licenseHeaderapplies only to new files