From eb24972337e640c9f30e975eee2e6fb60ce0a9f4 Mon Sep 17 00:00:00 2001 From: farrell-m Date: Mon, 20 May 2024 10:57:00 +0100 Subject: [PATCH 1/4] use common library --- build.gradle | 37 +------------------------------------ caab-api/build.gradle | 15 +++------------ caab-service/build.gradle | 33 +-------------------------------- settings.gradle | 15 +++++++++++++++ 4 files changed, 20 insertions(+), 80 deletions(-) diff --git a/build.gradle b/build.gradle index c2d53ab..b5fa006 100644 --- a/build.gradle +++ b/build.gradle @@ -1,42 +1,7 @@ plugins { - id 'java' - id 'io.spring.dependency-management' version '1.1.5' - id 'net.researchgate.release' version '3.0.2' + id 'uk.gov.laa.ccms.springboot.laa-ccms-spring-boot-gradle-plugin' version '0.0.1-b144207-SNAPSHOT' apply false } subprojects { - apply plugin: 'java' - apply plugin: 'io.spring.dependency-management' - group = 'uk.gov.laa.ccms.caab' - - java { - toolchain { - languageVersion = JavaLanguageVersion.of(JAVA_VERSION) - } - } - - repositories { - mavenCentral() - } - - release { - tagTemplate = '$name-$version' - } -} - -//used for deploying snapshot packages -task updateSnapshotVersion { - doLast { - def gitHash = "git rev-parse --short HEAD".execute().text.trim() - def propertiesFile = file('gradle.properties') - def properties = new Properties() - properties.load(new FileInputStream(propertiesFile)) - - def currentVersion = properties.getProperty('version') - def newVersion = currentVersion.replace('-SNAPSHOT', "-${gitHash}-SNAPSHOT") - properties.setProperty('version', newVersion) - - properties.store(propertiesFile.newWriter(), null) - } } diff --git a/caab-api/build.gradle b/caab-api/build.gradle index f90cf78..048b4ef 100644 --- a/caab-api/build.gradle +++ b/caab-api/build.gradle @@ -1,9 +1,8 @@ plugins { id 'org.openapi.generator' version '7.0.1' - id 'org.springframework.boot' version '3.1.0' } -apply plugin: "maven-publish" +apply plugin: 'uk.gov.laa.ccms.springboot.laa-ccms-spring-boot-gradle-plugin' dependencies { @@ -19,16 +18,6 @@ dependencies { } publishing { - repositories { - maven { - name = "GitHubPackages" - url 'https://maven.pkg.github.com/ministryofjustice/laa-ccms-caab-api' - credentials { - username = System.getenv("GITHUB_ACTOR") - password = System.getenv("GITHUB_TOKEN") - } - } - } publications { gpr(MavenPublication) { from(components.java) @@ -38,6 +27,8 @@ publishing { sourceSets.main.java.srcDirs += ['generated/src/main/java'] +checkstyleMain.exclude "*" + openApiGenerate { generatorName = "spring" inputSpec = "$rootDir/caab-api/open-api-specification.yml".toString() // Change this to the location of your OpenAPI specification diff --git a/caab-service/build.gradle b/caab-service/build.gradle index 77824f2..c6e816f 100644 --- a/caab-service/build.gradle +++ b/caab-service/build.gradle @@ -1,12 +1,4 @@ -plugins { - id 'org.springframework.boot' version '3.2.5' - id 'jacoco' - id 'checkstyle' -} - -ext { - checkstyleVersion = '10.12.2' -} +apply plugin: 'uk.gov.laa.ccms.springboot.laa-ccms-spring-boot-gradle-plugin' sourceSets { integrationTest { @@ -65,7 +57,6 @@ task integrationTest(type: Test) { } jacocoTestReport { - sourceDirectories.from files('build/generated/sources/annotationProcessor/java/main') afterEvaluate { classDirectories.setFrom(files(classDirectories.files.collect { fileTree(dir: it, exclude: [ @@ -74,12 +65,9 @@ jacocoTestReport { '**/AuditorAwareImpl.class']) })) } - - dependsOn tasks['test'] } jacocoTestCoverageVerification { - afterEvaluate { classDirectories.setFrom(files(classDirectories.files.collect { fileTree(dir: it, exclude: [ @@ -88,23 +76,4 @@ jacocoTestCoverageVerification { '**/AuditorAwareImpl.class']) })) } - - violationRules { - rule { - limit { - minimum = 0.80 // You can define your required coverage ratio here. - } - } - } - - dependsOn tasks['test'] -} - -checkstyle { - maxWarnings = 0 - toolVersion = "${checkstyleVersion}" - sourceSets = [sourceSets.main] - showViolations = true } - - diff --git a/settings.gradle b/settings.gradle index 4003a92..e6dd1ee 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,18 @@ +pluginManagement { + repositories { + maven { + name = "gitHubPackages" + url uri('https://maven.pkg.github.com/ministryofjustice/laa-ccms-spring-boot-common') + credentials { + username = System.getenv("GITHUB_ACTOR")?.trim() ? System.getenv("GITHUB_ACTOR") : settings.ext.find('project.ext.gitPackageUser') + password = System.getenv("GITHUB_TOKEN")?.trim() ? System.getenv("GITHUB_TOKEN") : settings.ext.find('project.ext.gitPackageKey') + } + } + maven { url "https://plugins.gradle.org/m2/" } + gradlePluginPortal() + } +} + rootProject.name = 'laa-ccms-caab-api' include 'caab-api' From b1c06c1bf53a73bd06f62ad4915f9bd9bce93042 Mon Sep 17 00:00:00 2001 From: farrell-m Date: Mon, 20 May 2024 11:25:39 +0100 Subject: [PATCH 2/4] add github token to pipeline --- .github/workflows/on-tag.yml | 2 ++ .github/workflows/pr-merge-main.yml | 2 ++ .github/workflows/push-branch.yml | 2 ++ 3 files changed, 6 insertions(+) diff --git a/.github/workflows/on-tag.yml b/.github/workflows/on-tag.yml index dc5dc02..1c3e317 100644 --- a/.github/workflows/on-tag.yml +++ b/.github/workflows/on-tag.yml @@ -44,6 +44,8 @@ jobs: uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629 with: arguments: build + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Test uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629 diff --git a/.github/workflows/pr-merge-main.yml b/.github/workflows/pr-merge-main.yml index 1d5e012..ce71c88 100644 --- a/.github/workflows/pr-merge-main.yml +++ b/.github/workflows/pr-merge-main.yml @@ -35,6 +35,8 @@ jobs: uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629 with: arguments: build + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Test uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629 diff --git a/.github/workflows/push-branch.yml b/.github/workflows/push-branch.yml index 35dab8c..c6f020a 100644 --- a/.github/workflows/push-branch.yml +++ b/.github/workflows/push-branch.yml @@ -30,6 +30,8 @@ jobs: uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629 with: arguments: build + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Test uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629 From ad42753834afc2165b962c20c26aed0f9fe68b11 Mon Sep 17 00:00:00 2001 From: farrell-m Date: Mon, 20 May 2024 14:52:53 +0100 Subject: [PATCH 3/4] remove integrationTest task setup, cleanup --- build.gradle | 2 +- caab-service/build.gradle | 25 ------------------------- gradle.properties | 2 -- settings.gradle | 4 ++-- 4 files changed, 3 insertions(+), 30 deletions(-) diff --git a/build.gradle b/build.gradle index b5fa006..7fb5c32 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'uk.gov.laa.ccms.springboot.laa-ccms-spring-boot-gradle-plugin' version '0.0.1-b144207-SNAPSHOT' apply false + id 'uk.gov.laa.ccms.springboot.laa-ccms-spring-boot-gradle-plugin' version '0.0.1-d85b520-SNAPSHOT' apply false } subprojects { diff --git a/caab-service/build.gradle b/caab-service/build.gradle index c6e816f..810950d 100644 --- a/caab-service/build.gradle +++ b/caab-service/build.gradle @@ -1,22 +1,5 @@ apply plugin: 'uk.gov.laa.ccms.springboot.laa-ccms-spring-boot-gradle-plugin' -sourceSets { - integrationTest { - java { - compileClasspath += main.output + test.output - runtimeClasspath += main.output + test.output - } - } -} - -configurations { - compileOnly { - extendsFrom annotationProcessor - } - integrationTestImplementation.extendsFrom(testImplementation) - integrationTestRuntimeOnly.extendsFrom(testRuntimeOnly) -} - dependencies { implementation project(':caab-api') @@ -48,14 +31,6 @@ test { useJUnitPlatform() } -task integrationTest(type: Test) { - useJUnitPlatform() - description = "Run integration tests" - group = "verification" - testClassesDirs = sourceSets.integrationTest.output.classesDirs - classpath = sourceSets.integrationTest.runtimeClasspath -} - jacocoTestReport { afterEvaluate { classDirectories.setFrom(files(classDirectories.files.collect { diff --git a/gradle.properties b/gradle.properties index 501e756..90ff605 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,2 @@ version=0.0.25-SNAPSHOT group='uk.gov.laa.ccms' - -JAVA_VERSION = 21 \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index e6dd1ee..e70febf 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,8 +4,8 @@ pluginManagement { name = "gitHubPackages" url uri('https://maven.pkg.github.com/ministryofjustice/laa-ccms-spring-boot-common') credentials { - username = System.getenv("GITHUB_ACTOR")?.trim() ? System.getenv("GITHUB_ACTOR") : settings.ext.find('project.ext.gitPackageUser') - password = System.getenv("GITHUB_TOKEN")?.trim() ? System.getenv("GITHUB_TOKEN") : settings.ext.find('project.ext.gitPackageKey') + username = System.getenv("GITHUB_ACTOR")?.trim() ?: settings.ext.find('project.ext.gitPackageUser') + password = System.getenv("GITHUB_TOKEN")?.trim() ?: settings.ext.find('project.ext.gitPackageKey') } } maven { url "https://plugins.gradle.org/m2/" } From 538823ceed131af411bc3f17ebdc9a6cd3688158 Mon Sep 17 00:00:00 2001 From: farrell-m Date: Wed, 22 May 2024 09:42:36 +0100 Subject: [PATCH 4/4] bump to release version --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 7fb5c32..644b953 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'uk.gov.laa.ccms.springboot.laa-ccms-spring-boot-gradle-plugin' version '0.0.1-d85b520-SNAPSHOT' apply false + id 'uk.gov.laa.ccms.springboot.laa-ccms-spring-boot-gradle-plugin' version '0.0.1' apply false } subprojects {