/* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ buildscript { apply from: 'build-tools/repositories.gradle' ext { opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT") buildVersionQualifier = System.getProperty("build.version_qualifier", "") isSnapshot = "true" == System.getProperty("build.snapshot", "true") // 3.0.0-SNAPSHOT -> 3.0.0.0-SNAPSHOT version_tokens = opensearch_version.tokenize('-') opensearch_build = version_tokens[0] + '.0' plugin_no_snapshot = opensearch_build if (buildVersionQualifier) { opensearch_build += "-${buildVersionQualifier}" plugin_no_snapshot += "-${buildVersionQualifier}" } if (isSnapshot) { opensearch_build += "-SNAPSHOT" } opensearch_no_snapshot = opensearch_version.replace("-SNAPSHOT","") common_utils_version = System.getProperty("common_utils.version", opensearch_build) kotlin_version = '1.8.21' } repositories { mavenLocal() maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" } mavenCentral() maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath "org.opensearch.gradle:build-tools:${opensearch_version}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}" } } plugins { id 'com.netflix.nebula.ospackage' version "11.0.0" id "com.dorongold.task-tree" version "1.5" } apply plugin: 'base' apply plugin: 'jacoco' apply from: 'build-tools/merged-coverage.gradle' configurations { ktlint } dependencies { add("ktlint", "com.pinterest:ktlint:0.45.1") { attributes { attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL)) } } } task ktlint(type: JavaExec, group: "verification") { description = "Check Kotlin code style." main = "com.pinterest.ktlint.Main" classpath = configurations.ktlint args "alerting/**/*.kt", "elastic-api/**/*.kt", "core/**/*.kt" } task ktlintFormat(type: JavaExec, group: "formatting") { description = "Fix Kotlin code style deviations." main = "com.pinterest.ktlint.Main" classpath = configurations.ktlint args "-F", "alerting/**/*.kt", "elastic-api/**/*.kt", "core/**/*.kt" } check.dependsOn ktlint allprojects { group = "org.opensearch" version = "${opensearch_build}" apply from: "$rootDir/build-tools/repositories.gradle" plugins.withId('java') { sourceCompatibility = targetCompatibility = JavaVersion.VERSION_11 } plugins.withId('org.jetbrains.kotlin.jvm') { compileKotlin.kotlinOptions.jvmTarget = compileTestKotlin.kotlinOptions.jvmTarget = JavaVersion.VERSION_11 compileKotlin.dependsOn ktlint } tasks.withType(AbstractArchiveTask).configureEach { preserveFileTimestamps = false reproducibleFileOrder = true } } evaluationDependsOnChildren() check.dependsOn subprojects*.check // updateVersion: Task to auto increment to the next development iteration task updateVersion { onlyIf { System.getProperty('newVersion') } doLast { ext.newVersion = System.getProperty('newVersion') println "Setting version to ${newVersion}." // String tokenization to support -SNAPSHOT ant.replaceregexp(match: opensearch_version.tokenize('-')[0], replace: newVersion.tokenize('-')[0], flags:'g', byline:true) { fileset(dir: projectDir) { // Include the required files that needs to be updated with new Version include(name: "alerting/build.gradle") } } ant.replaceregexp(file:'build.gradle', match: '"opensearch.version", "\\d.*"', replace: '"opensearch.version", "' + newVersion.tokenize('-')[0] + '-SNAPSHOT"', flags:'g', byline:true) } }