-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathbuild.gradle
More file actions
164 lines (142 loc) · 5.2 KB
/
build.gradle
File metadata and controls
164 lines (142 loc) · 5.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
buildscript {
apply from: 'build-tools/repositories.gradle'
ext {
opensearch_version = System.getProperty("opensearch.version", "3.6.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 = '2.2.0'
}
repositories {
mavenLocal()
maven {
url "https://ci.opensearch.org/ci/dbc/snapshots/maven/"
mavenContent {
snapshotsOnly()
}
}
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 "12.0.0"
id "com.dorongold.task-tree" version "1.5"
id "de.undercouch.download" version "5.6.0"
}
apply plugin: 'base'
apply plugin: 'jacoco'
apply plugin: 'opensearch.java-agent'
apply from: 'build-tools/merged-coverage.gradle'
// Add explicit repository configuration for ktlint
repositories {
mavenCentral()
}
// Configure ktlint with explicit repository
configurations {
ktlint {
resolutionStrategy {
force "ch.qos.logback:logback-classic:1.5.19"
force "ch.qos.logback:logback-core:1.5.19"
}
}
}
// Add repository ONLY for ktlint resolution
configurations.ktlint.incoming.beforeResolve {
repositories.clear()
repositories {
mavenCentral()
}
}
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."
mainClass = "com.pinterest.ktlint.Main"
classpath = configurations.ktlint
args "alerting/**/*.kt", "elastic-api/**/*.kt", "core/**/*.kt"
// Skip on JDK 25
onlyIf {
JavaVersion.current() < JavaVersion.VERSION_25
}
}
task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
mainClass = "com.pinterest.ktlint.Main"
classpath = configurations.ktlint
args "-F", "alerting/**/*.kt", "elastic-api/**/*.kt", "core/**/*.kt"
// Skip on JDK 25 until ktlint fully supports it
onlyIf {
JavaVersion.current() < JavaVersion.VERSION_25
}
}
check.dependsOn ktlint
allprojects {
group = "org.opensearch"
version = "${opensearch_build}"
apply from: "$rootDir/build-tools/repositories.gradle"
configurations.all {
resolutionStrategy {
force "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"
force "org.jetbrains.kotlin:kotlin-stdlib-common:${kotlin_version}"
force "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlin_version}"
force "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlin_version}"
force "org.jetbrains.kotlin:kotlin-reflect:${kotlin_version}"
}
}
tasks.withType(JavaCompile) {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
plugins.withId('org.jetbrains.kotlin.jvm') {
compileKotlin.kotlinOptions.jvmTarget = compileTestKotlin.kotlinOptions.jvmTarget = JavaVersion.VERSION_21
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)
}
}