代码之家  ›  专栏  ›  技术社区  ›  yossico

Java:具有所有依赖项的瘦jar

  •  1
  • yossico  · 技术社区  · 6 年前

    假设我有以下Java类:

    福。爪哇:

    package my.small.question;
    import my.common.stuff.Bar;
    public class Foo {
    
        private Bar bar;
    
        public Foo(Bar bar) {
            this.bar = bar;
            bar.init();
        }
    }
    

    酒吧爪哇:

    package my.common.stuff;
    import my.algorithms.SpecialSauce;
    public class Bar {
    
        private SpecialSauce yum;
    
        public Bar() {
            this.yum = new SpecialSauce(888) ;
            yum.bake();
        }
    }
    

    如果我想从中创建一个可运行的jar Foo.class 我需要把包裹放进去- Bar.class & SpecialSauce.class 但通用包还有许多其他类( Baz.class , Baq.class 等等……)不用于任何流形式 而且 my.algorithms 这个软件包还有很多其他不需要的算法——你知道了。。。

    我的问题

    如何自动(工具?)我能用它做一个薄罐子吗 福。JAVA 只包含必备类及其依赖项(递归),而不包含其他内容?

    0 回复  |  直到 6 年前