/* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform buildscript { repositories { mavenLocal() maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" } mavenCentral() } } plugins { id 'java' id 'com.github.johnrengelman.shadow' version '4.0.1' id 'jacoco' id 'maven' id 'maven-publish' id 'signing' } group 'org.opensearch.driver' // keep version in sync with version in Driver source version '1.4.0.0' boolean snapshot = "true".equals(System.getProperty("build.snapshot", "false")); if (snapshot) { version += "-SNAPSHOT" } jacoco { toolVersion = "0.8.3" } sourceCompatibility = 8 targetCompatibility = 8 repositories { mavenLocal() maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" } mavenCentral() } dependencies { implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.13' implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "2.13.4.2" implementation group: 'com.amazonaws', name: 'aws-java-sdk-core', version: '1.12.1' testImplementation('org.junit.jupiter:junit-jupiter-api:5.3.1') testImplementation('org.junit.jupiter:junit-jupiter-params:5.3.1') testImplementation('com.github.tomakehurst:wiremock:3.0.0-beta-2') testImplementation('org.mockito:mockito-core:2.23.0') testImplementation('org.junit.jupiter:junit-jupiter-engine:5.3.1') testImplementation('org.junit-pioneer:junit-pioneer:0.3.0') testImplementation('org.eclipse.jetty:jetty-server:11.0.14') // Enforce wiremock to use latest guava and json-smart testImplementation('com.google.guava:guava:32.0.1-jre') testImplementation('net.minidev:json-smart:2.4.9') testRuntimeOnly('org.slf4j:slf4j-simple:1.7.25') // capture WireMock logging // JDBC drivers for comparison test. Somehow Apache Derby throws security permission exception. testImplementation fileTree('/build/libs') { include '*.jar' builtBy 'compileJdbc' } testImplementation group: 'org.xerial', name: 'sqlite-jdbc', version: '3.41.2.2' testImplementation group: 'com.google.code.gson', name: 'gson', version: '2.8.9' } task compileJdbc(type: Exec) { if (DefaultNativePlatform.getCurrentOperatingSystem().isWindows()) { commandLine './gradlew.bat', 'build' commandLine './gradlew.bat', 'shadowJar' } else { commandLine './gradlew', 'build' commandLine './gradlew', 'shadowJar' } } tasks.withType(JavaCompile) { options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked" } static def getShadowPath(String path) { return 'org.opensearch.sql.jdbc.shadow.' + path } shadowJar { baseName = rootProject.name classifier = '' exclude 'META-INF/maven/commons-*/**' exclude 'META-INF/maven/org.apache.*/**' exclude 'META-INF/maven/joda-time/**' exclude 'META-INF/maven/com.fasterxml.*/**' exclude 'META-INF/services/com.fasterxml.*' exclude 'META-INF/services/org.apache.logging*/**' exclude 'META-INF/maven/com.amazonaws/**' exclude 'META-INF/maven/software.amazon.*/**' exclude 'META-INF/LICENSE*' exclude 'META-INF/NOTICE*' exclude 'META-INF/DEPENDENCIES' relocate 'com.amazonaws', getShadowPath('com.amazonaws') relocate 'org.apache', getShadowPath('org.apache') relocate 'org.joda', getShadowPath('org.joda') relocate 'com.fasterxml', getShadowPath('com.fasterxml') relocate 'software.amazon', getShadowPath('software.amazon') } test { useJUnitPlatform() } task sourcesJar(type: Jar) { classifier = 'sources' from sourceSets.main.allJava } task javadocJar(type: Jar) { classifier "javadoc" from javadoc.destinationDir } publishing { publications { shadow(MavenPublication) { publication -> project.shadow.component(publication) artifact sourcesJar artifact javadocJar pom { name = "OpenSearch SQL JDBC Driver" packaging = "jar" url = "https://github.com/opensearch-project/sql-jdbc" description = "OpenSearch SQL JDBC driver" scm { connection = "scm:git@github.com:opensearch-project/sql-jdbc.git" developerConnection = "scm:git@github.com:opensearch-project/sql-jdbc.git" url = "git@github.com:opensearch-project/sql-jdbc.git" } licenses { license { name = "The Apache License, Version 2.0" url = "http://www.apache.org/licenses/LICENSE-2.0.txt" } } developers { developer { name = 'OpenSearch' url = 'https://github.com/opensearch-project/sql-jdbc' } } } } publishMaven(MavenPublication) { publication -> from components.java artifact sourcesJar artifact javadocJar pom { name = "OpenSearch SQL JDBC Driver" packaging = "jar" url = "https://github.com/opensearch-project/sql-jdbc" description = "OpenSearch SQL JDBC driver" scm { connection = "scm:git@github.com:opensearch-project/sql-jdbc.git" developerConnection = "scm:git@github.com:opensearch-project/sql-jdbc.git" url = "git@github.com:opensearch-project/sql-jdbc.git" } licenses { license { name = "The Apache License, Version 2.0" url = "http://www.apache.org/licenses/LICENSE-2.0.txt" } } developers { developer { name = 'OpenSearch' url = 'https://github.com/opensearch-project/sql-jdbc' } } } } } repositories { maven { name = "sonatype-staging" url "https://aws.oss.sonatype.org/service/local/staging/deploy/maven2" credentials { username project.hasProperty('ossrhUsername') ? project.property('ossrhUsername') : '' password project.hasProperty('ossrhPassword') ? project.property('ossrhPassword') : '' } } maven { name = "localRepo" url "${project.buildDir}/repository" } } // TODO - enabled debug logging for the time being, remove this eventually gradle.startParameter.setShowStacktrace(ShowStacktrace.ALWAYS) gradle.startParameter.setLogLevel(LogLevel.DEBUG) } signing { required { gradle.taskGraph.hasTask("publishShadowPublicationToSonatype-stagingRepository") } sign publishing.publications.shadow } jacoco { toolVersion = "0.8.3" } jacocoTestReport { reports { html.enabled true } } test.finalizedBy(project.tasks.jacocoTestReport) jacocoTestCoverageVerification { violationRules { rule { limit { minimum = 0.4 } } } } configurations.all { // fixes https://www.mend.io/vulnerability-database/CVE-2023-24998 resolutionStrategy.force 'commons-fileupload:commons-fileupload:1.5' resolutionStrategy.force 'org.eclipse.jetty:jetty-client:11.0.14' resolutionStrategy.force 'org.eclipse.jetty:jetty-servlets:11.0.14' resolutionStrategy.force 'org.eclipse.jetty:jetty-webapp:11.0.14' } check.dependsOn jacocoTestCoverageVerification