当前位置:网站首页>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++)
边栏推荐
- Remote connection to MySQL under windows and Linux system
- 結婚後
- Mathematical calculation in real mode addressing
- Coordinatorlayout + tablayout + viewpager2 (there is another recyclerview nested inside), and the sliding conflict of recyclerview is solved
- Pychart creates new projects & loads faster & fonts larger & changes appearance
- 图扑软件通过 CMMI5 级认证!| 国际软件领域高权威高等级认证
- How to create an instance of the control defined in SAP ui5 XML view at runtime?
- 只需简单几步 - 开始玩耍微信小程序
- Which brand of running headphones is good? How many professional running headphones are recommended
- MVVM and MVC
猜你喜欢
Render header usage of El table
verilog 并行块实现
OSPF LSA message parsing (under update)
Addition without addition, subtraction, multiplication and division (simple difficulty)
CoordinatorLayout + TabLayout + ViewPager2(里面再嵌套一个RecyclerView),RecyclerView的滑动冲突解决
高并发场景下缓存处理方案
2022-2028 global soft capsule manufacturing machine industry research and trend analysis report
[road of system analyst] collection of wrong topics in enterprise informatization chapter
Remote connection to MySQL under windows and Linux system
結婚後
随机推荐
STM32__ 05 - PWM controlled DC motor
The video number will not be allowed to be put on the shelves of "0 yuan goods" in the live broadcasting room?
MMSegmentation系列之训练与推理自己的数据集(三)
Verilog 过程连续赋值
Gradle 笔记
3124. Word list
Possible causes of runtime error
Discussion on related configuration of thread pool
Is bone conduction earphone better than traditional earphones? The sound production principle of bone conduction earphones is popular science
Force deduction daily question 540 A single element in an ordered array
STM32__05—PWM控制直流电机
Cache processing scheme in high concurrency scenario
Formatting logic of SAP ui5 currency amount display
Mmsegmentation series training and reasoning their own data set (3)
Analysis of FLV packaging format
New programmer magazine | Li Penghui talks about open source cloud native message flow system
创业了...
[learn C and fly] 4day Chapter 2 program in C language (exercise 2.5 generate power table and factorial table
Feature query of hypergraph iserver rest Service
SAP ui5 beginner tutorial 19 - SAP ui5 data types and complex data binding