当前位置:网站首页>Gradle is as simple as using kotlin to write common commands
Gradle is as simple as using kotlin to write common commands
2022-08-08 20:33:00 【Do not forget the original intention z】
gradle is as simple as command use
I wrote it casually today, next time I will sort it out and study it steadily
plugins {
//Plugins can be set here
For example, if you want to write java files in gradle, just write
java
}
task custom command
doFirst{} //This command will run to when gradle is running
doLast{} //This command is run when gradle scans
dependaOn//This isConstrain the custom command to the dependency closure. For example, the task needs to execute "go to the hotel for dinner" but there is a condition. The condition is that you must have money, otherwise you will go to the king's meal.dependaOn (bring money) to execute custom orders from going to the hotel to eat.Among them, bringing money is also a task custom command, see the code for details
task("Go to the hotel for dinner",{
doFirst{
println("Go to the hotel for dinner") }
}).dependsOn("Bring money")
task("Bring money",{
doFirst{
println("Bring a thousand dollars")}
})
The above code means that if the method of going to the hotel for dinner is executed, the method of bringing money will be executed in advance. If there is no such method, an error will be reported!
//Record all source code to file name
task("getSrcName",{
//Incremental update -> Can detect files (class files) in real time if there is no change, do not output!
inputs.dir("src")//input
outputs.file("info.txt")//output
doFirst{
var srcdir = fileTree("src")
var infotxt = file("info.txt")
srcdir.forEach {
if(it.isFile){
//appendText is written to the file
infotxt.appendText(it.absolutePath)//Record the current file path
infotxt.appendText("\r\n")//Newline
}
}
}
})
The following describes how to use the task
task contains the required methods, here is the first to learn
Delete delete method
Copy copy method
Jar packaging method to generate jar package
See the code for specific usage methods
task("Delete", Delete::class, {
setDelete (the specific file directory can be deleted)})task("Copy", Copy::class, {
from (specifically copy that folder or file)
into (specifically copy that file)})
task("Jar", Jar::class, {
from(package that folder into a jar package)
into(package and store the jar package in that directory)})
These three methods can be more commonly used, and other methods can be entered: docs.gradle.org Officially go to the document to view
边栏推荐
- Web3到底是什么?
- 高数_复习_第3章:一元函数积分学
- 关于KotlinAndroid遇到的小知识
- 随手记:laravel、updateOrCreate 和 updateOrInsert 的区别
- The WPF main form calls User32's SetWindowPos to set the form to the top, which will cause the problem of grabbing the focus with other forms
- 记一次坎坷的调试|Mosquitto通过TLS连接EMQ时阻塞的问题
- 兼容并蓄广纳百川,Go lang1.18入门精炼教程,由白丁入鸿儒,go lang复合容器类型的声明和使用EP04
- 文档管理系统对于企业来说有哪些作用?
- 用 Antlr 重构脚本解释器
- Matlab用回归、SEIRD模型、聚类预测美国总统大选、新冠疫情对中美经济的影响
猜你喜欢
2022-08-08 第六小组 瞒春 学习笔记
技术分享 | 接口自动化测试之JSON Schema模式该如何使用?
iMeta | 深圳先进院戴磊组开发可同时提取共存菌株的组成和基因成分谱的菌株分析工具...
如何用WebSocket打造Web端IM即时通讯聊天
一文教你普罗米修斯Prometheus的基础应用
亚洲首个!朱永官院士荣获2022年国际土壤科学联合会李比希奖
学习笔记:线性表的顺序表示和实现(二级指针实现)
阿里云OSS文件下载到本地指定文件有坑
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception
From interview to autism, five rounds of interviews for byte software testing post, four hours of soul torture...
随机推荐
Matlab用回归、SEIRD模型、聚类预测美国总统大选、新冠疫情对中美经济的影响
数据解读!智能座舱“升级战”背后,本土供应链加速崛起
rk3588使用npu进行模型转换和推理,加速AI应用落地
fillder4不间断提示the system proxy was change,看我解决
接口测试经典面试题:Session、cookie、token有什么区别?
Ansible自动化运维工具(二)playbook剧本
音视频技术开发周刊 | 257
深度学习初步认知
源码分析MyCat专栏
OneNote 教程,如何在 OneNote 中检查拼写?
PHPUnit 单元测试
同花顺买股票软件正规吗?安全吗?
自定义MVC
LitJson使用中的一些问题
基于opencv的图片人像移除
【无标题】
买股票安全吗 资金能取出来吗
箭头函数this指向的解释
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception
西湖大学鞠峰组招聘【塑料降解 / 污水工程 / 微生物学】方向博士后和科研助理...