3

私のプロジェクトの pom.xml には、次の依存関係があります。

<dependency>
    <groupId>com.my.library</groupId>
    <artifactId>MyLib</artifactId>
    <version>1.0</version>
    <type>jar</type>
</dependency>

<dependency>
  ...
</dependency>

com.my.library:MyLib上記の依存関係のクラスを含むプロジェクトの最終ビルド jar を作成したいので、次のようにmaven-shade-pluginを使用しました。

<plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-shade-plugin</artifactId>
     <version>2.3</version>
     <executions>
        <execution>
           <phase>package</phase>
           <goals>
              <goal>shade</goal>
           </goals>
           <configuration>  
              <filters>
                 <filter>
                   <artifact>com.my.library:MyLib</artifact>
                   <includes>
                       <include>com/my/library/**</include>
                   </includes>
                 </filter>
              </filters>
           </configuration>
        </execution>
     </executions>
</plugin>

次に、 を実行するmvn clean installと、プロジェクトが正常にビルドされました。

しかし、ディレクトリの下のMyProject.jartarget/の内容を確認すると、依存関係からのクラスが含まれていませんcom.my.library:MyLib。なぜですか? maven-shade-plugin のどこが間違っていますか?

4

2 に答える 2

1

以下を定義し<artifactSet>ます。

<artifactSet>
    <includes>
        <include>com.my.library:MyLib</include>
    </includes>
</artifactSet>

<artifact/>から を削除してみてください<filters/>。これでうまくいくはずです。

于 2014-07-23T11:31:25.887 に答える
0

パターンをに変更

<includes>
    <include>com/my/library/**.class</include>
</includes>
于 2014-07-22T16:55:17.997 に答える