From 28c27694961f09d0ce5bd88129c64bd63d497d15 Mon Sep 17 00:00:00 2001 From: Nikita Smirnov <46124551+Nikita-Smirnov-Exactpro@users.noreply.github.com> Date: Wed, 1 May 2024 15:06:34 +0400 Subject: [PATCH] Migrated to th2 gradle plugin: `0.0.6` (#17) * Migrated to release version codec:5.5.0-dev --- ...e-and-docker.yml => build-dev-release.yml} | 17 ++-- .github/workflows/build-release.yml | 19 ++++ .github/workflows/build-sanpshot.yml | 24 +++++ .github/workflows/dev-docker-publish.yml | 19 ---- .github/workflows/docker-publish.yml | 20 ---- README.md | 11 ++- build.gradle | 91 ++++--------------- gradle.properties | 2 +- .../com/exactpro/th2/codec/http/DecodeTest.kt | 6 +- suppressions.xml | 6 ++ 10 files changed, 90 insertions(+), 125 deletions(-) rename .github/workflows/{dev-release-java-publish-sonatype-and-docker.yml => build-dev-release.yml} (59%) create mode 100644 .github/workflows/build-release.yml create mode 100644 .github/workflows/build-sanpshot.yml delete mode 100644 .github/workflows/dev-docker-publish.yml delete mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/dev-release-java-publish-sonatype-and-docker.yml b/.github/workflows/build-dev-release.yml similarity index 59% rename from .github/workflows/dev-release-java-publish-sonatype-and-docker.yml rename to .github/workflows/build-dev-release.yml index e515f3a..6cc5c82 100644 --- a/.github/workflows/dev-release-java-publish-sonatype-and-docker.yml +++ b/.github/workflows/build-dev-release.yml @@ -1,22 +1,19 @@ -name: Build and release Java distributions to sonatype. +name: Build and publish dev release Docker image to Github Container Registry ghcr.io and publish dev release jar to sonatype -on: - push: - tags: - - \d+.\d+.\d+-dev +on: workflow_dispatch jobs: build: uses: th2-net/.github/.github/workflows/compound-java.yml@main with: - build-target: 'Docker' - runsOn: ubuntu-latest - gradleVersion: '7' - docker-username: ${{ github.actor }} + build-target: 'Sonatype,Docker' devRelease: true + createTag: true + docker-username: ${{ github.actor }} secrets: + docker-password: ${{ secrets.GITHUB_TOKEN }} sonatypeUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }} sonatypePassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} sonatypeSigningKey: ${{ secrets.SONATYPE_GPG_ARMORED_KEY }} sonatypeSigningPassword: ${{ secrets.SONATYPE_SIGNING_PASSWORD }} - docker-password: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + nvd-api-key: ${{ secrets.NVD_APIKEY }} \ No newline at end of file diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml new file mode 100644 index 0000000..9251e4e --- /dev/null +++ b/.github/workflows/build-release.yml @@ -0,0 +1,19 @@ +name: Build and publish release Docker image to Github Container Registry ghcr.io and publish release jar to sonatype + +on: workflow_dispatch + +jobs: + build: + uses: th2-net/.github/.github/workflows/compound-java.yml@main + with: + build-target: 'Sonatype,Docker' + devRelease: false + createTag: true + docker-username: ${{ github.actor }} + secrets: + docker-password: ${{ secrets.GITHUB_TOKEN }} + sonatypeUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }} + sonatypePassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} + sonatypeSigningKey: ${{ secrets.SONATYPE_GPG_ARMORED_KEY }} + sonatypeSigningPassword: ${{ secrets.SONATYPE_SIGNING_PASSWORD }} + nvd-api-key: ${{ secrets.NVD_APIKEY }} \ No newline at end of file diff --git a/.github/workflows/build-sanpshot.yml b/.github/workflows/build-sanpshot.yml new file mode 100644 index 0000000..fc014bf --- /dev/null +++ b/.github/workflows/build-sanpshot.yml @@ -0,0 +1,24 @@ +name: Build and publish Docker image to Github Container Registry ghcr.io and publish snapshot jar to sonatype + +on: + push: + branches-ignore: + - master + - version-* + - dependabot** + paths-ignore: + - README.md + +jobs: + build-job: + uses: th2-net/.github/.github/workflows/compound-java-dev.yml@main + with: + build-target: 'Sonatype,Docker' + docker-username: ${{ github.actor }} + secrets: + docker-password: ${{ secrets.GITHUB_TOKEN }} + sonatypeUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }} + sonatypePassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} + sonatypeSigningKey: ${{ secrets.SONATYPE_GPG_ARMORED_KEY }} + sonatypeSigningPassword: ${{ secrets.SONATYPE_SIGNING_PASSWORD }} + nvd-api-key: ${{ secrets.NVD_APIKEY }} \ No newline at end of file diff --git a/.github/workflows/dev-docker-publish.yml b/.github/workflows/dev-docker-publish.yml deleted file mode 100644 index 6f77755..0000000 --- a/.github/workflows/dev-docker-publish.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Dev build and publish Docker distributions to Github Container Registry ghcr.io - -on: - push: - branches-ignore: - - master - - version-* - - dependabot** - paths-ignore: - - README.md - -jobs: - build-job: - uses: th2-net/.github/.github/workflows/compound-java-dev.yml@main - with: - build-target: 'Docker' - docker-username: ${{ github.actor }} - secrets: - docker-password: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml deleted file mode 100644 index cec50a6..0000000 --- a/.github/workflows/docker-publish.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Build and publish Docker distributions to Github Container Registry ghcr.io - -on: - push: - branches: - - master - - version-* - paths: - - gradle.properties -# - package_info.json - -jobs: - build-job: - uses: th2-net/.github/.github/workflows/compound-java.yml@main - with: - build-target: 'Docker' - docker-username: ${{ github.actor }} - secrets: - docker-password: ${{ secrets.GITHUB_TOKEN }} - \ No newline at end of file diff --git a/README.md b/README.md index cc401ce..74c19f3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# HTTP Codec v0.4.0 +# HTTP Codec v0.5.0 This microservice can encode and decode HTTP messages @@ -122,6 +122,15 @@ spec: # Release notes +## 0.5.0 ++ Migrated to th2 gradle plugin: `0.0.6` ++ Updated: + + bom `4.6.1` + + common: `5.10.1-dev` + + common-utils: `2.2.3-dev` + + codec: `5.5.0-dev` + + rawhttp-core: `2.6.0` + ## 0.4.0 + th2 transport protocol support diff --git a/build.gradle b/build.gradle index 9155ccd..ad90728 100644 --- a/build.gradle +++ b/build.gradle @@ -1,16 +1,19 @@ plugins { - id 'com.palantir.docker' version '0.25.0' - id 'org.jetbrains.kotlin.jvm' version "${kotlin_version}" - id 'application' - id 'org.jetbrains.kotlin.kapt' version "${kotlin_version}" - id "org.owasp.dependencycheck" version "8.2.1" + id "org.jetbrains.kotlin.jvm" version "$kotlin_version" + id "org.jetbrains.kotlin.kapt" version "$kotlin_version" + id("java-library") + id("maven-publish") + + id "com.exactpro.th2.gradle.publish" version "0.0.6" + id "com.exactpro.th2.gradle.component" version "0.0.6" } group = 'com.exactpro.th2' version = release_version -sourceCompatibility = 11 -targetCompatibility = 11 +kotlin { + jvmToolchain(11) +} repositories { mavenCentral() @@ -30,85 +33,31 @@ repositories { } } -jar { - manifest { - attributes( - 'Created-By': "${System.getProperty('java.version')} (${System.getProperty('java.vendor')})", - 'Specification-Title': '', - 'Specification-Vendor': 'Exactpro Systems LLC', - 'Implementation-Title': project.archivesBaseName, - 'Implementation-Vendor': 'Exactpro Systems LLC', - 'Implementation-Vendor-Id': 'com.exactpro', - 'Implementation-Version': project.version - ) - } -} - dependencies { - api platform("com.exactpro.th2:bom:4.5.0") - - implementation "com.exactpro.th2:common:5.7.2-dev" - implementation "com.exactpro.th2:common-utils:2.2.2-dev" - implementation "com.exactpro.th2:codec:5.4.1-dev" + implementation "com.exactpro.th2:common:5.10.1-dev" + implementation "com.exactpro.th2:common-utils:2.2.3-dev" + implementation "com.exactpro.th2:codec:5.5.0-dev" compileOnly "com.google.auto.service:auto-service:1.1.1" - annotationProcessor "com.google.auto.service:auto-service:1.1.1" kapt "com.google.auto.service:auto-service:1.1.1" implementation "io.github.microutils:kotlin-logging:3.0.5" - implementation "com.athaydes.rawhttp:rawhttp-core:2.4.1" + implementation "com.athaydes.rawhttp:rawhttp-core:2.6.0" - testImplementation "org.jetbrains.kotlin:kotlin-test-junit5" - testImplementation "org.junit.jupiter:junit-jupiter:5.10.0" + testImplementation "org.jetbrains.kotlin:kotlin-test-junit" + testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2' + testImplementation 'org.mockito.kotlin:mockito-kotlin:5.3.1' + testImplementation 'io.strikt:strikt-core:0.34.1' } application { - mainClassName 'com.exactpro.th2.codec.MainKt' -} - -applicationName = 'service' - -distTar { - archiveName "${applicationName}.tar" -} - -dockerPrepare { - dependsOn distTar -} - -docker { - copySpec.from(tarTree("$buildDir/distributions/${applicationName}.tar")) -} - -compileKotlin { - kotlinOptions { - jvmTarget = "11" - } -} - -compileTestKotlin { - kotlinOptions { - jvmTarget = "11" - } + mainClass.set("com.exactpro.th2.codec.MainKt") } test { useJUnitPlatform() } -configurations { - compileClasspath { - resolutionStrategy.activateDependencyLocking() - } -} - dependencyCheck { - formats = ['SARIF', 'JSON', 'HTML'] - failBuildOnCVSS = 5 suppressionFile = file('suppressions.xml') - analyzers { - assemblyEnabled = false - nugetconfEnabled = false - nodeEnabled = false - } -} +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 2412c75..6403218 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ kotlin.code.style=official kotlin_version=1.8.22 -release_version=0.4.0 +release_version=0.5.0 diff --git a/src/test/kotlin/com/exactpro/th2/codec/http/DecodeTest.kt b/src/test/kotlin/com/exactpro/th2/codec/http/DecodeTest.kt index 186d996..5b4b27c 100644 --- a/src/test/kotlin/com/exactpro/th2/codec/http/DecodeTest.kt +++ b/src/test/kotlin/com/exactpro/th2/codec/http/DecodeTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2020-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -123,7 +123,7 @@ class DecodeTest { assertEquals(3, decodedBody.size) assertEquals(200, decodedBody["statusCode"]) assertEquals("OK", decodedBody["reason"]) - val decodedHeaders = decodedBody["headers"] as Map + val decodedHeaders = decodedBody["headers"] as Map<*, *> assertEquals(2, decodedHeaders.size) assertEquals("text/plain", decodedHeaders["Content-Type"]) assertEquals("0", decodedHeaders["Content-Length"]) @@ -165,7 +165,7 @@ class DecodeTest { assertEquals("Request", decodedMessage.type) assertEquals("GET", decodedBody["method"]) assertEquals(URI("http://www.test.com/hello.txt"), decodedBody["uri"]) - val decodedHeaders = decodedBody["headers"] as Map + val decodedHeaders = decodedBody["headers"] as Map<*, *> assertEquals(3, decodedHeaders.size) assertEquals("OpenSSL/0.9.7l", decodedHeaders["User-Agent"]) assertEquals("www.test.com", decodedHeaders["Host"]) diff --git a/suppressions.xml b/suppressions.xml index 52da5f2..06f5763 100644 --- a/suppressions.xml +++ b/suppressions.xml @@ -1,5 +1,11 @@ + + + + ^pkg:maven/com\.exactpro\.th2/grpc-.*@.*$ + cpe:/a:grpc:grpc +