-
Notifications
You must be signed in to change notification settings - Fork 990
/
Copy pathbuild.gradle
102 lines (86 loc) · 3.27 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
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 es-hadoop")
}
if (JavaVersion.current() < JavaVersion.VERSION_11) {
throw new GradleException('At least Java 11 is required to use elasticsearch gradle tools')
}
/*
* Configure Project Versions
*/
boolean localRepo = project.getProperties().containsKey("localRepo")
Properties props = new Properties()
props.load(project.file('esh-version.properties').newDataInputStream())
String eshVersion = props.getProperty('eshadoop')
String esVersion = props.getProperty('elasticsearch')
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)
}
eshVersion += "-" + qualifier
esVersion += "-" + 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
eshVersion += "-SNAPSHOT"
esVersion += "-SNAPSHOT"
buildToolsVersion += "-SNAPSHOT"
}
props.put("eshadoop", eshVersion)
props.put("elasticsearch", esVersion)
props.put("build-tools", buildToolsVersion)
repositories {
gradlePluginPortal()
mavenCentral()
// For Elasticsearch 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 {
maven { url = "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url = "https://artifacts-snapshot.elastic.co/elasticsearch/${esVersion}/maven" }
}
}
dependencies {
compileOnly gradleApi()
compileOnly localGroovy()
// Required for dependency licenses task
implementation 'org.apache.rat:apache-rat:0.11'
implementation 'commons-codec:commons-codec:1.12'
if (localRepo) {
implementation name: "build-tools-${buildToolsVersion}"
} else {
implementation group: 'org.elasticsearch.gradle', name: 'build-tools', version: buildToolsVersion
}
}
// write the updated properties to a temp property file
File tempPropertiesFile = new File(project.buildDir, "esh-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
}