什么是脂肪JAR的gradle替代品? [英] what's the gradle alternative to a fat JAR?

查看:175
本文介绍了什么是脂肪JAR的gradle替代品?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果传递库不是使用 JAR 打包的,任务:

If transitive libs aren't packaged with the JAR task:

By default, jar task in gradle builds an executable jar file from your project source files. It will not contain any transitive libs that are needed for your program.

恰恰相反,Netbeans 包装 JAR 依赖关系或传递库。

To the contrary, Netbeans does package JAR dependencies or transitive libs. Rather than a fat JAR how does gradle include libs?

plugins {
    id 'com.gradle.build-scan' version '1.8' 
    id 'java'
    id 'application'
}


mainClassName = 'net.bounceme.dur.mbaas.json.Main'


buildScan {
    licenseAgreementUrl = 'https://gradle.com/terms-of-service'
    licenseAgree = 'yes'
}

repositories {
    jcenter()
}


jar {
    manifest {
        attributes 'Main-Class': 'net.bounceme.dur.mbaas.json.Main'
    }
}

dependencies {
    //compile fileTree(dir: 'libs', include: ['*.jar'])
    runtime group: 'com.google.firebase', name: 'firebase-admin', version: '5.2.0'
    compile fileTree(dir: 'lib', include: '*.jar') 
}

涉及另一个问题:使用 JAR 任务打包库的方法是什么,它不会导致fat <​​code> JAR

in relation to another question: what's the "way" to package libs with the JAR task which doesn't result in a "fat JAR"?

推荐答案

使用应用程序插件时,应用程序使用的所有库(自带jar或传递库)在打包为应用程序时放入libs文件夹中。那么这些库在启动应用程序时作为类路径在shell或批处理脚本中引用。

When using the application plugin, all libraries used by the application (own jar or transitive libraries) are put in a libs folder when packaged as an app. then these libs are referenced in the shell or batch script as classpath when launching the app.

在gradle中创建fatjar的最简单方法是使用可用的阴影插件通过插件门户。请参阅 https://plugins.gradle.org/plugin/com.github .johnrengelman.plugin-shadow 获取详情

The easiest way to create a fatjar in gradle, is to use the shadow plugin available via the plugin portal. see https://plugins.gradle.org/plugin/com.github.johnrengelman.plugin-shadow for details

这篇关于什么是脂肪JAR的gradle替代品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆