-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathbuild.gradle
184 lines (162 loc) · 7.22 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
* This file is part of ReadonlyREST.
*
* ReadonlyREST is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ReadonlyREST is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ReadonlyREST. If not, see http://www.gnu.org/licenses/
*/
import org.gradle.crypto.checksum.Checksum
plugins {
id 'org.gradle.crypto.checksum'
id "readonlyrest.plugin-common-conventions"
}
def pluginFullName = pluginName + '-' + version
def projectJavaLanguageVersion = JavaLanguageVersion.of(11)
def moduleEsVersion = project.property('esVersion') != null ? project.property('esVersion') : project.property('latestSupportedEsVersion')
def releaseDockerImageLatest = 'beshultd/elasticsearch-readonlyrest:' + moduleEsVersion + '-ror-latest'
def releaseDockerImageVersion = 'beshultd/elasticsearch-readonlyrest:' + moduleEsVersion + '-ror-' + pluginVersion
def preBuildDockerImageVersion = 'beshultd/elasticsearch-readonlyrest-dev:' + moduleEsVersion + '-ror-' + pluginVersion
java {
toolchain {
languageVersion = projectJavaLanguageVersion
}
}
dependencies {
implementation project(path: ':core')
implementation project(path: ':ror-tools', configuration: 'shadow')
implementation project(path: ':ror-tools-core')
implementation group: 'org.elasticsearch', name: 'elasticsearch' , version: moduleEsVersion
implementation group: 'org.elasticsearch.client', name: 'elasticsearch-rest-high-level-client', version: moduleEsVersion
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.13'
compileOnly group: 'org.codelibs.elasticsearch.lib', name: 'plugin-classloader', version: moduleEsVersion
compileOnly group: 'org.locationtech.spatial4j', name: 'spatial4j', version: '0.7'
implementation group: 'org.elasticsearch.plugin', name: 'transport-netty4-client', version: moduleEsVersion
}
configurations {
wagon
distJars {
exclude group: 'org.elasticsearch'
exclude group: 'lucene-core'
exclude module: 'log4j-api'
exclude module: 'log4j-core'
exclude group: 'lucene-analyzers-common'
exclude group: 'org.apache.commons'
exclude group: 'org.yaml'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
}
}
tasks.withType(ScalaCompile).configureEach {
scalaCompileOptions.additionalParameters = [
// The "-Wunused:nowarn" flag is unused for now, see plugin-common-conventions.gradle for details
//"-Wunused:-nowarn" // depending on es version, some methods are deprecated or not
]
}
tasks.register('cleanOldData') {
doLast {
delete 'build/tmp/' + pluginFullName
}
}
tasks.register('jarHellCheck', JavaExec) {
outputs.upToDateWhen { false }
mainClass.set("org.elasticsearch.bootstrap.JarHell")
classpath = project.sourceSets.main.compileClasspath.filter { it.exists() }
javaLauncher = javaToolchains.launcherFor {
languageVersion = projectJavaLanguageVersion
}
}
tasks.register('resolvePluginDescriptorTemplate', Copy) {
outputs.upToDateWhen { false }
from './plugin-metadata'
into 'build/tmp/' + pluginFullName
expand([
'descriptor': [
'name' : pluginName,
'pluginVersion': pluginVersion,
'esVersion' : moduleEsVersion
]
])
}
tasks.register('buildRorPluginZip') {
dependsOn(packageRorPlugin, createRorPluginChecksums)
}
tasks.register('packageRorPlugin', Zip) {
dependsOn(cleanOldData, jarHellCheck, toJar, resolvePluginDescriptorTemplate)
outputs.upToDateWhen { false }
archivesBaseName = pluginName
into('.') {
from configurations.distJars.filter { x -> !x.name.contains('spatial4j') && !x.name.contains('jts') }
from 'build/libs/' + pluginFullName + '.jar'
from 'build/tmp/' + pluginFullName
}
}
tasks.register('createRorPluginChecksums', Checksum) {
dependsOn(packageRorPlugin)
def distributionsDir = layout.buildDirectory.dir("distributions")
outputs.upToDateWhen { false }
inputFiles.setFrom(packageRorPlugin.archiveFile)
outputDirectory.set(distributionsDir)
checksumAlgorithm.set(Checksum.Algorithm.SHA512)
}
tasks.register('uploadRorPluginToS3', Exec) {
dependsOn(packageRorPlugin, createRorPluginChecksums)
def distributionsDir = layout.buildDirectory.get().asFile.path + "/distributions"
def pluginFileZip = distributionsDir + "/" + pluginFullName + ".zip"
def pluginSha1 = distributionsDir + "/" + pluginFullName + ".zip.sha1"
def pluginSha512 = distributionsDir + "/" + pluginFullName + ".zip.sha512"
def targetS3Dir = "build/" + pluginVersion + "/"
commandLine '../ci/upload-files-to-s3.sh', pluginFileZip, pluginSha512, pluginSha1, targetS3Dir
}
tasks.register('prepareDockerImageFiles', Copy) {
dependsOn packageRorPlugin
outputs.upToDateWhen { false }
from layout.projectDirectory.file("Dockerfile")
from layout.buildDirectory.file("distributions/" + pluginFullName + ".zip")
from rootProject.files("docker-image")
into layout.buildDirectory.dir("docker-image")
}
tasks.register('pushRorDockerImage', Exec) {
dependsOn('packageRorPlugin', 'prepareDockerImageFiles', 'prepareMultiplatformBuilder')
group 'docker'
executable 'docker'
workingDir 'build/docker-image'
args = [
'buildx', 'build', '--platform', 'linux/amd64',
'--build-arg', 'ROR_VERSION=' + pluginVersion, '--build-arg', "ES_VERSION=" + project.properties['esVersion'],
'-t', releaseDockerImageLatest, '-t', releaseDockerImageVersion,
'--push', '.'
]
}
tasks.register('pushRorPreBuildDockerImage', Exec) {
dependsOn('packageRorPlugin', 'prepareDockerImageFiles', 'prepareMultiplatformBuilder')
group 'docker'
executable 'docker'
workingDir 'build/docker-image'
args = [
'buildx', 'build', '--platform', 'linux/amd64',
'--build-arg', 'ROR_VERSION=' + pluginVersion, '--build-arg', "ES_VERSION=" + project.properties['esVersion'],
'-t', preBuildDockerImageVersion,
'--push', '.'
]
}
tasks.register('localRorDockerImage', Exec) {
// we prepare docker image for local architecture - the image is loaded to local registry
dependsOn('packageRorPlugin', 'prepareDockerImageFiles')
group 'docker'
executable 'docker'
workingDir 'build/docker-image'
args = [
'buildx', 'build',
'--build-arg', 'ROR_VERSION=' + pluginVersion, '--build-arg', "ES_VERSION=" + project.properties['esVersion'],
'-t', releaseDockerImageVersion,
'--load', '.'
]
}