-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
120 lines (99 loc) · 3.26 KB
/
build.gradle.kts
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
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.opensearch.gradle.testclusters.OpenSearchCluster
import org.opensearch.gradle.testclusters.RunTask
import org.opensearch.gradle.testclusters.TestClustersPlugin
buildscript {
val openSearchVersion = Versions.getOpenSearchVersion()
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath("org.opensearch.gradle:build-tools:${openSearchVersion}")
}
}
group = "org.opensearch.example"
version = Versions.getVersion()
plugins {
kotlin("jvm") version Versions.kotlinVersion
java
idea
}
apply(plugin = "opensearch.opensearchplugin")
apply(plugin = "opensearch.testclusters")
apply(plugin = "opensearch.rest-test")
apply(plugin = "opensearch.yaml-rest-test")
apply(plugin = "opensearch.internal-cluster-test")
configure<org.opensearch.gradle.plugin.PluginPropertiesExtension> {
name = "example-opensearch-plugin"
description = "OpenSearch plugin template written in Kotlin"
classname = "org.opensearch.example.ExamplePlugin"
noticeFile = rootProject.file("NOTICE")
licenseFile = rootProject.file("LICENSE")
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
implementation(kotlin("stdlib"))
implementation(kotlin("stdlib-common"))
val openSearchVersion = Versions.getOpenSearchVersion()
implementation("org.opensearch:opensearch:${openSearchVersion}")
}
configurations.all {
resolutionStrategy {
preferProjectModules()
}
}
tasks.named("licenseHeaders") {
enabled = true
}
tasks.named("dependencyLicenses") {
enabled = false
}
tasks.named("loggerUsageCheck") {
enabled = false
}
tasks.named("validateNebulaPom") {
enabled = false
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}
tasks.withType<Test> {
testLogging {
events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED, TestLogEvent.STANDARD_ERROR)
exceptionFormat = TestExceptionFormat.FULL
showExceptions = true
showStackTraces = true
showCauses = true
}
}
/**
* Temporary workaround for - https://github.com/opensearch-project/OpenSearch/issues/766
* 1. The 'run' task doesn't launch a test cluster.
* 2. The test cluster launched by the 'integTest' task doesn't have the plugin pre-installed.
*
* Workaround:
* 1. Create and register a new test cluster for the 'run' task.
* 2. For the test clusters launched by 'run' and 'integTest' tasks, pre-install the bundled plugin ZIP.
*/
val bundlePlugin = tasks.getByName<Zip>("bundlePlugin")
val testClusters = extensions.getByName<NamedDomainObjectContainer<OpenSearchCluster>>(TestClustersPlugin.EXTENSION_NAME)
listOf("runTask", "integTest").forEach { name -> testClusters.maybeCreate(name).plugin(bundlePlugin.archiveFile) }
tasks.named<RunTask>("run") {
useCluster(testClusters["runTask"])
}