「jar-with-dependencies」でmaven-assembly-pluginを使用して、jarをパッケージ化します。log-back.xml を持つ 2 つの依存関係アーティファクトがあります。2 番目のアーティファクトは、最初のアーティファクトに依存しています。2 番目のアーティファクトの log-back.xml を最終的な jar に入れたいのですが、常に最初のアーティファクトの log-back.xml が含まれています。では、どうすればこれを制御できますか?
ありがとう
「jar-with-dependencies」でmaven-assembly-pluginを使用して、jarをパッケージ化します。log-back.xml を持つ 2 つの依存関係アーティファクトがあります。2 番目のアーティファクトは、最初のアーティファクトに依存しています。2 番目のアーティファクトの log-back.xml を最終的な jar に入れたいのですが、常に最初のアーティファクトの log-back.xml が含まれています。では、どうすればこれを制御できますか?
ありがとう
これを実現するには、 unpackOptionsを使用できます。次のようなことを試してください。
<assembly>
...
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<includes>
<include>${groupId}:${artifact.whose.logback.is.to.be.excluded} </include>
</includes>
<unpack>true</unpack>
<unpackOptions>
<excludes>
<exclude>**/logback.xml</exclude>
</excludes>
</unpackOptions>
</dependencySet>
<dependencySet>
<outputDirectory>/</outputDirectory>
<excludes>
<exclude>${groupId}:${artifact.whose.logback.is.to.be.excluded}</exclude>
</excludes>
<unpack>true</unpack>
</dependencySet>
</dependencySets>
</assembly>
最初のアーティファクトはあなた自身のプロジェクトのモジュールですか? その場合、pom.xml のリソース セクションで log-back.xml を除外できます。
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>log-back.xml</exclude>
</excludes>
</resource>
...
</resources>
ただし、これは、このモジュールが全体的な jar の範囲外に構築されたときに、log-back.xml 自体を必要としない場合にのみ機能します。