当前位置:网站首页>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++)
边栏推荐
- [staff] restore mark (Introduction to the use of restore mark | example analysis of Metaphone mark and restore mark)
- MVVM and MVC
- What is the principle of bone conduction earphones and who is suitable for bone conduction earphones
- Actual battle of financial risk control - under Feature Engineering
- STM32__ 05 - PWM controlled DC motor
- [learn C and fly] 1day Chapter 2 (exercise 2.2 find the temperature of Fahrenheit corresponding to 100 ° f)
- C shallow copy and deep copy
- MMSegmentation系列之训练与推理自己的数据集(三)
- The video number will not be allowed to be put on the shelves of "0 yuan goods" in the live broadcasting room?
- Share the basic knowledge of a common Hongmeng application
猜你喜欢
Actual battle of financial risk control - under Feature Engineering
Use usedeferredvalue for asynchronous rendering
STM32__ 05 - PWM controlled DC motor
[JS reverse series] analysis of a customs publicity platform
Baohong industry | 6 financial management models at different stages of life
ZABBIX API creates hosts in batches according to the host information in Excel files
Coordinatorlayout + tablayout + viewpager2 (there is another recyclerview nested inside), and the sliding conflict of recyclerview is solved
Is bone conduction earphone better than traditional earphones? The sound production principle of bone conduction earphones is popular science
数据传输中的成帧
2022-2028 global nano abrasive industry research and trend analysis report
随机推荐
Pychart creates new projects & loads faster & fonts larger & changes appearance
Oracle creates a user with read-only permission in four simple steps
Mathematics in Sinorgchem: computational geometry
Possible causes of runtime error
Golang configure export goprivate to pull private library code
Analysis of FLV packaging format
[road of system analyst] collection of wrong topics in enterprise informatization chapter
竞争与冒险 毛刺
Cache processing scheme in high concurrency scenario
Qualcomm platform wifi-- WPA_ supplicant issue
tarjan2
What is the principle of bone conduction earphones and who is suitable for bone conduction earphones
QT implementation interface jump
Gradle 笔记
Use usedeferredvalue for asynchronous rendering
Verilog 过程连续赋值
2022-2028 global encryption software industry research and trend analysis report
Stack - es - official documents - filter search results
Learning notes of software testing -- theoretical knowledge of software testing
[JSON] gson use and step on the pit