首页 > 解决方案 > 需要了解一些 `ant fat/shaded` jar 概念

问题描述

我正在尝试创建一个包含其他罐子的runtime dependencies罐子。

我使用了以下脚本

<jar destfile="MyApplication.jar">
  <zipgroupfileset dir="lib" includes="*.jar" /> 
  <!-- other options -->
  <manifest>
    <attribute name="Main-Class" value="Main.MainClass" />
  </manifest>
</jar>

当我说其他runtime dependencies罐子时,我在想那些会作为一个完整的罐子添加到里面MyApplication.jar

像下面的东西。

MyApplication.jar

 --`lib/depedent1.jar`
 --`lib/depedent2.jar`
 -- my.class
 -- myAnother.class

但是,我发现MyApplication.jar实际上已经提取了lib/depedent1.jar/lib/depedent2.jar

如果内容被提取,我没有任何问题,但只是好奇不可能创建一个里面有真正区分的依赖罐子的罐子吗?

标签: javabuildantfatjar

解决方案


基本上,Shaded/fat jar 在它的父 jar 中提取依赖项的内容

MyApplication.jar

-- com.lib1.corp.SomeClass.class
-- com.lib2.corp.AnotherClass.class
-- com.my.corp.myFirst.class
-- com.my.corp.myAnother.class

推荐阅读