-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
65 lines (53 loc) · 1.35 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
import org.jetbrains.kotlin.gradle.internal.ensureParentDirsCreated
plugins {
kotlin("jvm")
}
repositories {
mavenCentral()
}
tasks {
// Таска для создания файла
val myCustomTask by creating {
group = "my group"
val dir = layout.buildDirectory.dir("my-in")
outputs.dir(dir)
doFirst {
val fileContent = """
package my.package
const val MY_VERSION: String = "${project.version}"
""".trimIndent()
dir
.get()
.file("my-version.kt")
.asFile
.apply {
ensureParentDirsCreated()
writeText(fileContent)
}
}
}
val myCopyTask by creating(Copy::class) {
dependsOn(myCustomTask)
group = "my group"
from(myCustomTask.outputs)
into(layout.buildDirectory.dir("tmp"))
}
compileKotlin {
dependsOn(myCopyTask)
}
}
tasks {
create("myTask") {
println("Configuration stage")
doFirst { println("At task starts") }
doLast { println("At task ends") }
}
}
afterEvaluate {
tasks {
create("myOtherTask") {
println("After other tasks initialized")
}
forEach { println("TASK $it") }
}
}