1

親モジュールに、コンパイルに必要なさまざまな jar を含む lib ディレクトリがあるが、最終製品には含まれていない Maven プロジェクトがあります。子モジュールをビルドしようとすると失敗します。「次の成果物を解決できませんでした」と表示され、最終的に「C:\path\to\project\modules\module_name\lib\local_dependency.jar に成果物 local_dependency が見つかりませんでした」と表示されます。

子モジュールは、親が使用するライブラリに依存していませんが、それでもそれらを含める必要があります。これを防ぐために設定する必要があるオプションはありますか?

親 Pom スニペット:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <currentVersion>1.0.0</currentVersion>
</properties>

<groupId>com.project</groupId>
<artifactId>project_artifact</artifactId>
<packaging>pom</packaging>
<version>${currentVersion}</version>

<modules>
    <module>modules/module_name</module>
</modules>

<dependencies>
    <dependency>
        <groupId>group.id</groupId>
        <artifactId>local_dependency</artifactId>
        <version>1.0</version>
        <systemPath>${basedir}/lib/local_dependency.jar</systemPath>
        <scope>system</scope>
        <optional>true</optional>
    </dependency>
</dependencies>

子ポン スニペット:

<parent>
    <groupId>com.project</groupId>
    <artifactId>project_artifact</artifactId>
    <version>${currentVersion}</version>
    <relativePath>../../</relativePath>
</parent>

<dependencies>
    <dependency>
        <groupId>net.some.dependency</groupId>
        <artifactId>artifact_name</artifactId>
        <version>1.0.0</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>com.project</groupId> <!-- The child depends on the parent for the parent's API-->
        <artifactId>project_artifact</artifactId>
        <version>${currentVersion}</version>
        <type>jar</type>
    </depdencency>
</dependencies>

したがって、これから、子 pom は project_base/modules/module_name/lib/local_dependency.jar から group.id:local_dependency を含めようとしますが、存在せず、存在する必要もありません。

4

2 に答える 2

3

依存関係の宣言で、特定の推移的な依存関係を除外できます。あなたの場合、子 pom の親への依存関係を次のように変更すると、ビルドが機能するはずです。

<dependency>
    <groupId>com.project</groupId> <!-- The child depends on the parent for the parent's API-->
    <artifactId>project_artifact</artifactId>
    <version>${currentVersion}</version>
    <type>jar</type>
    <exclusions>
        <exclusion>
            <groupId>group.id</groupId>
            <artifactId>local_dependency</artifactId>
        </exclusion>
    </exclusions>
</dependency>
于 2013-10-05T16:34:55.277 に答える