@@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
3
3
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest
4
4
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest
5
5
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType
6
+ import tasks.GenerateRemoteSchemas
6
7
7
8
plugins {
8
9
convention.kotlin
@@ -68,52 +69,44 @@ dependencies {
68
69
kover(projects.jsonSchemaValidator)
69
70
}
70
71
71
- private val remotesFile =
72
- layout.buildDirectory
73
- .file(" remotes.json" )
74
- .get()
75
- .asFile
76
-
77
72
val generateRemoteSchemas =
78
- tasks.register(" generateRemoteSchemas" ) {
79
- inputs.dir(" $projectDir /schema-test-suite/remotes" )
80
- outputs.files(remotesFile)
81
- doLast {
82
- remotesFile.outputStream().use { out ->
83
- exec {
84
- standardOutput = out
85
- executable = " python3"
86
- args(
87
- " $projectDir /schema-test-suite/bin/jsonschema_suite" ,
88
- " remotes" ,
89
- )
90
- }
91
- }
92
- }
93
- }
73
+ tasks.register<GenerateRemoteSchemas >(" generateRemoteSchemas" )
94
74
95
75
tasks.withType<AbstractTestTask > {
96
76
dependsOn(generateRemoteSchemas)
97
77
}
98
78
99
79
tasks.withType<KotlinJsTest > {
100
- // This is used to pass the right location for Node.js test
101
- environment(" TEST_SUITES_DIR" , " $projectDir /schema-test-suite/tests" )
102
- environment(" REMOTES_SCHEMAS_JSON" , remotesFile.absolutePath)
80
+ doFirst {
81
+ // This is used to pass the right location for Node.js test
82
+ environment(" TEST_SUITES_DIR" , " $projectDir /schema-test-suite/tests" )
83
+ environment(" REMOTES_SCHEMAS_JSON" , generateRemoteSchemas.flatMap { it.remotesFile }.get().asFile.absolutePath)
84
+ }
103
85
}
104
86
105
87
tasks.withType<KotlinNativeSimulatorTest > {
106
- // prefix SIMCTL_CHILD_ is used to pass the env variable to the simulator
107
- environment(" SIMCTL_CHILD_TEST_SUITES_DIR" , " $projectDir /schema-test-suite/tests" )
108
- environment(" SIMCTL_CHILD_REMOTES_SCHEMAS_JSON" , remotesFile.absolutePath)
88
+ doFirst {
89
+ // prefix SIMCTL_CHILD_ is used to pass the env variable to the simulator
90
+ environment(" SIMCTL_CHILD_TEST_SUITES_DIR" , " $projectDir /schema-test-suite/tests" )
91
+ environment(
92
+ " SIMCTL_CHILD_REMOTES_SCHEMAS_JSON" ,
93
+ generateRemoteSchemas.flatMap {
94
+ it.remotesFile
95
+ }.get().asFile.absolutePath,
96
+ )
97
+ }
109
98
}
110
99
111
100
tasks.withType<KotlinNativeTest > {
112
- environment(" REMOTES_SCHEMAS_JSON" , remotesFile.absolutePath)
101
+ doFirst {
102
+ environment(" REMOTES_SCHEMAS_JSON" , generateRemoteSchemas.flatMap { it.remotesFile }.get().asFile.absolutePath)
103
+ }
113
104
}
114
105
115
106
tasks.withType<Test > {
116
- environment(" REMOTES_SCHEMAS_JSON" , remotesFile.absolutePath)
107
+ doFirst {
108
+ environment(" REMOTES_SCHEMAS_JSON" , generateRemoteSchemas.flatMap { it.remotesFile }.get().asFile.absolutePath)
109
+ }
117
110
}
118
111
119
112
ktlint {
0 commit comments