Skip to content

Commit

Permalink
PR remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-brt committed Jul 8, 2024
1 parent bfe29c6 commit 8ad4cce
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 40 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/publish-swaggerhub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,14 @@ jobs:
run: |
./gradlew resolve
- name: Download upstream API specs
- name: Download upstream API specs for control-plane and data-plane
run: |
./gradlew :edc-controlplane:edc-controlplane-base:downloadOpenapi
cp edc-controlplane/edc-controlplane-base/build/docs/openapi/* resources/openapi/yaml/
./gradlew :edc-dataplane:edc-dataplane-base:downloadOpenapi
cp edc-dataplane/edc-dataplane-base/build/docs/openapi/* resources/openapi/yaml/
- name: Merge API specs
run: |
./gradlew -PapiTitle="Tractus-X EDC REST API" -PapiDescription="Tractus-X EDC API Documentation" :mergeApiSpec --input=./resources/openapi/yaml --output=./resources/openapi/yaml/tractusx-edc-api.yaml
Expand Down
40 changes: 40 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,43 @@ nexusPublishing {
tasks.check {
dependsOn(tasks.named<JacocoReport>("testCodeCoverageReport"))
}

tasks.register("downloadOpenapi") {
outputs.dir(project.layout.buildDirectory.dir("docs/openapi"))
doLast {
val destinationDirectory = layout.buildDirectory.asFile.get().toPath()
.resolve("docs").resolve("openapi")

configurations.asMap.values
.asSequence()
.filter { it.isCanBeResolved }
.map { it.resolvedConfiguration.firstLevelModuleDependencies }.flatten()
.map { childrenDependencies(it) }.flatten()
.distinct()
.forEach { dep ->
downloadYamlArtifact(dep, "management-api", destinationDirectory);
downloadYamlArtifact(dep, "observability-api", destinationDirectory);
downloadYamlArtifact(dep, "public-api", destinationDirectory);
}
}
}

fun childrenDependencies(dependency: ResolvedDependency): List<ResolvedDependency> {
return listOf(dependency) + dependency.children.map { child -> childrenDependencies(child) }.flatten()
}

fun downloadYamlArtifact(dep: ResolvedDependency, classifier: String, destinationDirectory: java.nio.file.Path) {
try {
val managementApi = dependencies.create(dep.moduleGroup, dep.moduleName, dep.moduleVersion, classifier = classifier, ext = "yaml")
configurations
.detachedConfiguration(managementApi)
.resolve()
.forEach { file ->
destinationDirectory
.resolve("${dep.moduleName}.yaml")
.toFile()
.let(file::copyTo)
}
} catch (_: Exception) {
}
}
39 changes: 0 additions & 39 deletions edc-controlplane/edc-controlplane-base/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -77,42 +77,3 @@ dependencies {
runtimeOnly(libs.edc.controlplane.callback.dispatcher.http)

}

tasks.register("downloadOpenapi") {
outputs.dir(project.layout.buildDirectory.dir("docs/openapi"))
doLast {
val destinationDirectory = layout.buildDirectory.asFile.get().toPath()
.resolve("docs").resolve("openapi")

configurations.asMap.values
.asSequence()
.filter { it.isCanBeResolved }
.map { it.resolvedConfiguration.firstLevelModuleDependencies }.flatten()
.map { childrenDependencies(it) }.flatten()
.distinct()
.forEach { dep ->
downloadYamlArtifact(dep, "management-api", destinationDirectory);
downloadYamlArtifact(dep, "observability-api", destinationDirectory);
}
}
}

fun childrenDependencies(dependency: ResolvedDependency): List<ResolvedDependency> {
return listOf(dependency) + dependency.children.map { child -> childrenDependencies(child) }.flatten()
}

fun downloadYamlArtifact(dep: ResolvedDependency, classifier: String, destinationDirectory: java.nio.file.Path) {
try {
val managementApi = dependencies.create(dep.moduleGroup, dep.moduleName, dep.moduleVersion, classifier = classifier, ext = "yaml")
configurations
.detachedConfiguration(managementApi)
.resolve()
.forEach { file ->
destinationDirectory
.resolve("${dep.moduleName}.yaml")
.toFile()
.let(file::copyTo)
}
} catch (_: Exception) {
}
}

0 comments on commit 8ad4cce

Please sign in to comment.