-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
105 lines (99 loc) · 4.35 KB
/
build.gradle.kts
File metadata and controls
105 lines (99 loc) · 4.35 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
* Copyright (c) 2011-2025 Genestack Limited
* All Rights Reserved
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF GENESTACK LIMITED
* The copyright notice above does not evidence any
* actual or intended publication of such source code.
*/
import com.genestack.openapi.DownloadSpecification
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask
import com.genestack.openapi.MergeSpecifications
import kotlin.io.path.listDirectoryEntries
import kotlin.io.path.name
import kotlin.io.path.Path as KotlinPath
plugins {
alias(libs.plugins.openapi.generator)
}
val sourceDirectory = "$rootDir/openapi/v1"
val processorsControllerVersion: String = System.getenv("PROCESSORS_CONTROLLER_VERSION")
val processorsControllerFileName = "processorsController.yaml"
val processorsControllerFilePath = "${sourceDirectory}/${processorsControllerFileName}"
val openApiVersion: String = System.getenv("OPENAPI_VERSION")
val mergedFileName = "odmApi.yaml"
val mergedFilePath = "${sourceDirectory}/${mergedFileName}"
tasks {
val downloadSpec by registering(DownloadSpecification::class) {
version.set(processorsControllerVersion)
registryUsername.set(System.getenv("NEXUS_USER"))
registryPassword.set(System.getenv("NEXUS_PASSWORD"))
releaseRegistryUrl.set(System.getenv("RAW_REGISTRY_RELEASES"))
snapshotRegistryUrl.set(System.getenv("RAW_REGISTRY_SNAPSHOTS"))
outputFile.set(layout.projectDirectory.file(processorsControllerFilePath))
}
val mergeSpecifications by registering(MergeSpecifications::class) {
dependsOn(downloadSpec)
inputFiles.set(provider { // provider to calculate during runtime, not configuration loading time
KotlinPath(sourceDirectory)
.listDirectoryEntries("*.yaml")
.sorted()
.map { layout.projectDirectory.file("${sourceDirectory}/${it.name}") }
})
outputFile.set(layout.projectDirectory.file(mergedFilePath))
}
val generateOdmApiPython by registering(GenerateTask::class) {
dependsOn(mergeSpecifications)
generatorName.set("python")
inputSpec.set(mergedFilePath)
outputDir.set("$rootDir/generated/python")
packageName.set("odm_api")
gitUserId.set("genestack")
gitRepoId.set("openapi")
nameMappings.set(mapOf("genestack:accession" to "genestackaccession"))
configOptions = mapOf(
"packageVersion" to openApiVersion,
// Workaround for https://github.com/OpenAPITools/openapi-generator/issues/21619
// The second version asks for license, which we can't provide due to unavailability of
// "licenseName" and "licenseUrl" fields in the specification for python generator.
"poetry1" to "true",
// All float fields accept "NaN", "Infinity", "-Infinity" values
"mapNumberTo" to "float"
// "disallowAdditionalPropertiesIfNotPresent" to "true"
)
}
val generateOdmApiR by registering(GenerateTask::class) {
dependsOn(mergeSpecifications)
generatorName.set("r")
inputSpec.set(mergedFilePath)
outputDir.set("$rootDir/generated/r")
packageName.set("odmApi")
gitUserId.set("genestack")
gitRepoId.set("openapi")
nameMappings.set(mapOf("genestack:accession" to "genestackaccession"))
configOptions = mapOf(
"packageVersion" to openApiVersion
// "disallowAdditionalPropertiesIfNotPresent" to "true"
)
}
val generateOdmApiPostmanCollection by registering(GenerateTask::class) {
dependsOn(mergeSpecifications)
generatorName.set("postman-collection")
inputSpec.set(mergedFilePath)
outputDir.set("$rootDir/generated/postman-collection")
packageName.set("odm-api")
gitUserId.set("genestack")
gitRepoId.set("openapi")
nameMappings.set(mapOf("genestack:accession" to "genestackaccession"))
configOptions = mapOf(
"packageVersion" to openApiVersion
// "disallowAdditionalPropertiesIfNotPresent" to "true"
)
}
val generateAll by registering(GradleBuild::class) {
file("$rootDir/generated").deleteRecursively()
tasks = listOf(
generateOdmApiPython.name,
generateOdmApiR.name,
generateOdmApiPostmanCollection.name
)
}
}