30

While reading the Android NDK documentation, I came across the term "DSL". I don't know what it means exactly. Would you please tell me the full name of "DSL"?

Documentation here: http://tools.android.com/tech-docs/new-build-system/gradle-experimental#TOC-Samples

Kyle F Hartzenberg
  • 2,567
  • 3
  • 6
  • 24
최완규
  • 333
  • 1
  • 3
  • 4

3 Answers3

43

Simply, it stands for 'Domain Specific Language'. IMO, in gradle context, DSL gives you a gradle specific way to form your build scripts. More precisely, it's a plugin-based build system that defines a way of setting up your build script using (mainly) building blocks defined in various plugins.

For example, gradle scripts usually relies on using methods (also known as building blocks) taking a closure as the only parameter. And you write it down like this;

apply plugin: 'com.android.library'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    ...

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 25

So in above, we wanted to use the 'android{ ...}' building block (or pre-defined task - please see Example.89 here) to set some android properties for our build. But I don't know which building blocks I can put in it at the beginning. So, I need a way to look up those from somewhere. This is where gradle DSL and plugins come into play together. I can go to that specific plugin's page to figure out what kind of building blocks are defined in it, or what makes this plugin special. Those would be the things that defines the capabilities of the plugin in the form of a high-level language called (gradle) DSL.

Understanding how DSL works may require you to know about how 'delegates' work in groovy. This might help quite a lot.

One last thing you might be wondering is about how a gradle.script gets evaluated. You can find some useful information over here.

stdout
  • 2,471
  • 2
  • 31
  • 40
4

It stands for "Domain Specific Language," more info can be found on Wikipedia.

Brandon McKenzie
  • 1,655
  • 11
  • 26
0

Gradle is a build tool, not a language. But in android we use android gradle plugin to get syntax, api for using gradle in android.

e.g

signingConfigs {
            debug {
                keyAlias 'cooldude69'
                keyPassword 'cooldude69'
            }
        }

Here signingConfig is a part of build.gradle file which helps Gradle build tool to specify this build is a debug build with certain keyAlias etc.

So these building blocks, API, etc are formats to use Gradle in android, hence called Gradle DSL (domain-specific language). Can also say in laymen's terms it's a Gradle language (based on groovy languge) to use the Gradle build tool.

reference ->

https://developer.android.com/reference/tools/gradle-api/4.2/classes

https://developer.android.com/studio/build/gradle-tips#groovy

shubham chouhan
  • 580
  • 7
  • 8