diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 41745a4..914eb79 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -81,6 +81,8 @@ jobs: uses: th2-net/.github/.github/workflows/owasp-gradle-scan.yml@main with: multiproject: true + secrets: + nvd-api-key: ${{ secrets.NVD_APIKEY }} publish-docker: name: Build and publish docker image if: | diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml index cae73dd..12e3d01 100644 --- a/.github/workflows/dev-build.yml +++ b/.github/workflows/dev-build.yml @@ -60,6 +60,8 @@ jobs: uses: th2-net/.github/.github/workflows/owasp-gradle-scan.yml@main with: multiproject: true + secrets: + nvd-api-key: ${{ secrets.NVD_APIKEY }} publish-docker: name: Build docker image needs: diff --git a/.github/workflows/dev-release-java-publish-sonatype-and-docker.yml b/.github/workflows/dev-release-java-publish-sonatype-and-docker.yml index b2bfeba..d26dab2 100644 --- a/.github/workflows/dev-release-java-publish-sonatype-and-docker.yml +++ b/.github/workflows/dev-release-java-publish-sonatype-and-docker.yml @@ -117,14 +117,14 @@ jobs: ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SONATYPE_GPG_ARMORED_KEY }} ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SONATYPE_SIGNING_PASSWORD }} - owasp-scan: needs: - build-and-publish-core-java uses: th2-net/.github/.github/workflows/owasp-gradle-scan.yml@main with: multiproject: true - + secrets: + nvd-api-key: ${{ secrets.NVD_APIKEY }} publish-docker: name: Build and publish docker image needs: diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index 63e51f9..0000000 --- a/app/build.gradle +++ /dev/null @@ -1,68 +0,0 @@ -plugins { - id 'org.jetbrains.kotlin.jvm' - id 'application' - id 'com.palantir.docker' version '0.25.0' -} - -apply from: '../common.gradle' - -sourceCompatibility = 11 -targetCompatibility = 11 - -configurations.configureEach { - resolutionStrategy.cacheChangingModulesFor 0, 'seconds' - resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds' -} - -dependencies { - implementation project(':read-db-core') - - //region Drivers - runtimeOnly('org.postgresql:postgresql:42.6.0') { - because('prostresql support') - } - runtimeOnly('com.mysql:mysql-connector-j:8.1.0') { - because('mysql support') - } - runtimeOnly('com.oracle.database.jdbc:ojdbc11:23.2.0.0') { - because('oracle support') - } - runtimeOnly('com.microsoft.sqlserver:mssql-jdbc:12.4.0.jre11') { - because('mssql support') - } - //endregion -} - -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 - ) - } -} - -applicationName = 'service' - -distTar { - archiveFileName.set("${applicationName}.tar") -} - -dockerPrepare { - dependsOn distTar -} - -docker { - copySpec.from(tarTree("$buildDir/distributions/${applicationName}.tar")) -} - -application { - mainClass.set("com.exactpro.th2.read.db.bootstrap.Main") -} - -tasks.withType(PublishToMavenRepository).configureEach {it.enabled = false} \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..299f507 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,33 @@ +plugins { + id("application") + id("com.exactpro.th2.gradle.component") +} + +configurations.all { + resolutionStrategy.cacheChangingModulesFor(0, "seconds") + resolutionStrategy.cacheDynamicVersionsFor(0, "seconds") +} + +dependencies { + implementation(project(":read-db-core")) + + //region Drivers + runtimeOnly("org.postgresql:postgresql:42.6.0") { + because("prostresql support") + } + runtimeOnly("com.mysql:mysql-connector-j:8.1.0") { + because("mysql support") + } + runtimeOnly("com.oracle.database.jdbc:ojdbc11:23.2.0.0") { + because("oracle support") + } + runtimeOnly("com.microsoft.sqlserver:mssql-jdbc:12.4.0.jre11") { + because("mssql support") + } + //endregion +} + +application { + applicationName = "service" + mainClass.set("com.exactpro.th2.read.db.bootstrap.Main") +} diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 6f4cc5a..0000000 --- a/build.gradle +++ /dev/null @@ -1,63 +0,0 @@ -import com.github.jk1.license.filter.LicenseBundleNormalizer -import com.github.jk1.license.render.JsonReportRenderer - -plugins { - id "io.github.gradle-nexus.publish-plugin" version "1.3.0" - id 'org.jetbrains.kotlin.jvm' version '1.8.22' apply false - id "org.owasp.dependencycheck" version "8.4.0" - id "com.gorylenko.gradle-git-properties" version "2.4.1" - id "com.github.jk1.dependency-license-report" version "2.5" - id "de.undercouch.download" version "5.5.0" -} - -allprojects { - group = 'com.exactpro.th2' - version = release_version - String suffix = property('version_suffix').toString() - if (!suffix.isEmpty()) { - version = "$version-$suffix" - } -} - -nexusPublishing { - repositories { - sonatype { - nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) - snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) - } - } -} - -tasks.withType(PublishToMavenRepository).configureEach { it.enabled = false } - -dependencyCheck { - skipProjects = [':app'] - formats = ['SARIF', 'JSON', 'HTML'] - failBuildOnCVSS = 5 - - analyzers { - assemblyEnabled = false - nugetconfEnabled = false - nodeEnabled = false - } -} - -dependencyLocking { - lockAllConfigurations() -} - -licenseReport { - def licenseNormalizerBundlePath = "$buildDir/license-normalizer-bundle.json" - - if (!file(licenseNormalizerBundlePath).exists()) { - download.run { - src 'https://raw.githubusercontent.com/th2-net/.github/main/license-compliance/gradle-license-report/license-normalizer-bundle.json' - dest "$buildDir/license-normalizer-bundle.json" - overwrite false - } - } - - filters = [new LicenseBundleNormalizer(licenseNormalizerBundlePath, false)] - renderers = [new JsonReportRenderer('licenses.json', false)] - allowedLicensesFile = new URL("https://raw.githubusercontent.com/th2-net/.github/main/license-compliance/gradle-license-report/allowed-licenses.json") -} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..2da214c --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,17 @@ +plugins { + id("com.exactpro.th2.gradle.base") version "0.0.4" + id("com.exactpro.th2.gradle.publish") version "0.0.4" + + kotlin("jvm") version "1.8.22" apply false + id("com.exactpro.th2.gradle.grpc") version "0.0.4" apply false + id("com.exactpro.th2.gradle.component") version "0.0.4" apply false +} + +allprojects { + group = "com.exactpro.th2" + version = project.findProperty("release_version") as String + val suffix = project.findProperty("version_suffix") as String + if (suffix.isNotEmpty()) { + version = "$version-$suffix" + } +} \ No newline at end of file diff --git a/common.gradle b/common.gradle deleted file mode 100644 index 8ec08f1..0000000 --- a/common.gradle +++ /dev/null @@ -1,10 +0,0 @@ -dependencies { - api platform('com.exactpro.th2:bom:4.5.0') -} - -test { - useJUnitPlatform() - testLogging { - showStandardStreams = true - } -} \ No newline at end of file diff --git a/core/build.gradle b/core/build.gradle deleted file mode 100644 index 0f2f940..0000000 --- a/core/build.gradle +++ /dev/null @@ -1,135 +0,0 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import org.jetbrains.kotlin.gradle.dsl.JvmTarget -import com.github.jk1.license.filter.LicenseBundleNormalizer -import com.github.jk1.license.render.JsonReportRenderer - -plugins { - id 'java-library' - id 'maven-publish' - id 'signing' - id "com.google.protobuf" version "0.9.3" - id "org.jetbrains.kotlin.jvm" - id "com.github.jk1.dependency-license-report" version "2.5" - id "de.undercouch.download" version "5.5.0" -} - -apply from: '../common.gradle' -apply from: '../publication.gradle' - -sourceCompatibility = 11 -targetCompatibility = 11 - -ext { - coroutines_version = '1.7.3' -} - -tasks.withType(KotlinCompile).configureEach { - compilerOptions { - jvmTarget.set(JvmTarget.JVM_11) - freeCompilerArgs.add('-opt-in=kotlin.RequiresOptIn') - } -} - -configurations.configureEach { - resolutionStrategy.cacheChangingModulesFor 0, 'seconds' - resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds' -} - -dependencies { - implementation project(":grpc-read-db") - - api platform("com.exactpro.th2:bom:4.5.0") - implementation "com.exactpro.th2:common:5.7.1-dev" - implementation "com.exactpro.th2:common-utils:2.2.0-dev" - implementation "com.exactpro.th2:lw-data-provider-utils:0.0.1-dev" - - implementation "org.slf4j:slf4j-api" - - implementation("org.apache.commons:commons-dbcp2:2.9.0") { - because("connection pool") - } - implementation "org.apache.commons:commons-text" - implementation("com.opencsv:opencsv:5.8") { - because("publishes raw messages in csv format") - } - - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" - implementation "io.github.microutils:kotlin-logging:3.0.5" - implementation "com.fasterxml.jackson.core:jackson-databind" - - testImplementation "org.junit.jupiter:junit-jupiter:5.10.0" - testImplementation "org.jetbrains.kotlin:kotlin-test-junit" - testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version" - testImplementation "org.mockito.kotlin:mockito-kotlin:5.1.0" - testImplementation "io.strikt:strikt-core:0.34.1" - - testImplementation platform("org.testcontainers:testcontainers-bom:1.19.0") - testImplementation "org.testcontainers:testcontainers" - testImplementation "org.testcontainers:mysql" - testImplementation "org.testcontainers:oracle-xe" - testImplementation "io.grpc:grpc-testing" - - testImplementation 'com.exactpro.th2:junit-jupiter-integration:0.0.1-master-6956603819-5241ee5-SNAPSHOT' - - testRuntimeOnly("com.mysql:mysql-connector-j:8.1.0") { - because("mysql support") - } - testRuntimeOnly('com.oracle.database.jdbc:ojdbc11:23.2.0.0') { - because('oracle support') - } -} - -tasks.register('integrationTest', Test) { - group = 'verification' - useJUnitPlatform { - includeTags('integration-test') - } - testLogging { - showStandardStreams = true - } -} - -tasks.register('unitTest', Test) { - group = 'verification' - useJUnitPlatform { - excludeTags('integration-test') - } - testLogging { - showStandardStreams = true - } -} - -java { - withJavadocJar() - withSourcesJar() -} - -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 - ) - } -} - -licenseReport { - def licenseNormalizerBundlePath = "$buildDir/license-normalizer-bundle.json" - - if (!file(licenseNormalizerBundlePath).exists()) { - download.run { - src 'https://raw.githubusercontent.com/th2-net/.github/main/license-compliance/gradle-license-report/license-normalizer-bundle.json' - dest "$buildDir/license-normalizer-bundle.json" - overwrite false - } - } - - filters = [new LicenseBundleNormalizer(licenseNormalizerBundlePath, false)] - renderers = [new JsonReportRenderer('licenses.json', false)] - allowedLicensesFile = new URL("https://raw.githubusercontent.com/th2-net/.github/main/license-compliance/gradle-license-report/allowed-licenses.json") -} \ No newline at end of file diff --git a/core/build.gradle.kts b/core/build.gradle.kts new file mode 100644 index 0000000..42aac81 --- /dev/null +++ b/core/build.gradle.kts @@ -0,0 +1,84 @@ +plugins { + kotlin("jvm") + id("java-library") + id("maven-publish") +} + +val coroutinesVersion by extra("1.7.3") + +kotlin { + jvmToolchain(11) +} + +configurations.all { + resolutionStrategy.cacheChangingModulesFor(0, "seconds") + resolutionStrategy.cacheDynamicVersionsFor(0, "seconds") +} + +dependencies { + implementation(project(":grpc-read-db")) + + implementation("com.exactpro.th2:common:5.7.1-dev") + implementation("com.exactpro.th2:common-utils:2.2.0-dev") + implementation("com.exactpro.th2:lw-data-provider-utils:0.0.1-dev") + + implementation("org.slf4j:slf4j-api") + + implementation("org.apache.commons:commons-dbcp2:2.9.0") { + because("connection pool") + } + implementation("org.apache.commons:commons-text") + implementation("com.opencsv:opencsv:5.8") { + because("publishes raw messages in csv format") + } + + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") + implementation("io.github.microutils:kotlin-logging:3.0.5") + implementation("com.fasterxml.jackson.core:jackson-databind") + + testImplementation("org.junit.jupiter:junit-jupiter:5.10.0") + testImplementation("org.jetbrains.kotlin:kotlin-test-junit") + testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion") + testImplementation("org.mockito.kotlin:mockito-kotlin:5.1.0") + testImplementation("io.strikt:strikt-core:0.34.1") + + testImplementation(platform("org.testcontainers:testcontainers-bom:1.19.0")) + testImplementation("org.testcontainers:testcontainers") + testImplementation("org.testcontainers:mysql") + testImplementation("org.testcontainers:oracle-xe") + testImplementation("io.grpc:grpc-testing") + testImplementation("io.grpc:grpc-inprocess") + + testImplementation("com.exactpro.th2:junit-jupiter-integration:0.0.1") + + testRuntimeOnly("com.mysql:mysql-connector-j:8.1.0") { + because("mysql support") + } + testRuntimeOnly("com.oracle.database.jdbc:ojdbc11:23.2.0.0") { + because("oracle support") + } +} + +tasks { + test { useJUnitPlatform() } + + register("integrationTest") { + group = "verification" + useJUnitPlatform { + includeTags("integration-test") + } + testLogging { + showStandardStreams = true + } + } + + register("unitTest") { + group = "verification" + useJUnitPlatform { + excludeTags("integration-test") + } + testLogging { + showStandardStreams = true + } + } +} \ No newline at end of file diff --git a/grpc/build.gradle b/grpc/build.gradle deleted file mode 100644 index 1de1d38..0000000 --- a/grpc/build.gradle +++ /dev/null @@ -1,122 +0,0 @@ -import com.github.jk1.license.filter.LicenseBundleNormalizer -import com.github.jk1.license.render.JsonReportRenderer - -plugins { - id 'java' - id 'java-library' - id 'maven-publish' - id 'signing' - id "com.google.protobuf" version "0.9.3" - id "com.github.jk1.dependency-license-report" version "2.5" - id "de.undercouch.download" version "5.5.0" -} - -apply from: '../common.gradle' -apply from: '../publication.gradle' - -sourceCompatibility = 11 -targetCompatibility = 11 - -ext { - grpcVersion = '1.56.0' - protobufVersion = '3.24.3' // The protoc:3.23.3 https://github.com/protocolbuffers/protobuf/issues/13070 - serviceGeneratorVersion = '3.5.1' - grpcCommonVersion = '4.3.0-dev' - - genBaseDir = file("${buildDir}/generated/source/proto") // from protobuf plugin -} - -configurations.configureEach { - resolutionStrategy.cacheChangingModulesFor 0, 'seconds' - resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds' -} - -dependencies { - api "com.google.protobuf:protobuf-java-util" - api "io.grpc:grpc-stub" - api "com.exactpro.th2:grpc-common:4.3.0-dev" - implementation "io.grpc:grpc-protobuf" - implementation "io.grpc:grpc-core" - implementation "io.grpc:grpc-netty" - - implementation "javax.annotation:javax.annotation-api:1.3.2" - - api "com.exactpro.th2:grpc-common:$grpcCommonVersion" - api "com.exactpro.th2:grpc-service-generator:$serviceGeneratorVersion" -} - -sourceSets { - main { - proto { - srcDirs 'proto' - } - // the proto plugins add generated dir to source sets - resources { - srcDirs "$genBaseDir/main/services/java/resources" - } - } -} - -protobuf { - protoc { - artifact = "com.google.protobuf:protoc:$protobufVersion" - } - plugins { - grpc { - artifact = "io.grpc:protoc-gen-grpc-java:$grpcVersion" - } - services { - artifact = "com.exactpro.th2:grpc-service-generator:$serviceGeneratorVersion:all@jar" - } - } - generateProtoTasks { - all()*.plugins { - grpc {} - services { - option 'javaInterfacesPath=./java/src' - option 'javaInterfacesImplPath=./java/src' - option 'javaMetaInfPath=./java/resources' - option 'pythonPath=./python' - } - } - ofSourceSet('main') - } -} - -compileJava.dependsOn.add('generateProto') -processResources.dependsOn.add('generateProto') - -java { - withJavadocJar() - withSourcesJar() -} - -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 - ) - } -} - -licenseReport { - def licenseNormalizerBundlePath = "$buildDir/license-normalizer-bundle.json" - - if (!file(licenseNormalizerBundlePath).exists()) { - download.run { - src 'https://raw.githubusercontent.com/th2-net/.github/main/license-compliance/gradle-license-report/license-normalizer-bundle.json' - dest "$buildDir/license-normalizer-bundle.json" - overwrite false - } - } - - filters = [new LicenseBundleNormalizer(licenseNormalizerBundlePath, false)] - renderers = [new JsonReportRenderer('licenses.json', false)] - allowedLicensesFile = new URL("https://raw.githubusercontent.com/th2-net/.github/main/license-compliance/gradle-license-report/allowed-licenses.json") -} \ No newline at end of file diff --git a/grpc/build.gradle.kts b/grpc/build.gradle.kts new file mode 100644 index 0000000..cf7dd15 --- /dev/null +++ b/grpc/build.gradle.kts @@ -0,0 +1,18 @@ +plugins { + id("java-library") + id("maven-publish") + id("com.exactpro.th2.gradle.grpc") +} + +configurations.all { + resolutionStrategy.cacheChangingModulesFor(0, "seconds") + resolutionStrategy.cacheDynamicVersionsFor(0, "seconds") +} + +dependencies { + api("com.exactpro.th2:grpc-common:4.3.0-dev") +} + +th2Grpc { + service.set(true) +} \ No newline at end of file diff --git a/grpc/setup.py b/grpc/setup.py index 617a845..e7c6cec 100644 --- a/grpc/setup.py +++ b/grpc/setup.py @@ -37,7 +37,7 @@ def finalize_options(self): pass def run(self): - proto_path = os.path.abspath('proto') + proto_path = os.path.abspath('src/main/proto') gen_path = os.path.abspath('build/generated/source/proto/main/services/python') if not os.path.exists(gen_path): @@ -70,7 +70,7 @@ def run(self): class CustomDist(sdist): def run(self): - copy_tree(f'proto/{package_name}', package_name) + copy_tree(f'src/main/proto/{package_name}', package_name) copy_tree(f'build/generated/source/proto/main/services/python/{package_name}', package_name) Path(f'{package_name}/__init__.py').touch() diff --git a/grpc/proto/th2_grpc_read_db/read_db.proto b/grpc/src/main/proto/th2_grpc_read_db/read_db.proto similarity index 100% rename from grpc/proto/th2_grpc_read_db/read_db.proto rename to grpc/src/main/proto/th2_grpc_read_db/read_db.proto diff --git a/publication.gradle b/publication.gradle deleted file mode 100644 index 0149e91..0000000 --- a/publication.gradle +++ /dev/null @@ -1,80 +0,0 @@ -apply plugin: 'maven-publish' -apply plugin: 'signing' - -// conditionals for publications -tasks.withType(PublishToMavenRepository).configureEach { - onlyIf { - (repository == publishing.repositories.nexusRepository && - project.hasProperty('nexus_user') && - project.hasProperty('nexus_password') && - project.hasProperty('nexus_url')) || - (repository == publishing.repositories.sonatype && - project.hasProperty('sonatypeUsername') && - project.hasProperty('sonatypePassword')) - } -} -tasks.withType(Sign).configureEach { - onlyIf { - project.hasProperty('signingKey') && - project.hasProperty('signingPassword') - } -} -// disable running task 'initializeSonatypeStagingRepository' on a gitlab -tasks.configureEach {task -> - if(task.name == 'initializeSonatypeStagingRepository' && - !(project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')) - ) { - task.enabled = false - } -} - -publishing { - publications { - mavenJava(MavenPublication) { - from(components.java) - pom { - name = project.name - packaging = 'jar' - description = project.description - url = vcs_url - scm { - url = vcs_url - } - licenses { - license { - name = 'The Apache License, Version 2.0' - url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - developers { - developer { - id = 'developer' - name = 'developer' - email = 'developer@exactpro.com' - } - } - scm { - url = vcs_url - } - } - } - } - repositories { - //Nexus repo to publish from gitlab - maven { - name = 'nexusRepository' - credentials { - username = project.findProperty('nexus_user') - password = project.findProperty('nexus_password') - } - url = project.findProperty('nexus_url') - } - } -} - -signing { - def signingKey = findProperty("signingKey") - def signingPassword = findProperty("signingPassword") - useInMemoryPgpKeys(signingKey, signingPassword) - sign publishing.publications.mavenJava -} \ No newline at end of file