From c0e4e95d3debf48d9681261a7dd7f1bde74b4c59 Mon Sep 17 00:00:00 2001 From: Beppe Catanese Date: Mon, 11 Nov 2024 10:42:53 +0100 Subject: [PATCH 1/2] Delete services/models before generation --- go/build.gradle | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/go/build.gradle b/go/build.gradle index d02e9a4..298573b 100644 --- a/go/build.gradle +++ b/go/build.gradle @@ -59,8 +59,13 @@ services.each { Service svc -> dependsOn generateTask outputs.upToDateWhen { false } + // delete existing services and models + doFirst { + delete layout.projectDirectory.dir("repo/src/$svc.id") + } + from layout.buildDirectory.dir("services/$svc.id") - include "**/*.go" + include "**/*" into layout.projectDirectory.dir("repo/src/$svc.id") } @@ -94,10 +99,17 @@ tasks.named('deployPayment', Copy) { into layout.projectDirectory.dir("repo/src/payments") } -// These don't need a "index" -services.findAll({ it.small || it.name.endsWith('Webhooks') }).each { Service svc -> +// Small services (skip client.go as single class service does not need an "index" to group multiple tags) +services.findAll({ it.small }).each { Service svc -> + tasks.named("deploy${svc.name}", Copy) { + exclude 'client.go' + } +} + +// Webhooks (skip client.go and copy models only) +services.findAll({ it.name.endsWith('Webhooks') }).each { Service svc -> tasks.named("deploy${svc.name}", Copy) { - exclude 'client.go', 'api_default.go' + exclude 'client.go' } } @@ -107,3 +119,27 @@ services.findAll({ it.small || it.name.endsWith('Webhooks') }).each { Service sv additionalProperties.put('hasRestServiceError', 'true') } } + +// Test small services +tasks.named('binlookup') { + doLast { + assert file("${layout.projectDirectory}/repo/src/binlookup/model_amount.go").exists() + assert !file("${layout.projectDirectory}/repo/src/binlookup/api_default.go").exists() + assert file("${layout.projectDirectory}/repo/src/binlookup/api_general.go").exists() + } +} +// Test services +tasks.named('checkout') { + doLast { + assert file("${layout.projectDirectory}/repo/src/checkout/model_amount.go").exists() + assert !file("${layout.projectDirectory}/repo/src/checkout/api_default.go").exists() + assert file("${layout.projectDirectory}/repo/src/checkout/api_donations.go").exists() + } +} +// Test webhooks +tasks.named('acswebhooks') { + doLast { + assert file("${layout.projectDirectory}/repo/src/acswebhook/model_amount.go").exists() + assert !file("${layout.projectDirectory}/repo/src/checkout/api_default.go").exists() + } +} From b164e4aa2357331668da2ae3db5f926c2a3ad1c5 Mon Sep 17 00:00:00 2001 From: Beppe Catanese Date: Mon, 11 Nov 2024 10:43:07 +0100 Subject: [PATCH 2/2] Minor edit in README --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index a859af6..9bc2f5d 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,12 @@ To generate all services in all libraries, run: ``` *Note:* Ensure that the service is in the following list: [`adyen.sdk-automation-conventions.gradle`](/buildSrc/src/main/groovy/adyen.sdk-automation-conventions.gradle). +For all services in a library, run: + +``` + ./gradlew :go:services + +``` For a single specific service: