@@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
33import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest
44import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest
55import org.jlleitschuh.gradle.ktlint.reporter.ReporterType
6+ import tasks.GenerateRemoteSchemas
67
78plugins {
89 convention.kotlin
@@ -68,52 +69,44 @@ dependencies {
6869 kover(projects.jsonSchemaValidator)
6970}
7071
71- private val remotesFile =
72- layout.buildDirectory
73- .file(" remotes.json" )
74- .get()
75- .asFile
76-
7772val 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" )
9474
9575tasks.withType<AbstractTestTask > {
9676 dependsOn(generateRemoteSchemas)
9777}
9878
9979tasks.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+ }
10385}
10486
10587tasks.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+ }
10998}
11099
111100tasks.withType<KotlinNativeTest > {
112- environment(" REMOTES_SCHEMAS_JSON" , remotesFile.absolutePath)
101+ doFirst {
102+ environment(" REMOTES_SCHEMAS_JSON" , generateRemoteSchemas.flatMap { it.remotesFile }.get().asFile.absolutePath)
103+ }
113104}
114105
115106tasks.withType<Test > {
116- environment(" REMOTES_SCHEMAS_JSON" , remotesFile.absolutePath)
107+ doFirst {
108+ environment(" REMOTES_SCHEMAS_JSON" , generateRemoteSchemas.flatMap { it.remotesFile }.get().asFile.absolutePath)
109+ }
117110}
118111
119112ktlint {
0 commit comments