当前位置:网站首页>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
边栏推荐
猜你喜欢

JSP第二篇 -----JSP浅聊EL表达式第二篇:EL表达式中的运算符

SushiSwap「SUSHI」下降了 93%,但还没有完全消失

What are the latest developments in the handling of false information?KDD2022 "Fighting Misinformation and Responding to Media Bias" tutorial, 161 pages ppt

fillder4不间断提示the system proxy was change,看我解决

音视频技术开发周刊 | 257

com.alibaba.fastjson.JSONException: default constructor not found. class

Ansible自动化运维工具(一)安装及模块

Ansible自动化运维工具(二)playbook剧本

rk3588使用npu进行模型转换和推理,加速AI应用落地

LeetCode_2_两数相加
随机推荐
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception
WPF主窗体调用 User32的SetWindowPos 设置窗体置顶会导致与其他窗体抢夺焦点的问题
劳务派遣业务流程图
OpenEuler's Ways to Improve Resource Utilization 02: Effects under Typical Applications
Kotlin委托属性知识点
How can recommender systems be trusted?A review of the latest "Trusted Recommender System" from Rutgers University, a 43-page pdf explaining the composition and technology of trusted RS
头脑风暴:打家劫舍2
Little knowledge about KotlinAndroid encounters
NAACL2022 NER SOTA—RICON学习笔记
方舟基础物品指令代码大全
PHPUnit 单元测试
简单Swing界面笔记
Kotlin之JSON格式解析
树查找(暑假每日一题 18)
nacos作用
高数_复习_第3章:一元函数积分学
openEuler 资源利用率提升之道02:典型应用下的效果
数据解读!智能座舱“升级战”背后,本土供应链加速崛起
PHP使用glob()查找文件
超人飞来!Flutter 实现满屏的力量感动画!