gradle - 如何使用 lib 目录和其他 jar 构建一个 jar? [英] gradle - how do I build a jar with a lib dir with other jars in it?

查看:35
本文介绍了gradle - 如何使用 lib 目录和其他 jar 构建一个 jar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 gradle 中 - 如何将 jar 嵌入到 lib 的构建输出 jar 中目录(特别是 lib/enttoolkit.jar 和 lib/mail.jar)?

In gradle - how can I embed jars inside my build output jar in the lib directory (specifially the lib/enttoolkit.jar and lib/mail.jar)?

推荐答案

如果您在项目中的目录中拥有所有 jar(我们称之为 libs),您只需要:

If you have all the jars inside a directory (lets call it libs) in your project, you only need this:

jar {
    into('lib') {
        from 'libs'
    }
}

我想这些 jar 更有可能是某种依赖关系.那么你可以这样做:

I guess it is more likely that these jars are dependencies of some sort. Then you could do it like this:

configurations {
    // configuration that holds jars to copy into lib
    extraLibs
}
dependencies {
    extraLibs 'org.something:something-dep1:version'
    extraLibs 'org.something:something-dep2:version'
}

jar {
    into('lib') {
        from configurations.extraLibs
    }
}

这篇关于gradle - 如何使用 lib 目录和其他 jar 构建一个 jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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