@@ -11,6 +11,7 @@ import org.gradle.process.ExecOperations
11
11
import java.io.File
12
12
import java.io.FileOutputStream
13
13
import javax.inject.Inject
14
+ import org.gradle.api.file.ConfigurableFileCollection
14
15
15
16
@CacheableTask
16
17
abstract class StoneTask : DefaultTask () {
@@ -21,44 +22,56 @@ abstract class StoneTask : DefaultTask() {
21
22
@get:Input
22
23
abstract val stoneConfigs: ListProperty <StoneConfig >
23
24
24
- @get:InputDirectory
25
+ @get:InputFile
25
26
@get:PathSensitive(PathSensitivity .RELATIVE )
26
- abstract val generatorDir : DirectoryProperty
27
+ abstract val generatorFile : RegularFileProperty
27
28
28
- @get:InputDirectory
29
- @get:PathSensitive(PathSensitivity .RELATIVE )
29
+ @get:Internal
30
30
abstract val specDir: DirectoryProperty
31
31
32
+ @get:InputFiles
33
+ @get:PathSensitive(PathSensitivity .RELATIVE )
34
+ abstract val specFiles: ConfigurableFileCollection
35
+
32
36
@get:Optional
33
37
@get:InputFile
34
38
@get:PathSensitive(PathSensitivity .RELATIVE )
35
39
abstract val routeWhitelistFilter: RegularFileProperty
36
40
37
- @get:InputDirectory
38
- @get:PathSensitive(PathSensitivity .RELATIVE )
41
+ @get:Internal
39
42
abstract val stoneDir: DirectoryProperty
40
43
44
+ @get:InputFiles
45
+ @get:PathSensitive(PathSensitivity .RELATIVE )
46
+ abstract val stoneFiles: ConfigurableFileCollection
47
+
41
48
@get:Input
42
49
abstract val pythonCommand: Property <String >
43
50
44
51
@get:OutputDirectory
45
52
abstract val outputDir: DirectoryProperty
46
53
54
+ init {
55
+ stoneFiles.setFrom(stoneDir.asFileTree.matching {
56
+ include(" **/*.py" )
57
+ })
58
+
59
+ specFiles.setFrom(specDir.asFileTree.matching {
60
+ include(" **/*.stone" )
61
+ })
62
+ }
63
+
47
64
@TaskAction
48
65
fun processStone () {
49
66
check(stoneDir.get().asFile.exists()) {
50
- " Stone directory ${ stoneDir} does not exist. " +
67
+ " Stone directory $stoneDir does not exist. " +
51
68
" Please run `./update-submodules` to download the stone submodule."
52
69
}
53
70
54
71
val outputDirectory = outputDir.asFile.get()
55
72
outputDirectory.deleteRecursively()
56
73
outputDirectory.mkdirs()
57
74
58
- val generatorFile = generatorDir.asFileTree.matching {
59
- exclude(" **/*.pyc" )
60
- }.singleFile
61
-
62
75
val specFiles = specDir.asFileTree.matching {
63
76
include(" **/*.stone" )
64
77
}.files
@@ -83,7 +96,7 @@ abstract class StoneTask : DefaultTask() {
83
96
pythonCommand.get(), " -m" , " stone.cli" ,
84
97
" --attribute" , " :all" ,
85
98
86
- generatorFile.absolutePath ,
99
+ generatorFile.get().asFile ,
87
100
outputDirectory.resolve(" src" ).absolutePath,
88
101
* specFiles.map { it.absolutePath }.toTypedArray(),
89
102
" --" , " --package" , stoneConfig.packageName,
@@ -124,7 +137,7 @@ abstract class StoneTask : DefaultTask() {
124
137
125
138
private fun buildRouteFilter (stoneConfig : StoneConfig ): String {
126
139
val client = stoneConfig.client
127
- val routeFilters = listOf (stoneConfig.globalRouteFilter, client?.routeFilter).filterNotNull( )
140
+ val routeFilters = listOfNotNull (stoneConfig.globalRouteFilter, client?.routeFilter)
128
141
return routeFilters.joinToString(" and " ) { " (${it} )" }
129
142
}
130
143
}
0 commit comments