私は、最終的に実行可能なjarファイルを作成するJava Mavenプロジェクトに取り組んできました。最初は問題はありませんでしたが、依存関係も jar にコピーすることにしました。
次の (非常に役立つ) スタック オーバーフローの質問を見つけ、回答にある指示に従いました (自分のメイン クラスとターゲット バージョンを置き換えます): Maven で実行可能 jar をビルドする際の問題
これはうまく機能しましたが、2 つの jar ファイル (ldap-daemon-0.0.1-SNAPSHOT.jar と ldap-daemon-0.0.1-SNAPSHOT-jar-with-dependencies.jar) ができてしまいました。私はこれで問題ありませんが、私が知る限り、後で maven-dependency-plugin のコピー機能を使用して依存関係のある jar のコピーを実際に取得することはできません。
したがって、私が知りたいのは、次のいずれかを達成する方法です。
- メインのビルド アーティファクトである ldap-daemon-0.0.1-SNAPSHOT.jar に依存関係を含めます。
- maven-dependency-plugin を使用して、2 番目のビルド アーティファクト (ldap-daemon-0.0.1-SNAPSHOT-jar-with-dependencies.jar) をコピーします。
ldap-daemon のプラグイン構成は次のとおりです (パッケージ構成は「jar」です)。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.acuitus.ldapd.LDAPDaemonImp</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>6</source>
<target>6</target>
</configuration>
</plugin>
そして、結果のjarをダウンストリームプロジェクトのフォルダーにコピーしようとする私のプラグイン構成は次のとおりです。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.acuitus</groupId>
<artifactId>ldap-daemon</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/classes/www-export</outputDirectory>
<destFileName>ldap-daemon.jar</destFileName>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/wars</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
どんな援助も大歓迎です。御時間ありがとうございます!