将项目依赖项复制到文件夹 [英] Copy project dependencies to folder

查看:83
本文介绍了将项目依赖项复制到文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Gradle的新手.我正在尝试将项目中的所有依赖项都复制到文件夹build/lib中.可以这样做吗?

I new to Gradle. I'm trying to have all dependencies from my project copied to folder build/lib. Is it possible to do that?

当前,我通过分发插件在构建/分发中有一个.zip和一个.tar.但是,我只想拥有未压缩的库.

Currently, I have a .zip and a .tar in build/distributions via the distribution plugin. However, I would like to have just the uncompressed libs.

此处,我似乎是一个可能的解决方案,但是我想将此作为主要版本的一部分而不是单独的任务.

I've seem a possible solution here, however I would like to have this as part of the main build and not as a separated task.

推荐答案

只需将任务作为依赖项添加到 build .这样,它将成为主要构建的一部分".

Just add the task as a dependency to build. That way it will be "part of the main build".

task copyDependencies(type: Copy) {
  from configurations.runtimeClasspath // And/or:
  from configurations.compileClasspath
  into "$buildDir/lib"
}
build.dependsOn copyDependencies

当然,您也可以将其连接到用于构建或部署应用程序的任何其他任务.

You can, of cause, also hook it up to any other task that you use to build or deploy the application.

只是在您不知道的情况下,也可以使用分发插件中的 installDist 任务(与应用程序插件结合使用)在 $ buildDir中创建分解版本./install .

Just in case you are not aware of it, you can also use the installDist task from the distribution plugin (in combination with the application plugin) to create an exploded version in $buildDir/install.

这篇关于将项目依赖项复制到文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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