From 39290a0ae57ed1d326e86538e1923b4bf4bbb2fb Mon Sep 17 00:00:00 2001 From: Petri Tuomola Date: Tue, 18 Aug 2020 21:46:37 +0300 Subject: [PATCH] FINERACT-1082: Changing version from hardcoded to autogenerated for Swagger --- fineract-provider/build.gradle | 34 ++++++++++++++++++- .../{config.json => config.json.template} | 2 +- ...nput.yaml => fineract-input.yaml.template} | 2 +- 3 files changed, 35 insertions(+), 3 deletions(-) rename fineract-provider/config/swagger/{config.json => config.json.template} (90%) rename fineract-provider/config/swagger/{fineract-input.yaml => fineract-input.yaml.template} (98%) diff --git a/fineract-provider/build.gradle b/fineract-provider/build.gradle index f73d54af5..18236d7c8 100644 --- a/fineract-provider/build.gradle +++ b/fineract-provider/build.gradle @@ -195,6 +195,20 @@ openjpa { // Configuration for Swagger documentation generation task // https://github.com/swagger-api/swagger-core/tree/master/modules/swagger-gradle-plugin +import org.apache.tools.ant.filters.ReplaceTokens + +task prepareInputYaml(dependsOn: 'generateGitProperties') { + doLast { + copy { + from file('config/swagger/fineract-input.yaml.template') + into file('config/swagger') + rename { String filename -> return 'fineract-input.yaml' } + filter(ReplaceTokens, tokens: [VERSION: project.ext.gitProps['git.commit.id.describe']]) + } + } +} + + resolve { logging.captureStandardOutput LogLevel.INFO outputFileName = 'fineract' @@ -205,6 +219,8 @@ resolve { openApiFile = file("config/swagger/fineract-input.yaml") } +resolve.dependsOn prepareInputYaml + // Configuration for JaCoCo code coverage task // https://www.eclemma.org/jacoco/ jacoco { @@ -290,6 +306,7 @@ rat { '**/*.github/**', '**/MANIFEST.MF', '**/*.json', + '**/*.json.template', '**/*.txt', '**/*.log', '**/fineractdev-eclipse-preferences.epf', @@ -846,16 +863,29 @@ gitProperties { dateFormat = "yyyy-MM-dd'T'HH:mmZ" dateFormatTimeZone = "GMT" failOnNoGitDirectory = false + extProperty = 'gitProps' } // make sure the generateGitProperties task always executes (even when git.properties is not changed) generateGitProperties.outputs.upToDateWhen { false } -//This is for swagger code generation +// This is for swagger code generation +// https://github.com/int128/gradle-swagger-generator-plugin dependencies { swaggerCodegen 'io.swagger.codegen.v3:swagger-codegen-cli:3.0.18' } +task prepareConfigJson(dependsOn: 'generateGitProperties') { + doLast { + copy { + from file('config/swagger/config.json.template') + into file('config/swagger') + rename { String filename -> return 'config.json' } + filter(ReplaceTokens, tokens: [VERSION: project.ext.gitProps['git.commit.id.describe']]) + } + } +} + swaggerSources { fineract { inputFile = file('../build/classes/java/main/static/swagger-ui/fineract.yaml') @@ -865,3 +895,5 @@ swaggerSources { } } } + +generateSwaggerCodeFineract.dependsOn prepareConfigJson diff --git a/fineract-provider/config/swagger/config.json b/fineract-provider/config/swagger/config.json.template similarity index 90% rename from fineract-provider/config/swagger/config.json rename to fineract-provider/config/swagger/config.json.template index 9c78730f8..1b9f4cb7f 100644 --- a/fineract-provider/config/swagger/config.json +++ b/fineract-provider/config/swagger/config.json.template @@ -1,7 +1,7 @@ { "groupId": "org.apache.fineract", "artifactId": "client", - "artifactVersion": "1.4.0", + "artifactVersion": "@VERSION@", "invokerPackage": "org.apache.fineract.client", "modelPackage": "org.apache.fineract.client.models", "apiPackage": "org.apache.fineract.client.services", diff --git a/fineract-provider/config/swagger/fineract-input.yaml b/fineract-provider/config/swagger/fineract-input.yaml.template similarity index 98% rename from fineract-provider/config/swagger/fineract-input.yaml rename to fineract-provider/config/swagger/fineract-input.yaml.template index 878d71157..20b2fb796 100644 --- a/fineract-provider/config/swagger/fineract-input.yaml +++ b/fineract-provider/config/swagger/fineract-input.yaml.template @@ -1,6 +1,6 @@ openapi: 3.0.3 info: - version: 1.4.0 + version: @VERSION@ title: Apache Fineract description: |- Apache Fineract is a secure, multi-tenanted microfinance platform