当前位置:网站首页>Gradle notes
Gradle notes
2022-07-02 03:03:00 【howeres】
Groovy The closure of ( The key grammar )
Definition : Be similar to lambda expression , Use when passing Anonymous inner class object The way
characteristic : You can make a statement first , Then set up the agent to execute
Closure closure = {
sayHello()
}
// Test preparation
class Foo {
void sayHello() {
println("Hello!!!")
}
}
def foo = new Foo()
// Start testing , It can be seen that delegate It's a member variable , And the type is anonymous interface
closure.delegate = foo
closure()
- Call features :
- Can be external ( Closure object in the last parameter )
- Can be external + Omit parenthesis ( When there is only one parameter and it is a closure )
def running(Closure closure) {
println("start~")
closure()
println("end.")
}
running({
println("running...") })
// Closures can be post
running() {
println("running...")}
def caculate(Closure closure) {
def num1 = 10
def num2 = 15
closure(num1, num2)
}
caculate() {
k,v -> println("$k + $v = ${k+v}")}
// Brackets can be omitted , That is, the most familiar Gradle The way
caculate {
k,v -> println("$k + $v = ${k+v}") }
Gradle Construction process of
- Generate a
Settings
object , performsettings.gradle
Configure this object - Use
Settings
Object generation engineering structure , establishProject
object - For all
Project
Execute correspondingbuild.gradle
To configure
Script files build.gradle
How to execute
To sum up ,build.gradle
It's just one. Groovy Script file in format , Build in sequence , But turn it on build.gradle
May still be confused , Characters and braces ? With the longest used dependencies
give an example
dependencies {
// This dependency is found on compile classpath of this component and consumers.
implementation 'com.google.guava:guava:26.0-jre'
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
}
meanwhile implementation
You can also write like this
implementation('com.google.guava:guava:26.0-jre')
implementation
It's actually a function . Groovy Function calls in can be called in the form of spaces plus parameters
void foo(String params1, int param2) {
println("param1 = $params1, param2 = $param2")
}
foo "hello", 996
Gradle and Groovy The relationship between
Gradle Support Kotlin or Groovy Written in two languages , The relationship between the two is Realization relationship . Groovy yes Gradle A kind of DSL ( Domain Specific Language
i.e., Domain specific language )
Gradle Of DSL A build dedicated to configuration projects cannot be used for other work . Grammar is still Groovy Its own grammar , But the call can only rely on Gradle Stipulated API Mode or a specific set of specifications . Emphasize one Specific special ( Appointment )
And DSL (HTML、Makefile、LaTeX、AWK) The corresponding is a general language that can do any work (Java 、C/C++)
边栏推荐
- Jointly developed by nailing, the exclusive functions of glory tablet V7 series were officially launched
- How to create an instance of the control defined in SAP ui5 XML view at runtime?
- Mongodb base de données non relationnelle
- 2022 safety officer-c certificate examination questions and mock examination
- [liuyubobobo play with leetcode algorithm interview] [00] Course Overview
- [learn C and fly] 1day Chapter 2 (exercise 2.2 find the temperature of Fahrenheit corresponding to 100 ° f)
- Realize the code scanning function of a custom layout
- Provincial election + noi Part IV graph theory
- Share the basic knowledge of a common Hongmeng application
- STM32__ 05 - PWM controlled DC motor
猜你喜欢
Just a few simple steps - start playing wechat applet
C reflection practice
Leetcode question brushing (10) - sequential question brushing 46 to 50
Formatting logic of SAP ui5 currency amount display
Pychart creates new projects & loads faster & fonts larger & changes appearance
Which brand of sports headset is better? Bluetooth headset suitable for sports
Baohong industry | four basic knowledge necessary for personal finance
[JVM] detailed description of the process of creating objects
小米青年工程师,本来只是去打个酱油
2022-2028 global human internal visualization system industry research and trend analysis report
随机推荐
Baohong industry | four basic knowledge necessary for personal finance
【做题打卡】集成每日5题分享(第二期)
What kind of good and cost-effective Bluetooth sports headset to buy
Batch detect whether there is CDN in URL - high accuracy
连通块模板及变式(共4题)
使用开源项目【Banner】实现轮播图效果(带小圆点)
MongoDB非关系型数据库
PMP personal sprint preparation experience
寻找重复数[抽象二分/快慢指针/二进制枚举]
QT uses sqllite
竞争与冒险 毛刺
[learn C and fly] 1day Chapter 2 (exercise 2.2 find the temperature of Fahrenheit corresponding to 100 ° f)
[staff] restore mark (Introduction to the use of restore mark | example analysis of Metaphone mark and restore mark)
Ten minutes will take you in-depth understanding of multithreading - multithreaded teamwork: synchronous control
Mmsegmentation series training and reasoning their own data set (3)
3124. Word list
Learning notes of software testing -- theoretical knowledge of software testing
Oracle creates a user with read-only permission in four simple steps
tarjan2
About DNS