Some light on gradle.properties, settings.gradle, gradle-wrapper.properties and local.properties

守給你的承諾、 提交于 2019-12-13 03:35:37

问题


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.

So far I think

local.properties for environment paths like sdk/ndk location

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

gradle.properties ?
gradle-wrapper.properties ?


回答1:


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

myMinSdkVersion=10

myTargetSdkVersion=22

myCompileSdkVersion=22

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.

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

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

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

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




回答2:


Gradle includes two properties files, located in your root project directory, that you can use to specify settings for the Gradle build toolkit itself:

gradle.properties This is where you can configure project-wide Gradle settings, such as the Gradle daemon's maximum heap size. local.properties Configures local environment properties for the build system, such as the path to the SDK installation. Because the content of this file is automatically generated by Android Studio and is specific to the local developer environment, you should not modify this file manually or check it into your version control system.



来源:https://stackoverflow.com/questions/48701867/some-light-on-gradle-properties-settings-gradle-gradle-wrapper-properties-and

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!