[question] Is there a way to skip licenseHeader for legacy files while keeping other formatters active?
- Vorherrschende Sprache
- Java
- Sterne
- 5.6k
- Forks
- 559
- Ø Merge
- 1 T. 14 Std.
- Gemergte PRs (30 T.)
- 43
Beschreibung
**Environment:**
- Java
- Spotless Maven Plugin
**Background**
Our project contains both new and legacy Java files:
- **New files** contain only the new license header:
```java
// New License Header
```
- **Legacy files** contain multiple historical license headers, for example:
```java
// New License Header
// Old License Header
```
**Problem**
When configuring Spotless with:
```xml
${project.basedir}/tools/spotless/license-header.txt
package |import |module
```
Spotless replaces **all** license headers in **all files**, including legacy files that should keep their original headers.
This causes two issues:
1. Legacy files lose their historical license information
2. 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
Beitragsleitfaden
Rechercherichtung
Beginnen Sie mit der im Issue gezeigten Maven Spotless-Konfiguration und dem licenseHeader-Trennzeichen und prüfen Sie anschließend, wie die aufgeführten Formatierungsschritte auf Java-Dateien angewendet werden. Ermitteln Sie, ob licenseHeader auf neue Dateien beschränkt werden kann, ohne die anderen Schritte auszuschließen. Als erledigt gilt die Aufgabe, wenn neue Dateien den Header erhalten, bestehende Header unverändert bleiben und alle anderen Formatter weiterhin ausgeführt werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java
- Bereich
- build-system, tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100