-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
73 lines (60 loc) · 1.8 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import com.example.buildsrc.MyExtension
plugins {
id("java")
}
group = "org.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
}
tasks.getByName<Test>("test") {
useJUnitPlatform()
}
allprojects{
extensions.create("Extension", MyExtension::class.java)
val addElementNoProjectAllScope by extra { _: Unit ->
configure<MyExtension> {
contents.add("addElementNoProjectAllScope")
}
}
//passing a no-argument lambda makes the val EAGERLY initialized with lambda result
val addElementFakeLambdaAllScope by extra {
println("Evaluated FakeLambdaAllScope for ${project.name}")
configure<MyExtension> {
contents.add("addElementFakeLambdaAllScope")
}
}
}
val addElementNoProjectExtScope by extra { _: Unit ->
configure<MyExtension> {
contents.add("addElementNoProjectExtScope")
}
}
//passing a no-argument lambda makes the val EAGERLY initialized with lambda result
val addElementFakeLambdaExtScope by extra {
println("Evaluated FakeLambdaExtScope for ${project.name}")
configure<MyExtension> {
contents.add("addElementFakeLambdaExtScope")
}
}
val addElementWithProject by extra { project: Project ->
project.configure<MyExtension> {
contents.add("addElement")
}
}
val printContents by extra (fun(project: Project){
println("${project.name} contents:")
project.extensions
.getByType(MyExtension::class)
.contents.forEach{println(it)}
println()
})
val getContents by extra (fun(project: Project): Set<String>? {
return project.extensions
.getByType(MyExtension::class)
.contents
})