Skip to content

Commit

Permalink
Merge pull request #36 from Adyen/update-php-generation
Browse files Browse the repository at this point in the history
Cleanup Models and Services before generation
  • Loading branch information
DjoykeAbyah authored Nov 18, 2024
2 parents a0f9db0 + 511f712 commit ce64250
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion php/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,24 @@ services.findAll({ !it.small }).each { Service svc ->
dependsOn "generate$svc.name"
outputs.upToDateWhen { false }

// Cleanup existing non-small Models and Services before generation
doFirst {
logger.lifecycle("Cleaning up existing files for $svc.name")
delete layout.projectDirectory.dir("repo/src/Adyen/Service/$svc.name")
delete layout.projectDirectory.dir("repo/src/Adyen/Model/$svc.name")
}

// Set the destination directory for copied files
into layout.projectDirectory.dir("repo/src/Adyen")
def sourcePath = "services/$svc.id/lib"

// Copy generated Model and Service PHP files
from(layout.buildDirectory.dir(sourcePath)) {
include "Model/**/*.php"
include "Service/**/*.php"
}

// Copy ObjectSerializer.php to the specific model directory
from(layout.buildDirectory.file("$sourcePath/ObjectSerializer.php")) {
into "Model/" + serviceNaming[svc.id]
}
Expand All @@ -60,6 +70,7 @@ services.findAll({ !it.small }).each { Service svc ->
tasks.named(svc.id) { dependsOn deploy }
}

// Deployment tasks for small services
smallServices.each { Service svc ->
def serviceName = serviceNaming[svc.id]
def deploy = tasks.register("deploy$svc.name", Copy) {
Expand Down Expand Up @@ -121,4 +132,4 @@ tasks.named('payment') {
assert file("${layout.projectDirectory}/repo/src/Adyen/Model/Payments/ObjectSerializer.php").exists()
assert file("${layout.projectDirectory}/repo/src/Adyen/Service/Payments/PaymentsApi.php").exists()
}
}
}

0 comments on commit ce64250

Please sign in to comment.