2016-05-24 7 views
-1

2つのモジュールがあるところで 'Mavenモジュール'プロジェクトを構築していました。Mavenマニフェストファイルが完全なJARパスを除外

  • モジュールA
  • モジュールB

モジュールBは、モジュールAを使用しています一つであり、私はモジュールBメイン・クラスを実行すると、それは完璧に実行されます。しかし、JARをビルドしようとすると、JARにはManifestファイルに無効なクラスパス・ジャーが含まれています。私は 'クラスパス' に追加のパスがある見てのとおり、マニフェストファイル

Manifest-Version: 1.0 
Archiver-Version: Plexus Archiver 
Built-By: Someone 
Class-Path: lib/com/example/a/1.0.0/module-a-1.0.0.jar lib/com/1stl 
eg/jnativehook/2.0.2/jnativehook-2.0.2.jar lib/org/json/json/20160212 
/json-20160212.jar lib/org/glassfish/jersey/core/jersey-client/2.22.2 
/jersey-client-2.22.2.jar lib/javax/ws/rs/javax.ws.rs-api/2.0.1/javax 
.ws.rs-api-2.0.1.jar lib/org/glassfish/jersey/core/jersey-common/2.22....... 

を生成

モジュールB POM

<build> 
    <plugins> 
     <plugin> 
     <!-- Build an executable JAR --> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-jar-plugin</artifactId> 
     <version>3.0.0</version> 
     <configuration> 
      <archive> 
       <manifest> 
        <addClasspath>true</addClasspath> 
        <classpathPrefix>lib/</classpathPrefix> 
        <mainClass>com.example.main.Main</mainClass> 
       </manifest> 
      </archive> 
     </configuration> 
     </plugin> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-dependency-plugin</artifactId> 
     <version>2.10</version> 
     <executions> 
      <execution> 
       <phase>package</phase> 
       <goals> 
        <goal>copy-dependencies</goal> 
       </goals> 
       <configuration> 
        <outputDirectory>${project.build.directory}/lib</outputDirectory> 
       </configuration> 
      </execution> 
     </executions> 
     </plugin> 
    </plugins> 
</build> 

。 jar名だけを含むようにこれを変更するには?

私は私はあなたを編集したくない場合は、次のプラグインを追加するソリューションは、単一のJAR

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-assembly-plugin</artifactId> 
    <version>2.4</version> 
    <configuration> 
     <archive> 
     <manifest> 
      <mainClass>com.example.main.Main</mainClass> 
     </manifest> 
     </archive> 
     <descriptorRefs> 
     <descriptorRef>jar-with-dependencies</descriptorRef> 
     </descriptorRefs> 
    </configuration> 
    <executions> 
     <execution> 
     <id>make-assembly</id> 
     <phase>package</phase> 
     <goals> 
      <goal>single</goal> 
     </goals> 
     </execution> 
    </executions> 
</plugin> 

答えて

0

「をインストールMVNクリーン」を実行していますpom.xmlの場合、mvn package assembly:single と同じことができます。このコマンドは、すべての依存関係を.jarファイルにコピーします。

0

に必要なJARファイルが含まれてい

-1

あなたの問題は、あなたの親POMのうち、次のものが<classpathLayoutType>repository</classpathLayoutType>に設定されていることです。それを削除するか、simpleで上書きしてください。

+0

興味深いことに、コメントなしのdownvote。憎しみ? –

関連する問題