Gradle多种版本的GRADLE [英] Gradle multiple versions OF GRADLE

查看:100
本文介绍了Gradle多种版本的GRADLE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为清楚起见:这不是有关依赖关系的多个版本,而是有关Gradle自己的jars的多个版本.

我认为可能有答案...但是没有!

I thought this might have the answer... but there aren't any!

这是带有Windows 10操作系统的Gradle 2.14.

This is Gradle 2.14, with a Windows 10 OS.

我发现gradle经常在该项目的".gradle \"目录下建立一个新目录:在合法的"2.14 \"目录旁边,它一直在建立"2.2.1 \"目录.

I found that gradle was constantly building a new directory under the ".gradle\" directory for this project: alongside the legitimate "2.14\" directory it kept building a "2.2.1\" directory.

我查看了Gradle的安装目录:令人困惑的是,我发现了Gradle的jar文件的多个版本:不仅是2.14,而且是2.13、1.7,是2.2.1.

I looked under my directory where Gradle is installed: and puzzlingly I found multiple versions of Gradle's jar files: not only 2.14, but 2.13, 1.7, and yes, 2.2.1..

因此,我决定手动删除2.2.1.罐子.它停止建立虚假的" 2.2.1目录.

So I decided to manually delete the 2.2.1. jars. It stopped building the "spurious" 2.2.1 directory.

有人可以告诉我Gradle如何确定它使用的是哪个版本?我真的很想摆脱那些非2.14罐子,找到一种方法来防止其他版本以某种方式蔓延!

Can someone tell me how Gradle decides which version of itself it is using? I'd really like to get rid of those non-2.14 jars and find a way to prevent other versions creeping back in somehow!

推荐答案

有人可以告诉我Gradle如何确定它使用的是哪个版本?

这取决于您如何调用gradle.

This depends on how you invoke gradle.

方法1.. gradle 命令将调用GRADLE_HOME路径中的gradle版本.

Method 1. A gradle command will invoke the version of gradle which is in your GRADLE_HOME path.

方法2.使用渐变包装器

gradlew 命令将调用在项目的 gradle \ wrapper \ gradle-wrapper.properties 文件(如果已存在)中配置的gradle版本.如果不是,您可以通过 gradle创建包装器--gradle-version 3.3 .现在,当您使用 gradlew 时,它将始终使用gradle版本3.3.

A gradlew command will invoke the version of gradle which is configured in your project's gradle\wrapper\gradle-wrapper.properties file if it exists already. If its not, you can create it by gradle wrapper --gradle-version 3.3. Now when you use gradlew , it will always use gradle version 3.3.

建议使用gradle包装器,这样您就可以在安装了gradle版本可能不同的不同机器上甚至在未安装gradle的机器上一致地重现相同的内部版本,因​​为gradlew.bat和gradlew将用于Windows和Linux分别用于引导构建.

The use of gradle wrapper is recommended so that you can consistently reproduce the same build in different machines where the installed gradle versions might be different or even on machines where gradle is not installed, because gradlew.bat and gradlew will be used on windows and linux respectively for bootstrapping the build.

在.gradle目录中找到gradle的多个版本的原因可能是因为以前您可能曾尝试使用这些版本的gradle进行构建.

The reason you found multiple version of gradle in your .gradle directory might be because previously you might have tried to build with those versions for gradle.

这篇关于Gradle多种版本的GRADLE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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