/* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ /* * Licensed to Elasticsearch under one or more contributor * license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright * ownership. Elasticsearch licenses this file to you under * the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ plugins { id 'java' id "io.freefair.lombok" id 'jacoco' id 'opensearch.opensearchplugin' } apply plugin: 'opensearch.pluginzip' apply plugin: 'opensearch.rest-test' ext { projectSubstitutions = [:] licenseFile = rootProject.file('LICENSE.TXT') noticeFile = rootProject.file('NOTICE') } repositories { mavenCentral() maven { url 'https://jitpack.io' } } opensearchplugin { name 'opensearch-sql' description 'OpenSearch SQL' classname 'org.opensearch.sql.plugin.SQLPlugin' licenseFile rootProject.file("LICENSE.txt") noticeFile rootProject.file("NOTICE") } publishing { publications { pluginZip(MavenPublication) { publication -> pom { name = 'opensearch-sql' description = 'OpenSearch SQL' groupId = "org.opensearch.plugin" 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' } } } } } repositories { maven { name = "Snapshots" // optional target repository name url = "https://aws.oss.sonatype.org/content/repositories/snapshots" credentials { username "$System.env.SONATYPE_USERNAME" password "$System.env.SONATYPE_PASSWORD" } } } } javadoc.enabled = false loggerUsageCheck.enabled = false dependencyLicenses.enabled = false thirdPartyAudit.enabled = false configurations.all { // conflict with spring-jcl resolutionStrategy.force "commons-logging:commons-logging:1.2" // enforce 2.12.6, https://github.com/opensearch-project/sql/issues/424 resolutionStrategy.force "com.fasterxml.jackson.core:jackson-core:${versions.jackson}" // enforce 1.1.3, https://www.whitesourcesoftware.com/vulnerability-database/WS-2019-0379 resolutionStrategy.force 'commons-codec:commons-codec:1.13' resolutionStrategy.force 'com.google.guava:guava:32.0.1-jre' resolutionStrategy.force "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${versions.jackson}" resolutionStrategy.force "com.fasterxml.jackson.dataformat:jackson-dataformat-smile:${versions.jackson}" resolutionStrategy.force "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:${versions.jackson}" resolutionStrategy.force "com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}" resolutionStrategy.force "com.squareup.okhttp3:okhttp:4.9.3" resolutionStrategy.force "joda-time:joda-time:2.10.12" resolutionStrategy.force "org.slf4j:slf4j-api:1.7.36" resolutionStrategy.force "org.apache.httpcomponents:httpcore:4.4.15" resolutionStrategy.force "org.apache.httpcomponents:httpclient:4.5.13" } compileJava { options.compilerArgs.addAll(["-processor", 'lombok.launch.AnnotationProcessorHider$AnnotationProcessor']) } compileTestJava { options.compilerArgs.addAll(["-processor", 'lombok.launch.AnnotationProcessorHider$AnnotationProcessor']) } dependencies { api "com.fasterxml.jackson.core:jackson-core:${versions.jackson}" api "com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}" api "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}" api project(":ppl") api project(':legacy') api project(':opensearch') api project(':prometheus') api project(':datasources') api project(':spark') testImplementation group: 'net.bytebuddy', name: 'byte-buddy-agent', version: '1.12.13' testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: '2.1' testImplementation group: 'org.mockito', name: 'mockito-core', version: '5.4.0' testImplementation group: 'org.mockito', name: 'mockito-junit-jupiter', version: '5.4.0' testImplementation 'org.junit.jupiter:junit-jupiter:5.6.2' } test { include '**/*Test.class' testLogging { events "passed", "skipped", "failed" exceptionFormat "full" } } ext { projectSubstitutions = [:] licenseFile = rootProject.file('LICENSE.TXT') noticeFile = rootProject.file('NOTICE') } // ANTLR generated parser file is too large to be checked which caused licenseHeaders stuck. licenseHeaders { enabled = true excludes = ['org/opensearch/sql/antlr/parser/**'] } tasks.withType(licenseHeaders.class) { additionalLicense 'AL ', 'Apache', 'Licensed under the Apache License, Version 2.0 (the "License")' } // TODO: fix forbidden APIs // from police-man plugin, see https://github.com/policeman-tools/forbidden-apis/wiki/GradleUsage forbiddenApis.ignoreFailures = true // TODO: fix forbidden code patterns // introduced by OpenSearch plugin forbiddenPatterns { setEnabled(false) } // TODO: fix license. skip dependency license checks dependencyLicenses.enabled = false // We don't need to follow OpenSearch testing naming conventions. // see https://github.com/elastic/elasticsearch/blob/323f312bbc829a63056a79ebe45adced5099f6e6/buildSrc/src/main/java/org/elasticsearch/gradle/precommit/TestingConventionsTasks.java // enable testingConventions check will cause errors like: "Classes ending with [Tests] must subclass [LuceneTestCase]" testingConventions.enabled = false // TODO: need to verify the thirdPartyAudi // currently it complains missing classes like ibatis, mysql etc, should not be a problem thirdPartyAudit.enabled = false apply plugin: 'nebula.ospackage' validateNebulaPom.enabled = false // This is afterEvaluate because the bundlePlugin ZIP task is updated afterEvaluate and changes the ZIP name to match the plugin name afterEvaluate { ospackage { packageName = "${rootProject.name}" release = isSnapshot ? "0.1" : '1' version = "${project.version}" - "-SNAPSHOT" into '/usr/share/opensearch/plugins' from(zipTree(bundlePlugin.archivePath)) { into opensearchplugin.name } user 'root' permissionGroup 'root' fileMode 0644 dirMode 0755 requires('opensearch', versions.opensearch, EQUAL) packager = 'Amazon' vendor = 'Amazon' os = 'LINUX' prefix '/usr' license 'ASL-2.0' maintainer 'OpenSearch Team ' url 'https://www.opensearch.org/downloads.html' summary ''' SQL plugin for OpenSearch. Reference documentation can be found at https://opensearch.org/docs/latest/search-plugins/sql/index/. '''.stripIndent().replace('\n', ' ').trim() } buildRpm { arch = 'NOARCH' dependsOn 'assemble' finalizedBy 'renameRpm' task renameRpm(type: Copy) { from("$buildDir/distributions") into("$buildDir/distributions") include archiveName rename archiveName, "${packageName}-${version}.rpm" doLast { delete file("$buildDir/distributions/$archiveName") } } } buildDeb { arch = 'all' dependsOn 'assemble' finalizedBy 'renameDeb' task renameDeb(type: Copy) { from("$buildDir/distributions") into("$buildDir/distributions") include archiveName rename archiveName, "${packageName}-${version}.deb" doLast { delete file("$buildDir/distributions/$archiveName") } } } } testClusters.integTest { plugin(project.tasks.bundlePlugin.archiveFile) testDistribution = "ARCHIVE" // debug with command, ./gradlew opensearch-sql:run -DdebugJVM. --debug-jvm does not work with keystore. if (System.getProperty("debugJVM") != null) { jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005' } // add customized keystore keystore 'plugins.query.federation.datasources.config', new File("$projectDir/src/test/resources/", 'datasources.json') } run { useCluster testClusters.integTest }