当前位置:网站首页>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
Settingsobject , performsettings.gradleConfigure this object - Use
SettingsObject generation engineering structure , establishProjectobject - For all
ProjectExecute correspondingbuild.gradleTo 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++)
边栏推荐
- Batch detect whether there is CDN in URL - high accuracy
- 2022-2028 global encryption software industry research and trend analysis report
- Software testing learning notes - network knowledge
- 2022 low voltage electrician test question simulation test question bank simulation test platform operation
- [staff] restore mark (Introduction to the use of restore mark | example analysis of Metaphone mark and restore mark)
- 图扑软件通过 CMMI5 级认证!| 国际软件领域高权威高等级认证
- 2022低压电工考试题模拟考试题库模拟考试平台操作
- The video number will not be allowed to be put on the shelves of "0 yuan goods" in the live broadcasting room?
- Websocket + spingboot realize code scanning login
- Discussion on related configuration of thread pool
猜你喜欢
![[staff] the direction of the symbol stem and the connecting line (the symbol stem faces | the symbol stem below the third line faces upward | the symbol stem above the third line faces downward | the](/img/fe/d97b25f702bbc05f941d08147259e0.jpg)
[staff] the direction of the symbol stem and the connecting line (the symbol stem faces | the symbol stem below the third line faces upward | the symbol stem above the third line faces downward | the

2022-2028 global manual dental cleaning equipment industry research and trend analysis report

Render header usage of El table
![[JS reverse series] analysis of a customs publicity platform](/img/15/fdff7047e789d4e7c3c273a2f714f3.jpg)
[JS reverse series] analysis of a customs publicity platform

MVVM and MVC

GB/T-2423. XX environmental test documents, including the latest documents

超图iServer rest服务之feature查询

JS introduction < 1 >

結婚後

2022-2028 global nano abrasive industry research and trend analysis report
随机推荐
QT实现界面跳转
Realize the code scanning function of a custom layout
[learn C and fly] day 5 chapter 2 program in C language (Exercise 2)
STM32__ 05 - PWM controlled DC motor
Leetcode question brushing (10) - sequential question brushing 46 to 50
Redis cluster
QT uses sqllite
About DNS
Mongodb non relational database
Qualcomm platform WiFi -- P2P issue (2)
2022-2028 global soft capsule manufacturing machine industry research and trend analysis report
[staff] pitch representation (bass clef | C1 36 note pitch representation | C2 48 note pitch representation | C3 60 note pitch representation)
C shallow copy and deep copy
Which kind of sports headphones is easier to use? The most recommended sports headphones
What is hybrid web containers for SAP ui5
2022安全员-C证考试题及模拟考试
C reflection practice
Render header usage of El table
Baohong industry | four basic knowledge necessary for personal finance
Qualcomm platform WiFi -- Native crash caused by WiFi