Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "DSL" mean in gradle?

Tags:

While I read Android NDK document, there is the "DSL". I don't know what it means exactly. Would you please tell me full name of the "DSL"?

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

like image 403
최완규 Avatar asked Jul 12 '16 18:07

최완규


People also ask

What is Gradle Groovy DSL?

Gradle is a new and revolutionary build tool, based on the Groovy programming language. It is very different from existing tools like Ant and Maven in that it provides an extremely powerful capability to develop build applications using Groovy code and a compelling Groovy DSL.

What is plugin DSL?

The plugins DSL provides a succinct and convenient way to declare plugin dependencies. It works with the Gradle plugin portal to provide easy access to both core and community plugins. The plugins DSL block configures an instance of PluginDependenciesSpec. To apply a core plugin, the short name can be used: Example 1.

What is Kotlin Gradle DSL?

The Gradle Kotlin DSL provides support for writing Gradle build scripts using JetBrains' Kotlin language.

What is Kotlin DSL android?

Kotlin script is Kotlin code that can be run from the command line. Kotlin DSL: Refers primarily to the Android Gradle plugin Kotlin DSL or, occasionally, to the underlying Gradle Kotlin DSL. In the context of migrating from Groovy, the terms “KTS” and “Kotlin DSL” may be used interchangeably.


1 Answers

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.

like image 156
stdout Avatar answered Sep 18 '22 15:09

stdout