关于gradle.properties,settings.gradle,gradle-wrapper.properties和local.properties的一些说明 [英] Some light on gradle.properties, settings.gradle, gradle-wrapper.properties and local.properties

查看:1074
本文介绍了关于gradle.properties,settings.gradle,gradle-wrapper.properties和local.properties的一些说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在配置项目时,我经常使用它们,但是大多数情况下都按照说明添加了窥探者.我完全不知道哪个文件到底是什么.任何人都可以清楚地看到每个文件的用途.

I use them often when configuring my project but mostly add snippers as instructed. I have absolutely no clue which file is for what exactly. Can anyone give a clear picture what each file is for.

到目前为止,我认为

local.properties用于诸如 sdk/ndk 位置

local.properties for environment paths like sdk/ndk location

settings.gradle用于包括项目中的所有模块,其中每个模块都有自己的build.gradle

settings.gradle for including all modules in project where each module has it's own build.gradle

gradle.properties吗?
gradle-wrapper.properties吗?

gradle.properties ?
gradle-wrapper.properties ?

推荐答案

gradle.properties

使用gradle.properties创建通用变量 据我所知,此解决方案仅限于Android项目.在/gradle.properties中,您可以定义通用或项目级别的变量,例如:

gradle.properties

Using gradle.properties to create universal variables This solution is limited to Android projects as far as I know. In /gradle.properties you can define your universal or project level variables as such: Link

myBuildToolsVersion = 20.0.0

myBuildToolsVersion=20.0.0

myMinSdkVersion = 10

myMinSdkVersion=10

myTargetSdkVersion = 22

myTargetSdkVersion=22

myCompileSdkVersion = 22

myCompileSdkVersion=22

gradle-wrapper.properties

内部,Android Studio使用包装器配置中定义的Gradle版本.可以在gradle/wrapper/gradle-wrapper.properties.中找到该配置.当Google决定是时候使用新版本的Gradle时,Android Studio会显示一条消息提示您升级.然后,您所需要做的就是单击消息,Android Studio将编辑属性文件并为您同步Gradle安装. 链接

gradle-wrapper.properties

Internally, Android Studio uses the version of Gradle that is defined in the wrapper configuration. That configuration can be found in gradle/wrapper/gradle-wrapper.properties. When Google decides that it is time to use a new version of Gradle, Android Studio will display a message nudging you to upgrade. All you need to do then is click the message and Android Studio will edit the properties file and synchronize the Gradle installation for you. Link

local.properties文件位于项目的根级别.

The local.properties file goes in the project's root level.

此文件不应包含在源代码管理中. (不正确地)将此包含在源代码管理中之后,然后在本地删除该文件,Android Studio会自动为我重新创建该文件.

This file should not be included in source control. After (incorrectly) including this in source control, then deleting the file locally, Android Studio re-created the file for me automatically.

这是此文件的示例内容:

Here is the example content of this file:

## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Thu Aug 14 14:49:26 PDT 2014
sdk.dir=C\:\\Program Files (x86)\\Android\\android-studio\\sdk

请注意sdk.dir=对Android Studio SDK安装位置的引用(在不同的计算机上可能有所不同). 链接

Note the sdk.dir= reference to the location of the Android Studio SDK installation (which may be different on different machines). Link

  • ':lib'逻辑项目路径,该路径根据settings.gradle中提供的信息映射到物理路径.
  • 多项目构建可以具有任意目录结构,该目录结构在settings.gradle中进行配置.除非您愿意,否则无需四处移动目录. 链接
  • ':lib' is a logical project path, which gets mapped to a physical path based on information provided in settings.gradle.
  • A multi-project build can have an arbitrary directory structure, which is configured in settings.gradle. No need to move directories around, unless you want to. Link

有关gradle的更多信息,您需要检查以下链接,这些链接可以帮助您更多地了解gradle和gradle系统. Gradle使开发人员的生活变得轻松,无需对library updationapk generationimport lib easilyproduct flavors以及更多其他内容感到头疼.

For more and more info about gradle you need to check below links which help you more know about gradle and gradle system. Gradle makes developer life easy for not taking to much headache about library updation , apk generation , import lib easily , product flavors and many more.

http://www.vogella.com/tutorials/Gradle/article.html https://developer.android.com/studio/build/gradle-tips. html

这篇关于关于gradle.properties,settings.gradle,gradle-wrapper.properties和local.properties的一些说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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