So, I've been trying to avoid build tools for a while, but started to use Gradle for some time now. I'm able to use it for simple things like letting it download dependencies, like it's intended, but I've seen people use it to do really advanced staff like manage large projects with different modules, native dependencies, publish to Github when building, etc.

I feel like I still need to copy-paste a lot when trying to do anything more complicated, because even after finding some documentation to read, I'm still not sure where language syntax like {, }, :, (, ), are meant to be used.

So, my question is: Does it make sense to learn Groovy to understand Gradle better? Should reading the docs be enough? I'm not even asking because I would not be interested in Groovy, I'm just wondering how people got used to using Gradle and whether it makes sense to use it for more advanced tasks then fetching dependencies from repositories.

推荐答案

Gradle使用的DSL(领域特定语言)是基于Groovy之上的currently.这意味着,通过只学习DSL,你应该能够在一定程度上与Gradle合作.当然,它继承了Groovy的一些语法(如括号等),但语法与普通Groovy代码相差甚远.

如果你想开始编写自己的闭包、任务和插件,那么你需要一些Groovy技能,是的.Groovy in Action 2nd edition是一本好书,如果你是Java开发人员,请看一下Making Java Groovy.

说到这里,请记住Gradle Inc announced that they are going to support Kotlin as another language to base the DSL on.这意味着您将能够在Kotlin or Groovy中编写构建的"自定义"部分.所以,也要关注Kotlin ,这里有最好的方法——Kotlin in Action.

Kotlin相关问答推荐

Spring Boot Bean验证器未触发

Spring Boot kotlin协程不能并行运行

用A*搜索算法解决特修斯和米诺陶尔难题

相当于roomdb中的DateTime Bigint列的是什么

如何让 LocalDateTime.parse 拒绝 24:00 时间

为什么Kotlin有次构造函数和init块?

在 Kotlin 中将两个字节转换为 UIn16

为什么Kotlin不用static inner class来实现带有object关键字的单例呢?

修改器的属性是什么,我需要更改以使角变圆且宽度更小?喷气背包组合

Kotlin 函数中接收者和参数的类型相同

Kotlin 函数有 2 个参数用于对 Map 或 List 进行排序

gradle 如何 Select 以-jvm结尾的库?

是什么让 Kotlin 中的 String 类能够使用方括号?

JobIntentService 被销毁,当应用程序被销毁时

无法解决:androidx.lifecycle:lifecycle-viewmodel-ktx:1.1.1

如何在 kotlin 的片段类中更改 ActionBar 标题?

Android Room - error: Cannot figure out how to save this field into database

在Kotlin中不带类直接引用枚举实例

Android Compose 生产准备好了吗?

Kotlin:获取文件的扩展名,例如.txt