-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbuild.gradle.kts
164 lines (145 loc) · 4.39 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
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
*/
import net.researchgate.release.ReleaseExtension
import java.io.File
import java.io.FileInputStream
import java.util.Properties
plugins {
java
`maven-publish`
eclipse
idea
id("org.ec4j.editorconfig") version "0.0.3"
id("com.diffplug.spotless") version "6.25.0"
}
buildscript {
repositories {
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath("gradle.plugin.org.ec4j.gradle:editorconfig-gradle-plugin:0.0.3")
classpath("com.diffplug.spotless:spotless-plugin-gradle:6.25.0")
classpath("net.researchgate:gradle-release:3.1.0")
}
}
apply(plugin = "org.ec4j.editorconfig")
apply(plugin = "com.diffplug.spotless")
apply(plugin = "net.researchgate.release")
repositories {
mavenLocal()
maven {
url = uri("https://repo.maven.apache.org/maven2/")
}
}
dependencies {
implementation("org.testcontainers:testcontainers:1.20.4")
testImplementation("org.junit.jupiter:junit-jupiter:5.11.4")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.11.4")
testImplementation("ch.qos.logback:logback-classic:1.5.16")
testImplementation("org.opensearch.client:opensearch-rest-client:2.18.0")
}
group = "org.opensearch"
val build = Properties().apply {
load(FileInputStream(File(rootProject.rootDir, "version.properties")))
}
// Detect version from version.properties and align it with the build settings
var isSnapshot = "true" == System.getProperty("build.snapshot", "true")
var buildVersion = build.getProperty("version")
if (isSnapshot && !buildVersion.endsWith("SNAPSHOT")) {
buildVersion = buildVersion + "-SNAPSHOT"
} else if (!isSnapshot && buildVersion.endsWith("SNAPSHOT")) {
throw GradleException("Expecting release (non-SNAPSHOT) build but version is not set accordingly: " + buildVersion)
}
// Check if tag release version (if provided) matches the version from build settings
val tagVersion = System.getProperty("build.version", buildVersion)
if (!buildVersion.equals(tagVersion)) {
throw GradleException("The tagged version " + tagVersion + " does not match the build version " + buildVersion)
}
version = buildVersion
description = "Testcontainers for Opensearch"
java.sourceCompatibility = JavaVersion.VERSION_11
java {
withSourcesJar()
withJavadocJar()
}
publishing {
publications.create<MavenPublication>("maven") {
from(components["java"])
}
}
tasks.withType<JavaCompile>() {
options.encoding = "UTF-8"
}
tasks.test {
useJUnitPlatform()
reports {
junitXml.required.set(true)
html.required.set(true)
}
}
spotless {
java {
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
removeUnusedImports()
importOrder()
palantirJavaFormat()
}
}
configure<ReleaseExtension> {
with(git) {
requireBranch.set("main")
versionPropertyFile.set("version.properties")
}
}
publishing {
repositories{
if (version.toString().endsWith("SNAPSHOT")) {
maven("https://aws.oss.sonatype.org/content/repositories/snapshots/") {
name = "snapshotRepo"
credentials {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
}
}
}
maven(rootProject.layout.buildDirectory.dir("repository")) {
name = "localRepo"
}
}
publications {
create<MavenPublication>("publishMaven") {
from(components["java"])
pom {
name.set("OpenSearch Testcontainers integration")
packaging = "jar"
artifactId = "opensearch-testcontainers"
description.set("OpenSearch Testcontainers integration")
url.set("https://github.com/opensearch-project/opensearch-testcontainers/")
scm {
connection.set("scm:[email protected]:opensearch-project/opensearch-testcontainers.git")
developerConnection.set("scm:[email protected]:opensearch-project/opensearch-testcontainers.git")
url.set("[email protected]:opensearch-project/opensearch-testcontainers.git")
}
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
name.set("opensearch-project")
url.set("https://www.opensearch.org")
inceptionYear.set("2022")
}
}
}
}
}
}