java-mavenビルドのすべてのソースファイルに著作権表示が付いていることを確認するにはどうすればよいですか?

StackOverflow https://stackoverflow.com/questions/1821742

質問

java / mavenビルドに著作権表示を含めることを強制する標準的な方法はありますか?製品自体はコピーで書かれているので、それは必要ではないことを認識しています。誰かが私のソースを持っている場合、私はもっと大きな問題を抱えていますが、チェックするよう求められており、checkstyle、PMDまたは他の何かがこれを自動的に処理したかどうか疑問に思っていました。

著作権のチェックを処理するツールはありますか?

役に立ちましたか?

解決

はい、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ルールを適用しますが、これは別の話です)。ニーズに合わせて調整します。

他のヒント

見つけたばかり http://code.google.com/p/maven-license-plugin/ 合理的すぎると思われる

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top