-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathbuild.gradle
145 lines (127 loc) · 5.09 KB
/
build.gradle
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
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
buildscript {
ext {
opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT")
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
// 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}"
}
if (isSnapshot) {
opensearch_build += "-SNAPSHOT"
}
opensearch_no_snapshot = opensearch_version.replace("-SNAPSHOT","")
common_utils_version = System.getProperty("common_utils.version", opensearch_build)
kotlin_version = System.getProperty("kotlin.version", "1.9.25")
junit_version = System.getProperty("junit.version", "5.7.2")
aws_version = System.getProperty("aws.version", "1.12.687")
asm_version = System.getProperty("asm.version", "9.7")
}
repositories {
// For local publish dependency
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
}
dependencies {
classpath "org.opensearch.gradle:build-tools:${opensearch_version}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}"
classpath "org.jetbrains.kotlin:kotlin-allopen:${kotlin_version}"
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.0"
classpath "org.jacoco:org.jacoco.agent:0.8.12"
}
configurations {
classpath {
resolutionStrategy {
//in order to handle jackson's higher release version in shadow, this needs to be upgraded to latest
force(group: "org.ow2.asm", name: "asm", version: asm_version)
force(group: "org.ow2.asm", name: "asm-commons", version: asm_version)
}
}
}
}
apply plugin: 'base'
apply plugin: 'jacoco'
apply plugin: 'io.gitlab.arturbosch.detekt'
apply from: 'build-tools/merged-coverage.gradle'
allprojects {
version = "${opensearch_build}"
repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
}
group = "org.opensearch"
plugins.withId('java') {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
plugins.withId('org.jetbrains.kotlin.jvm') {
compileJava.sourceCompatibility = JavaVersion.VERSION_21
compileJava.targetCompatibility = JavaVersion.VERSION_21
compileTestJava.sourceCompatibility = JavaVersion.VERSION_21
compileTestJava.targetCompatibility = JavaVersion.VERSION_21
compileKotlin.kotlinOptions.jvmTarget = "21"
compileTestKotlin.kotlinOptions.jvmTarget = "21"
compileKotlin.dependsOn ktlint
}
}
configurations {
ktlint {
resolutionStrategy {
force "ch.qos.logback:logback-classic:1.3.14"
force "ch.qos.logback:logback-core:1.3.14"
}
}
}
dependencies {
add("ktlint", "com.pinterest:ktlint:0.47.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 "notifications/**/*.kt", "core/**/*.kt", "core-spi/**/*.kt"
// to generate report in checkstyle format prepend following args:
// "--reporter=plain", "--reporter=checkstyle,output=${buildDir}/ktlint.xml"
// see https://github.com/pinterest/ktlint#usage for more
}
task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
mainClass = "com.pinterest.ktlint.Main"
classpath = configurations.ktlint
args "-F", "notifications/**/*.kt", "core/**/*.kt", "core-spi/**/*.kt"
// https://github.com/pinterest/ktlint/issues/1391
jvmArgs "--add-opens=java.base/java.lang=ALL-UNNAMED"
}
detekt {
config = files("detekt.yml")
buildUponDefaultConfig = true
parallel = true
}
check.dependsOn ktlint
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(file:'build.gradle', match: '"opensearch.version", "\\d.*"', replace: '"opensearch.version", "' + newVersion.tokenize('-')[0] + '-SNAPSHOT"', flags:'g', byline:true)
}
}