From a42b5abcbb1bea0b20374500a2a294f31de1927a Mon Sep 17 00:00:00 2001 From: Fiete Ostkamp Date: Tue, 22 Aug 2023 09:58:20 +0000 Subject: Migrate away from legacy gradle buildscript syntax - replace the buildscript way of declaring plugins with the plugins {} block - have duplicate openapi client declarations since programmatic way of registering openapiGenerate task does not seem to be working Issue-ID: PORTALNG-47 Change-Id: I9e007127726e558363409d1b224dc7b2b9e52719 Signed-off-by: Fiete Ostkamp --- app/build.gradle | 76 +++++++++++++------------ build.gradle | 87 +++++------------------------ lib/build.gradle | 28 +++++++--- openapi/build.gradle | 19 +++++++ openapi/client-portal-history/build.gradle | 54 +++++++++++------- openapi/client-portal-keycloak/build.gradle | 56 +++++++++++-------- openapi/client-portal-prefs/build.gradle | 54 +++++++++++------- openapi/server/build.gradle | 16 +++++- settings.gradle | 6 +- 9 files changed, 210 insertions(+), 186 deletions(-) mode change 100755 => 100644 build.gradle create mode 100644 openapi/build.gradle diff --git a/app/build.gradle b/app/build.gradle index 6febc07..8faa791 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,26 +1,41 @@ plugins { - id 'application' - id 'org.springframework.boot' - id 'io.spring.dependency-management' - id 'com.gorylenko.gradle-git-properties' - id 'jacoco' + id 'java' + id 'org.springframework.boot' + id 'io.spring.dependency-management' + id 'com.gorylenko.gradle-git-properties' // commit information in actuator + id 'jacoco' // code coverage id 'com.diffplug.spotless' } -dependencyManagement { - imports { - mavenBom "org.springframework.cloud:spring-cloud-contract-dependencies:$springCloudVersion" - } +group = 'org.onap.portalng' + +java { + sourceCompatibility = JavaVersion.VERSION_17 +} + +configurations { + compileOnly { + extendsFrom annotationProcessor + } } +// repositories { +// mavenCentral() +// } + dependencies { - implementation project(':openapi:server') - implementation project(':openapi:client-portal-prefs') + implementation project(':openapi:server') implementation project(':openapi:client-portal-history') + implementation project(':openapi:client-portal-prefs') implementation project(':openapi:client-portal-keycloak') - - implementation project(':lib') - + implementation project(':lib') + + implementation 'org.springframework.boot:spring-boot-starter-webflux' + implementation 'org.springframework.boot:spring-boot-starter-actuator' + implementation 'org.springframework.boot:spring-boot-starter-validation' + implementation 'org.springframework.boot:spring-boot-starter-security' + implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' + implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server' implementation 'org.springframework.boot:spring-boot-starter-webflux' implementation 'org.springframework.boot:spring-boot-starter-actuator' implementation 'org.springframework.boot:spring-boot-starter-validation' @@ -37,39 +52,29 @@ dependencies { implementation "org.mapstruct.extensions.spring:mapstruct-spring-annotations:$mapStructExtensionsVersion" implementation "org.mapstruct.extensions.spring:mapstruct-spring-extensions:$mapStructExtensionsVersion" + implementation "org.springframework.boot:spring-boot-starter-logging" + implementation "net.logstash.logback:logstash-logback-encoder:$logbackVersion" + compileOnly "org.projectlombok:lombok:$lombokVersion" + annotationProcessor "org.projectlombok:lombok:$lombokVersion" + testCompileOnly "org.projectlombok:lombok:$lombokVersion" + testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion" + testImplementation 'io.projectreactor:reactor-test' - testImplementation 'org.springframework.cloud:spring-cloud-contract-wiremock' + testImplementation "org.springframework.cloud:spring-cloud-contract-wiremock:$wiremockVersion" testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'io.rest-assured:rest-assured' } -mainClassName = 'org.onap.portalng.bff.Application' - -bootJar { - launchScript() - enabled = true - excludes = ['**/application-local.yml', '**/application-development.yml', '**/log4j.xml'] -} - -springBoot { - buildInfo { - properties { - artifact = 'org-onap-portalng-bff' - version = getVersion() - group = rootProject.group - name = 'portal-ng backend for frontend' - } - } +tasks.named('test') { + useJUnitPlatform() } +test.finalizedBy jacocoTestReport jacocoTestReport { reports { xml.required = true } } -test.finalizedBy jacocoTestReport - -configurations.implementation.setCanBeResolved(true) spotless { java { @@ -78,7 +83,6 @@ spotless { googleJavaFormat('1.15.0') } } - tasks.withType(JavaCompile) { dependsOn 'spotlessApply' } \ No newline at end of file diff --git a/build.gradle b/build.gradle old mode 100755 new mode 100644 index 7a01578..e4eda6f --- a/build.gradle +++ b/build.gradle @@ -1,75 +1,18 @@ -import org.springframework.boot.gradle.plugin.SpringBootPlugin - -buildscript { - repositories { - mavenCentral() - maven { - url "https://plugins.gradle.org/m2/" - } - } - - ext { - springBootVersion = '2.7.3' - springCloudVersion = '3.1.3' - lombokVersion = '1.18.24' - openapiVersion = '6.6.0' - redocVersion = '2.0.0-rc.65' - spotlessVersion = '6.10.0' - spotbugsVersion = '5.0.10' - problemVersion = '0.27.1' - problemSpringVersion = '0.27.0' - logstashLogbackVersion = '7.2' - mapStructVersion = '1.5.2.Final' - mapStructExtensionsVersion = '0.1.2' - gorylenkoVersion= '2.4.1' - licenseVersion = '0.16.1' - shadowVersion = '7.1.2' - } - - dependencies { - classpath "com.diffplug.spotless:spotless-plugin-gradle:$spotlessVersion" - classpath "com.github.spotbugs.snom:spotbugs-gradle-plugin:$spotbugsVersion" - classpath "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion" - classpath "org.openapitools:openapi-generator-gradle-plugin:$openapiVersion" - classpath "com.gorylenko.gradle-git-properties:gradle-git-properties:$gorylenkoVersion" - classpath "gradle.plugin.com.hierynomus.gradle.plugins:license-gradle-plugin:$licenseVersion" - classpath "gradle.plugin.com.github.johnrengelman:shadow:$shadowVersion" - } -} - -group = 'org.onap' -version = rootProject.file('version').text.trim() - allprojects { - apply plugin: 'java' - apply plugin: 'idea' - apply plugin: 'io.spring.dependency-management' - - - sourceCompatibility = 17 - targetCompatibility = 17 - - dependencyManagement { - imports { - mavenBom SpringBootPlugin.BOM_COORDINATES - } - } - - repositories { - mavenCentral() - } - - test { - useJUnitPlatform() - } - - dependencies { - implementation "org.springframework.boot:spring-boot-starter-logging" - implementation "net.logstash.logback:logstash-logback-encoder:$logstashLogbackVersion" + repositories { + mavenCentral() + } +} - compileOnly "org.projectlombok:lombok:$lombokVersion" - annotationProcessor "org.projectlombok:lombok:$lombokVersion" - testCompileOnly "org.projectlombok:lombok:$lombokVersion" - testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion" - } +ext { + // app + lib + problemVersion = '0.27.1' + problemSpringVersion = '0.27.0' + mapStructVersion = '1.5.2.Final' + mapStructExtensionsVersion = '0.1.2' + logbackVersion = '7.2' + lombokVersion = '1.18.28' + + // app + wiremockVersion = '3.1.3' } \ No newline at end of file diff --git a/lib/build.gradle b/lib/build.gradle index bb4d9f5..48997c3 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -1,11 +1,11 @@ plugins { - id 'com.gorylenko.gradle-git-properties' - id 'jacoco' - id 'com.github.johnrengelman.shadow' - id 'maven-publish' - id 'java-library' - id 'com.diffplug.spotless' - id 'com.github.spotbugs' + id 'java' + id 'org.springframework.boot' + id 'io.spring.dependency-management' + id 'com.github.johnrengelman.shadow' // + id 'maven-publish' // publish lib jar to artifact repository + id 'com.diffplug.spotless' // code formatting + id 'com.github.spotbugs' // bug linting that can be picked up by IDE } group 'org.onap.portalng' @@ -33,6 +33,18 @@ dependencies { annotationProcessor "org.mapstruct:mapstruct-processor:$mapStructVersion" annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' + + compileOnly "org.projectlombok:lombok:$lombokVersion" + annotationProcessor "org.projectlombok:lombok:$lombokVersion" + testCompileOnly "org.projectlombok:lombok:$lombokVersion" + testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion" +} + +bootJar { + enabled = false +} +jar { + enabled = true } shadowJar { @@ -84,14 +96,12 @@ spotless { googleJavaFormat('1.15.0') } } - tasks.withType(JavaCompile) { dependsOn 'spotlessApply' } spotbugs { ignoreFailures = false - effort = "max" reportLevel = "high" excludeFilter = file("$rootProject.projectDir/spotbugs-exclude.xml") } \ No newline at end of file diff --git a/openapi/build.gradle b/openapi/build.gradle new file mode 100644 index 0000000..0b3e556 --- /dev/null +++ b/openapi/build.gradle @@ -0,0 +1,19 @@ +plugins { + id 'java' + id 'io.spring.dependency-management' +} + +dependencies { + implementation project('server') + implementation project('client-portal-history') + implementation project('client-portal-keycloak') + implementation project('client-portal-prefs') +} +ext { + openapiVersion = '7.0.0-beta' +} +subprojects { + repositories { + mavenCentral() + } +} \ No newline at end of file diff --git a/openapi/client-portal-history/build.gradle b/openapi/client-portal-history/build.gradle index e692169..4420d80 100644 --- a/openapi/client-portal-history/build.gradle +++ b/openapi/client-portal-history/build.gradle @@ -1,31 +1,17 @@ plugins { + id 'java' + id 'idea' + id 'org.springframework.boot' + id 'io.spring.dependency-management' id 'org.openapi.generator' } dependencies { - implementation "org.springframework.boot:spring-boot-starter-webflux" - implementation "org.openapitools:openapi-generator:$openapiVersion" + implementation 'org.springframework.boot:spring-boot-starter-webflux' + implementation "org.openapitools:openapi-generator:$openapiVersion" } -compileJava { - dependsOn = ['openApiGenerate_history'] -} - -sourceSets { - main { - java { - srcDirs += file("$buildDir/openapi/src/main/java") - } - } -} - -idea { - module { - generatedSourceDirs += file("$buildDir/openapi/src/main/java") - } -} - -tasks.register('openApiGenerate_history', org.openapitools.generator.gradle.plugin.tasks.GenerateTask) { +openApiGenerate { generatorName = "java" library = "webclient" inputSpec = "${project.projectDir}/src/portal_history_openapi.yaml" @@ -46,4 +32,30 @@ tasks.register('openApiGenerate_history', org.openapitools.generator.gradle.plug apiPackage = "org.onap.portalng.bff.openapi.client_portal_history.api" modelPackage = "org.onap.portalng.bff.openapi.client_portal_history.model" modelNameSuffix = "PortalHistoryDto" +} + +compileJava { + dependsOn tasks.openApiGenerate +} + +sourceSets { + main { + java { + srcDirs += file("$buildDir/openapi/src/main/java") + } + } +} + +idea { + module { + generatedSourceDirs += file("$buildDir/openapi/src/main/java") + } +} + +bootJar { + enabled = false +} + +jar { + enabled = true } \ No newline at end of file diff --git a/openapi/client-portal-keycloak/build.gradle b/openapi/client-portal-keycloak/build.gradle index 525fa18..d7984db 100644 --- a/openapi/client-portal-keycloak/build.gradle +++ b/openapi/client-portal-keycloak/build.gradle @@ -1,35 +1,21 @@ plugins { + id 'java' + id 'idea' + id 'org.springframework.boot' + id 'io.spring.dependency-management' id 'org.openapi.generator' } dependencies { - implementation "org.springframework.boot:spring-boot-starter-webflux" - implementation "org.openapitools:openapi-generator:$openapiVersion" + implementation 'org.springframework.boot:spring-boot-starter-webflux' + implementation "org.openapitools:openapi-generator:$openapiVersion" } -compileJava { - dependsOn = ['openApiGenerate_keycloak'] -} - -sourceSets { - main { - java { - srcDirs += file("$buildDir/openapi/src/main/java") - } - } -} - -idea { - module { - generatedSourceDirs += file("$buildDir/openapi/src/main/java") - } -} - -tasks.register('openApiGenerate_keycloak', org.openapitools.generator.gradle.plugin.tasks.GenerateTask) { +openApiGenerate { generatorName = "java" library = "webclient" inputSpec = "${project.projectDir}/src/portal_keycloak_openapi.yaml" - outputDir = "${buildDir}/openapi" + outputDir = "${project.buildDir}/openapi" configOptions = [ openApiNullable : "false", dateLibrary : "java8", @@ -46,4 +32,30 @@ tasks.register('openApiGenerate_keycloak', org.openapitools.generator.gradle.plu apiPackage = "org.onap.portalng.bff.openapi.client_portal_keycloak.api" modelPackage = "org.onap.portalng.bff.openapi.client_portal_keycloak.model" modelNameSuffix = "KeycloakDto" +} + +compileJava { + dependsOn tasks.openApiGenerate +} + +sourceSets { + main { + java { + srcDirs += file("$buildDir/openapi/src/main/java") + } + } +} + +idea { + module { + generatedSourceDirs += file("$buildDir/openapi/src/main/java") + } +} + +bootJar { + enabled = false +} + +jar { + enabled = true } \ No newline at end of file diff --git a/openapi/client-portal-prefs/build.gradle b/openapi/client-portal-prefs/build.gradle index cb7122a..3229244 100644 --- a/openapi/client-portal-prefs/build.gradle +++ b/openapi/client-portal-prefs/build.gradle @@ -1,31 +1,17 @@ plugins { + id 'java' + id 'idea' + id 'org.springframework.boot' + id 'io.spring.dependency-management' id 'org.openapi.generator' } dependencies { - implementation "org.springframework.boot:spring-boot-starter-webflux" - implementation "org.openapitools:openapi-generator:$openapiVersion" + implementation 'org.springframework.boot:spring-boot-starter-webflux' + implementation "org.openapitools:openapi-generator:$openapiVersion" } -compileJava { - dependsOn = ['openApiGenerate_preferences'] -} - -sourceSets { - main { - java { - srcDirs += file("$buildDir/openapi/src/main/java") - } - } -} - -idea { - module { - generatedSourceDirs += file("$buildDir/openapi/src/main/java") - } -} - -tasks.register('openApiGenerate_preferences', org.openapitools.generator.gradle.plugin.tasks.GenerateTask) { +openApiGenerate { generatorName = "java" library = "webclient" inputSpec = "${project.projectDir}/src/portal_prefs_openapi.yaml" @@ -46,4 +32,30 @@ tasks.register('openApiGenerate_preferences', org.openapitools.generator.gradle. apiPackage = "org.onap.portalng.bff.openapi.client_portal_prefs.api" modelPackage = "org.onap.portalng.bff.openapi.client_portal_prefs.model" modelNameSuffix = "PortalPrefsDto" +} + +compileJava { + dependsOn tasks.openApiGenerate +} + +sourceSets { + main { + java { + srcDirs += file("$buildDir/openapi/src/main/java") + } + } +} + +idea { + module { + generatedSourceDirs += file("$buildDir/openapi/src/main/java") + } +} + +bootJar { + enabled = false +} + +jar { + enabled = true } \ No newline at end of file diff --git a/openapi/server/build.gradle b/openapi/server/build.gradle index 6cdc456..017a618 100644 --- a/openapi/server/build.gradle +++ b/openapi/server/build.gradle @@ -1,11 +1,15 @@ plugins { + id 'java' + id 'idea' + id 'org.springframework.boot' + id 'io.spring.dependency-management' id 'org.openapi.generator' } dependencies { - implementation "org.springframework.boot:spring-boot-starter-webflux" + implementation 'org.springframework.boot:spring-boot-starter-webflux' implementation "org.openapitools:openapi-generator:$openapiVersion" - implementation "org.webjars:redoc:$redocVersion" + // implementation 'jakarta.validation:jakarta.validation-api:3.0.2' constraints { implementation('io.swagger.core.v3:swagger-annotations:2.2.5') { @@ -55,3 +59,11 @@ idea { generatedSourceDirs += file("$buildDir/openapi/src/main/java") } } + +bootJar { + enabled = false +} + +jar { + enabled = true +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index f64bf25..263c125 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,12 +3,12 @@ pluginManagement { // https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_version_management plugins { id 'io.spring.dependency-management' version '1.1.2' - id 'org.springframework.boot' version '3.1.2' + id 'org.springframework.boot' version '2.7.14' + id 'org.openapi.generator' version '7.0.0-beta' + id 'com.github.johnrengelman.shadow' version '7.1.2' id 'com.github.hierynomus.license' version '0.16.1' id 'com.gorylenko.gradle-git-properties' version '2.4.1' - id 'org.openapi.generator' version '7.0.0-beta' id 'com.diffplug.spotless' version '6.20.0' - id 'com.github.johnrengelman.shadow' version '7.1.2' id 'com.github.spotbugs' version '5.0.14' } // https://docs.gradle.org/current/userguide/plugins.html#sec:custom_plugin_repositories -- cgit 1.2.3-korg