2

すべてのライセンスを管理するライセンス プラグインをセットアップしようとしているマルチモジュールプロジェクトがあります。プロジェクトのセットアップは次のとおりです。

─── transfuse-project
    ├── examples
    │   ├── helloAndroid
    │   │   ├── pom.xml
    │   │   ├── ...
    │   ├── integrationTest
    │   │   ├── pom.xml
    │   │   ├── ...
    │   ├── pom.xml
    │   └── ...
    ├── transfuse
    │   ├── pom.xml
    │   ├── ...
    ├── transfuse-api
    │   ├── pom.xml
    │   ├── ...
    ├── NOTICE
    └── pom.xml

各 pom.xml は、transfuse プロジェクトの pom.xml から継承されます。プロジェクト pom.xml で、関連するファイルに NOTICE を適用するライセンス プラグインをセットアップしました。

        <plugin>
            <groupId>com.mycila.maven-license-plugin</groupId>
            <artifactId>maven-license-plugin</artifactId>
            <version>1.9.0</version>
            <configuration>
                <header>NOTICE</header>
                <includes>
                    <include>**/*.java</include>
                    <include>**/*.xml</include>
                </includes>
                <excludes>
                    <exclude>**/.*/**</exclude>
                    <exclude>target/**</exclude>
                    <exclude>**/AndroidManifest.xml</exclude>
                </excludes>
                <properties>
                    <year>2013</year>
                    <name>John Ericksen</name>
                </properties>
                <useDefaultExcludes>true</useDefaultExcludes>
                <strictCheck>true</strictCheck>
            </configuration>
            <executions>
                <execution>
                    <id>check-headers</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>check</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

この構成は、ルート (transfuse-project) から直接ビルドすると機能します。この問題は、integrationTest のサンプルまたは API を直接ビルドすると発生します。Maven は、プロジェクト ルートで提供した NOTICE ファイルを見つけることができません。

[ERROR] Failed to execute goal com.mycila.maven-license-plugin:maven-license-plugin:1.9.0:check (check-headers) on project transfuse-api: Some files do not have the expected license header -> [Help 1]

さらに悪いことに、別の依存関係の NOTICE ファイルが見つかります。mvn license:formatサブモジュールで実行すると、モジュールのすべてのヘッダーが依存関係の NOTICE ファイルに置き換えられます。

各サブモジュール内に NOTICE ファイルを追加してこの問題を修正し、各サブモジュール pom を独自のライセンス プラグインで構成できると思いますが、可能であればその重複を避けたいと思います。私のプロジェクトのセットアップで動作する構成またはセットアップはありますか?

4

3 に答える 3

2

を使用して絶対パスを使用してみてください

<header>${basedir}/NOTICE</header>

これが機能しない場合は、親モジュールの basedir にプロパティを設定して使用してみてください。

<header>${main.basedir}/NOTICE</header>

3 番目のオプションは、実行時にプロパティを設定することです。

mvn clean install -Dmain.basedir=path/to/main/basedir

編集:

OK、もう 1 つのオプションは、ライセンス プラグインの前にmaven-dependency-pluginを実行することです。ただし、親が NOTICE を添付していることを確認する必要があります ( maven-assembly-plugin plugin を使用)

<plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-dependency-plugin</artifactId>
         <version>2.6</version>
         <executions>
           <execution>
             <id>unpack-parent</id>
             <phase>verify</phase>
             <goals>
               <goal>unpack</goal>
             </goals>
             <configuration>
               <artifactItems>
                 <artifactItem>
                   <groupId>parent</groupId>
                   <artifactId>parent</artifactId>
                   <version>parent</version>
                   <type>pom</type>
                   <overWrite>false</overWrite>
                   <outputDirectory>${project.build.directory}/license</outputDirectory>
                   <includes>NOTICE</includes>
                 </artifactItem>
               </artifactItems>
             </configuration>
           </execution>
         </executions>
       </plugin>

header変更は次のとおりです。

<header>${project.build.directory}/license/NOTICE</header>

編集2:

find-maven-plugin に出会いました。私はこれがうまくいくと思います:

<plugin>
    <groupId>com.github.goldin</groupId>
    <artifactId>find-maven-plugin</artifactId>
    <version>0.2.5</version>
    <executions>
        <execution>
            <id>find-notice-file</id>
            <goals>
                <goal>find</goal>
            </goals>
            <phase>validate</phase>
            <configuration>
                <propertyName>notice.file</propertyName>
                <file>NOTICE</file>
            </configuration>
        </execution>
    </executions>
</plugin>
于 2013-01-13T18:29:05.427 に答える
0

この 2 つの構成プロパティ セットで例を試してください。

<plugin>
  <groupId>com.mycila</groupId>
  <artifactId>license-maven-plugin</artifactId>
  <version>2.7</version>
  <configuration>
    <header>/NOTICE</header>
    <aggregate>true</aggregate>
  </configuration>
</plugin>
于 2015-01-15T20:01:39.437 に答える