diffplug / diffplug/spotless

[question] Is there a way to skip licenseHeader for legacy files while keeping other formatters active?

オープン
#2,908 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Java
スター
5.7k
フォーク
561
平均マージ
1日 14時間
マージ済み PR(30日)
43

説明

**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

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Issue に示されている Maven Spotless の設定と licenseHeader の区切り文字から始め、一覧にあるフォーマット手順が Java ファイルにどのように適用されるかを確認します。ほかの手順を除外せずに licenseHeader を新規ファイルに限定できるかを判断します。新規ファイルに header が付与され、既存の header が変更されず、ほかのすべての formatter が引き続き実行されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
build-system, tooling
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。