-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathbuild.gradle
More file actions
109 lines (93 loc) · 3.6 KB
/
Copy pathbuild.gradle
File metadata and controls
109 lines (93 loc) · 3.6 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
import java.nio.file.Files
import org.gradle.util.GradleVersion
apply plugin: 'groovy'
/*
* Build checks
*/
String minimumGradleVersion = file('src/main/resources/minimumGradleVersion').text.trim()
if (GradleVersion.current() < GradleVersion.version(minimumGradleVersion)) {
throw new GradleException("Gradle ${minimumGradleVersion}+ is required to build opensearch-hadoop")
}
if (JavaVersion.current() < JavaVersion.VERSION_11) {
throw new GradleException('At least Java 11 is required to use opensearch gradle tools')
}
/*
* Configure Project Versions
*/
boolean localRepo = project.getProperties().containsKey("localRepo")
Properties props = new Properties()
props.load(project.file('opensearch-hadoop-version.properties').newDataInputStream())
String opensearchHadoopVersion = props.getProperty('opensearch_hadoop')
String opensearchVersion = props.getProperty('opensearch')
String buildToolsVersion = props.getProperty('build-tools')
// determine if we're building a prerelease or candidate (alphaX/betaX/rcX)
String qualifier = System.getProperty("build.version_qualifier", "")
if (qualifier.isEmpty() == false) {
if (qualifier.matches("(alpha|beta|rc)\\d+") == false) {
throw new IllegalStateException("Invalid qualifier: " + qualifier)
}
opensearchHadoopVersion += "-" + qualifier
opensearchVersion += "-" + qualifier
buildToolsVersion += "-" + qualifier
}
// determine if we're building a snapshot or not (by default we will be)
boolean snapshot = "true".equals(System.getProperty("build.snapshot", "true"))
if (snapshot) {
// we update the version property to reflect if we are building a snapshot or a release build
opensearchHadoopVersion += "-SNAPSHOT"
opensearchVersion += "-SNAPSHOT"
buildToolsVersion += "-SNAPSHOT"
}
props.put("opensearch_hadoop", opensearchHadoopVersion)
props.put("opensearch", opensearchVersion)
props.put("build-tools", buildToolsVersion)
repositories {
gradlePluginPortal()
mavenCentral()
// For OpenSearch snapshots.
if (localRepo) {
// For some reason the root dirs all point to the buildSrc folder. The local Repo will be one above that.
flatDir { dirs new File(project.rootDir, "../localRepo") }
} else if (snapshot) {
maven { url = "https://central.sonatype.com/repository/maven-snapshots/" }
maven { url = "https://aws.oss.sonatype.org/content/repositories/snapshots" }
}
else {
maven { url = "https://plugins.gradle.org/m2/" }
}
}
dependencies {
compileOnly gradleApi()
compileOnly localGroovy()
// Required for dependency licenses task
implementation 'org.apache.rat:apache-rat:0.15'
implementation 'commons-codec:commons-codec:1.19.0'
if (localRepo) {
implementation(name: "build-tools-${buildToolsVersion}") {
exclude group: 'com.github.johnrengelman'
}
} else {
implementation(group: 'org.opensearch.gradle', name: 'build-tools', version: buildToolsVersion) {
exclude group: 'com.github.johnrengelman'
}
}
}
// write the updated properties to a temp property file
File tempPropertiesFile = new File(project.buildDir, "opensearch-hadoop-version.properties")
task writeVersionProperties {
inputs.properties(props)
outputs.file(tempPropertiesFile)
doLast {
OutputStream stream = Files.newOutputStream(tempPropertiesFile.toPath())
try {
props.store(stream, "UTF-8")
} finally {
stream.close()
}
}
}
// copy the saved property file to the resources dir
processResources {
dependsOn writeVersionProperties
from tempPropertiesFile
}