Skip to content

Commit

Permalink
Deploy .NET
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelpaul committed Dec 8, 2023
1 parent c676132 commit 384986b
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ ext {
removeTags = true
}

project.ext.smallServices = project.ext.services.findAll { it.small }
def services = project.ext.services as List<Service>

ext {
smallServices = services.findAll { it.small }
serviceNaming = services.collectEntries { [it.id, it.name] }
}

// Generate a full client for each service
project.ext.services.each { Service svc ->
Expand Down
54 changes: 54 additions & 0 deletions dotnet/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask

plugins {
id 'adyen.sdk-automation-conventions'
}
Expand All @@ -6,3 +8,55 @@ project.ext {
generator = 'csharp-netcore'
templates = 'templates/csharp'
}

def services = project.ext.services as List<Service>

services.each { Service svc ->
def serviceName = project.ext.serviceNaming[svc.id] as String

// Generation
tasks.named("generate${svc.name}", GenerateTask) {
apiPackage.set(svc.small ? 'Service' : "Service.${svc.name}")
apiNameSuffix.set('Service')
modelPackage.set("Model.${svc.name}")
reservedWordsMappings.put('Version', 'Version')
additionalProperties.putAll([
'packageName': 'Adyen',
'serviceName': serviceName,
])
}

// Deployment
def deployModels = tasks.register("deploy${svc.name}Models", Sync) {
description "Deploy $svc.name models into the repo."
dependsOn "generate$svc.name"
outputs.upToDateWhen { false }

from layout.buildDirectory.dir("services/$svc.id/src/Adyen/Model.${serviceName}")
into layout.projectDirectory.dir("repo/Adyen/Model/" + serviceName)
}

def deployServices = tasks.register("deploy${svc.name}Services", Sync) {
description "Deploy $svc.name into the repo."
dependsOn "generate$svc.name"
outputs.upToDateWhen { false }

from layout.buildDirectory.dir("services/$svc.id/src/Adyen/Service.${serviceName}")
into layout.projectDirectory.dir("repo/Adyen/Service/" + serviceName)
}

def deploySmallService = tasks.register("deploy${svc.name}SmallService", Copy) {
description "Copy $svc.name into the repo."
dependsOn "generate$svc.name"
outputs.upToDateWhen { false }

from layout.buildDirectory.file("services/$svc.id/src/Adyen/Service/DefaultService.cs")
rename 'DefaultService.cs', "${serviceName}Service.cs"
filter {
it.replace('DefaultService', "${serviceName}Service")
}
into layout.projectDirectory.dir("repo/Adyen/Service")
}

tasks.named(svc.id) { dependsOn deployModels, deployServices, deploySmallService }
}

0 comments on commit 384986b

Please sign in to comment.