Java/Maven ビルドに著作権表示を含めることを強制する標準的な方法はありますか? 製品自体はコピーで書かれており、誰かが私のソースを持っている場合、私はもっと大きな問題を抱えているので、それは必要ではないことを認識しています. .
著作権のチェックを処理するツールはありますか?
Java/Maven ビルドに著作権表示を含めることを強制する標準的な方法はありますか? 製品自体はコピーで書かれており、誰かが私のソースを持っている場合、私はもっと大きな問題を抱えているので、それは必要ではないことを認識しています. .
著作権のチェックを処理するツールはありますか?
はい、Checkstyle (およびmaven-checkstyle-plugin ) はそれを実行できます。すべてのソース ファイルにライセンス ヘッダーが含まれていることを確認できます。そのヘッダーをテキスト ファイルに入れ、 を使用しheaderLocation
てそれをポイントします (デフォルトでは を使用しますLICENSE.txt
)。
checkstyle.license
著作権表示に使用したいとしましょう。マルチモジュール ビルドの標準的なアプローチは、Checkstyle リソースをホストするための専用モジュールを作成することです (「マルチモジュール構成」を参照)。
whizbang
|-- pom.xml
|-- build-tools
| |-- src
| | `-- main
| | `-- resources
| | `-- whizbang
| | |-- checkstyle.xml
| | `-- checkstyle.license
| `-- pom.xml
|-- core
|-- gui
|-- jmx
`-- src
次に、最上位に Checkstyle構成pom.xml
を含めます。
<pluginManagement>
<plugins>
<!-- Apply checkstyle rules and fail the build in case of errors. The
checkstyle config files are taken from the build-tools JAR module.-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<!-- Lock down plugin version for build reproducibility -->
<version>2.4</version>
<dependencies>
<dependency>
<groupId>com.example.whizbang</groupId>
<artifactId>build-tools</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<configuration>
<consoleOutput>true</consoleOutput>
<configLocation>whizbang/checkstyle.xml</configLocation>
<headerLocation>whizbang/checkstyle.license</headerLocation>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
</pluginManagement>
この設定により、著作権ヘッダーがソース ファイルに存在することが保証されます (他の Checkstyle ルールが適用されますが、これは別の話です)。ニーズに合わせて調整してください。