Guo Xiaoxing
Weibo: Guo Xiaoxing's Sina Weibo
Email:[email protected]
Blog: http://blog.csdn.net/allenwells
Github:https://github.com/allenwell
The project building system for Android Studio is Gradle.
What is Gradle?
Gradle is based on the Groovy language and is oriented toward Java applications. Automated building tools based on DSL (domain-specific language) syntax.
What are the advantages of gradle?
- Gradle support for multi-project construction is excellent, and engineering relies on Gradle's first citizens.
- Gradle support for local builds.
- Support multi-mode dependency management: Includes jars or dirs from maven remote repositories, nexus, ivy warehouses, and local file systems
- Gradle is the first built-in integration tool that has a good compatibility dependency with Ant, Maven, ivy, and integration.
- Easy migration: Gradle works with any structure (Gradle can adapt to any structure you have.). You can build original and gradle projects in parallel on the same development platform. It is often required to write related tests to ensure the similarity of the plug-ins developed, and this migration can be less disruptive and as reliable as possible. This is also the best practice for refactoring.
- The overall design of Gradle is a language-oriented, rather than a rigid framework.
- Free Open Source
What features does the Gradle offer?
- A switchable, contract-based build framework like Maven that never locks you (contract is better than configuration)
Switchable, build-by-convention frameworks a la Maven. But we never lock you in!
- Powerful support for multi-project construction
- Powerful dependency management (Apache Ivy based) for maximum convenience to build your project
Language for dependency based programming
- Fully support existing MAVEN or Ivy warehouse infrastructure
- Support for transitive dependency management, without the need for remote warehouses and pom.xml and Ivy profiles
- Built on groovy scripting with a build script written in the groovy language
- With a wide range of domain models support your build a rich domain model for describing your build.
In Android Studio, Gradle is comprised of a top-level profile and other module configuration files, as shown in:
Let's take a look at these files in turn.
A gradle top-level configuration file
fileaddto all sub-projects/modules.buildscript { repositories { /* 存储库jcenter,也可以配置moven */ jcenter() } dependencies { /* 依赖的Gradle版本 */ ‘com.android.tools.build:gradle:1.2.3‘ // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }}allprojects { repositories { /* 所有项目的存储库 */ jcenter() }}
Two gradle module configuration file
Apply plugin:' Com.android.application 'Android {Compilesdkversion A//Highest API levelBuildtoolsversion"22.0.1"//Compile tool version numberDefaultconfig {//default configurationApplicationID"Com.allenwells.myapplication"//Application package nameMinsdkversion the//Minimum API levelTargetsdkversion A//Compile API levelVersioncode1//Version numberVersionname"1.0"//Version name} buildtypes {//Build TypeRelease {//Official version configurationMinifyenabledfalseProguardfiles Getdefaultproguardfile (' Proguard-android.txt '),' Proguard-rules.pro '}//Confusing configuration files} sourcesets {main {jnilibs.srcdirs =[' Libs ']}}}dependencies {//Dependent configurationCompile Filetree (dir:' Libs ', include: [' *.jar ']) Compile' com.android.support:appcompat-v7:22.1.1 '}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
"Android Studio Discovery Trail Series" VII: Android Project building System-Gradle