Skip to content
This repository has been archived by the owner on Jan 4, 2024. It is now read-only.

Commit

Permalink
build: Move openapi tasks into buildSrc
Browse files Browse the repository at this point in the history
  • Loading branch information
Esteban Lopez Valecky committed Nov 11, 2023
1 parent c50a2ce commit a791c1c
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 60 deletions.
61 changes: 1 addition & 60 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import com.adyen.gradle.OpenApiGeneratorAuthorTemplateTask
import com.adyen.gradle.OpenApiGeneratorCloneSpec
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask

plugins {
// This plugin is defined as include build, but it could actually be externalized as plugin
// if there are common parts of it that can be re-used across other projects
`adyen-conventions`
`adyen-openapi-generator`

// Plugin for BND (OSGI), it is the counterpart for the maven-bundle-plugin
// I would like to use latest 7.0.0, but it requires minimum version of jvm to be 17
Expand Down Expand Up @@ -83,60 +80,4 @@ tasks {
gradleVersion = "latest"
distributionType = Wrapper.DistributionType.BIN
}

// --------------------
// Makefile alternative

// alt to: make templates
val authorTemplate = register<OpenApiGeneratorAuthorTemplateTask>("openapiAuthorTemplates") {
group = "Adyen OpenAPI Tools"
generator = "java"
library = "jersey3"
output = layout.buildDirectory.dir("templates")
}
// alt to: make target/spec
val cloneSpec = register<OpenApiGeneratorCloneSpec>("openapiCloneSpec") {
group = "Adyen OpenAPI Tools"
apiSpecRepo = "https://github.com/Adyen/adyen-openapi.git"
target = layout.buildDirectory.dir("spec")
}

// TODO: make a predefined list of models to generate and create subtasks from there

// alt to: make models
// where models is spec=BalanceControlService-v1
val models = register<GenerateTask>("openapiModelBalanceControlService-v1") {
dependsOn(cloneSpec)
group = "Adyen OpenAPI Tools"
inputSpec = cloneSpec.get().target.dir("json/BalanceControlService-v1.json").get().asFile.toString()
generatorName = "java"
templateDir = layout.projectDirectory.dir("templates").asFile.toString()
outputDir = layout.buildDirectory.dir("out").get().asFile.toString()
reservedWordsMappings = mapOf("configuration" to "configuration")
//ignoreFileOverride = ".openapi-generator-ignore"
skipValidateSpec = true
modelPackage = "com.adyen.model.balancecontrol"
library = "jersey3"
globalProperties = mapOf(
"modelDocs" to "false",
"modelTests" to "false"
)
inlineSchemaNameMappings = mapOf(
"PaymentRequest_paymentMethod" to "CheckoutPaymentMethod",
"DonationPaymentRequest_paymentMethod" to "DonationPaymentMethod"
)
additionalProperties = mapOf(
"dateLibrary" to "java8",
"openApiNullable" to false,
"resourceClass" to "$(resourceClass)Resource"
)
}

// alt to: make
register("openapiGenerator") {
group = "Adyen OpenAPI Tools"
dependsOn(authorTemplate, models)
}
// --------------------

}
60 changes: 60 additions & 0 deletions buildSrc/src/main/kotlin/adyen-openapi-generator.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import com.adyen.gradle.OpenApiGeneratorAuthorTemplateTask
import com.adyen.gradle.OpenApiGeneratorCloneSpec
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask

tasks {
// --------------------
// Makefile alternative

// alt to: make templates
val authorTemplate = register<OpenApiGeneratorAuthorTemplateTask>("openapiAuthorTemplates") {
group = "Adyen OpenAPI Tools"
generator = "java"
library = "jersey3"
output = layout.buildDirectory.dir("templates")
}
// alt to: make target/spec
val cloneSpec = register<OpenApiGeneratorCloneSpec>("openapiCloneSpec") {
group = "Adyen OpenAPI Tools"
apiSpecRepo = "https://github.com/Adyen/adyen-openapi.git"
target = layout.buildDirectory.dir("spec")
}

// TODO: make a predefined list of models to generate and create subtasks from there

// alt to: make models
// where models is spec=BalanceControlService-v1
val models = register<GenerateTask>("openapiModelBalanceControlService-v1") {
dependsOn(cloneSpec)
group = "Adyen OpenAPI Tools"
inputSpec = cloneSpec.get().target.dir("json/BalanceControlService-v1.json").get().asFile.toString()
generatorName = "java"
templateDir = layout.projectDirectory.dir("templates").asFile.toString()
outputDir = layout.buildDirectory.dir("out").get().asFile.toString()
reservedWordsMappings = mapOf("configuration" to "configuration")
//ignoreFileOverride = ".openapi-generator-ignore"
skipValidateSpec = true
modelPackage = "com.adyen.model.balancecontrol"
library = "jersey3"
globalProperties = mapOf(
"modelDocs" to "false",
"modelTests" to "false"
)
inlineSchemaNameMappings = mapOf(
"PaymentRequest_paymentMethod" to "CheckoutPaymentMethod",
"DonationPaymentRequest_paymentMethod" to "DonationPaymentMethod"
)
additionalProperties = mapOf(
"dateLibrary" to "java8",
"openApiNullable" to false,
"resourceClass" to "$(resourceClass)Resource"
)
}

// alt to: make
register("openapiGenerator") {
group = "Adyen OpenAPI Tools"
dependsOn(authorTemplate, models)
}
// --------------------
}

0 comments on commit a791c1c

Please sign in to comment.