2016-12-21 5 views
1

私のプロジェクトは、lib-Aおよびサードパーティのlib-B:1.0がmy pomに依存しています。しかし、lib-Alib-b:2.0に依存しています。私の理解から、もしlib-Alib-bの影付きのバージョンを持っていたら、それは問題を解決するでしょうか? 問題はlib-bですが、私が制御できないサードパーティの依存関係です。依存関係を陰にすることは可能ですか?

仕事は私のプロジェクトとlib-Alib-bの異なるバージョンで正しく動作しますので、周囲にありますか?

答えて

2

回避策は、プロジェクトにlib-bを陰影付けすることです。

編集:

新しいプロジェクトを作成しますshaded-ためmy.shaded.example

のpom.xmlになります依存関係としてlib-bshaded-lib-bを言うと、あなたのプロジェクトにあなたはshaded-lib-bのための依存関係を持っているし、今lib-bの名前をパッケージ化必要lib-b

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
     <modelVersion>4.0.0</modelVersion> 

     <groupId>my.shaded.example</groupId> 
     <artifactId>shaded-lib-b</artifactId> 
     <version>1.0</version> 
     <packaging>jar</packaging> 

<dependencies> 
    <dependency> 
     <groupId>com.example</groupId> 
     <artifactId>lib-b</artifactId> 
     <version>1.0</version> 
    </dependency> 
</dependencies> 

<build> 
    <plugins> 
    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-shade-plugin</artifactId> 
     <version>2.4.1</version> 
     <executions> 
     <execution> 
      <phase>package</phase> 
      <goals> 
      <goal>shade</goal> 
      </goals> 
      <configuration> 
      <relocations> 
       <relocation> 
       <pattern>com.example</pattern> 
       <shadedPattern>my.shaded.example</shadedPattern> 
       </relocation> 
      </relocations> 
      <transformers> 
       <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" /> 
      </transformers> 
      </configuration> 
     </execution> 
     </executions> 
    </plugin> 
    </plugins> 
</build> 
</project> 
+0

第三者のライブラリであれば 'lib-b 'をどのようにシェードするのですか? – Glide

+0

がpom.xmlで更新されました – ravthiru

関連する問題