-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathbuild.gradle
More file actions
237 lines (210 loc) · 8.35 KB
/
Copy pathbuild.gradle
File metadata and controls
237 lines (210 loc) · 8.35 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
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
import org.opensearch.gradle.ConcatFilesTask
import org.opensearch.gradle.DependenciesInfoTask
import org.opensearch.gradle.precommit.DependencyLicensesTask
import org.opensearch.hadoop.gradle.BuildPlugin
apply plugin: 'opensearch.hadoop.build'
description = "OpenSearch for Apache Hadoop"
base {
archivesName = 'opensearch-hadoop'
}
def sparkVariantIncluded = 'spark35scala212'
configurations {
embedded {
canBeResolved = true
canBeConsumed = false
transitive = false
}
javadocDependencies {
canBeResolved = true
canBeConsumed = false
}
compileClasspath {
extendsFrom javadocDependencies
}
dist {
canBeResolved = true
canBeConsumed = false
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, 'packaging'))
}
}
sparkExtraJars {
canBeResolved = true
canBeConsumed = false
transitive = false
}
thirdPartyShaded {
canBeResolved = true
canBeConsumed = false
transitive = false
}
licenseChecks {
extendsFrom thirdPartyShaded
extendsFrom runtimeClasspath
}
}
BuildPlugin.disableTransitiveDependencies(project, project.configurations.thirdPartyShaded)
def distProjects = [":opensearch-hadoop-mr", ":opensearch-hadoop-hive",
":opensearch-spark-35"]
distProjects.each { distProject ->
def configureDistDependency = { Dependency dependency ->
if (distProject == ":opensearch-spark-35") {
dependency.capabilities {
requireCapability("org.opensearch.spark.sql.variant:$sparkVariantIncluded:$project.version")
}
}
}
dependencies {
// This is only going to pull in each project's regular jar to create the project-wide uberjar.
add('embedded', project(distProject), configureDistDependency)
// To squash Javadoc warnings.
add('javadocDependencies', project(distProject), configureDistDependency)
// This will pull all java sources (including generated) for the project-wide javadoc.
add('javadocSources', project(distProject), configureDistDependency)
// This will pull all non-generated sources for the project-wide source jar.
add('additionalSources', project(distProject), configureDistDependency)
// This will pull in the regular jar, javadoc jar, and source jar to be packaged in the distribution.
add('dist', project(distProject), configureDistDependency)
}
}
// Additional Spark variant jars to include in the distribution zip (not in the uber jar)
['spark30scala212', 'spark30scala213'].each { variant ->
dependencies {
add('sparkExtraJars', project(":opensearch-spark-30")) {
capabilities {
requireCapability("org.opensearch.spark.sql.variant:$variant:$project.version")
}
}
}
}
['spark35scala213'].each { variant ->
dependencies {
add('sparkExtraJars', project(":opensearch-spark-35")) {
capabilities {
requireCapability("org.opensearch.spark.sql.variant:$variant:$project.version")
}
}
}
}
dependencies {
sparkExtraJars(project(":opensearch-spark-40")) {
capabilities {
requireCapability("org.opensearch.spark.sql.variant:spark40scala213:$project.version")
}
}
}
dependencies {
// For Uber pom (and Javadoc to a lesser extent)
thirdPartyShaded("commons-httpclient:commons-httpclient:3.1")
thirdPartyShaded("org.codehaus.jackson:jackson-mapper-asl:${project.ext.jacksonVersion}")
thirdPartyShaded("org.codehaus.jackson:jackson-core-asl:${project.ext.jacksonVersion}")
implementation("commons-logging:commons-logging:1.4.0")
implementation("commons-codec:commons-codec:1.22.0")
implementation("javax.xml.bind:jaxb-api:2.3.1")
implementation("org.apache.hive:hive-service:$hiveVersion") {
exclude module: "log4j-slf4j-impl"
}
implementation("org.apache.hive:hive-exec:$hiveVersion")
implementation("org.apache.hive:hive-metastore:$hiveVersion")
implementation("org.apache.spark:spark-core_${project.ext.scala212MajorVersion}:$spark35Version") {
exclude group: 'javax.servlet'
exclude group: 'org.apache.hadoop'
}
implementation("org.apache.spark:spark-yarn_${project.ext.scala212MajorVersion}:$spark35Version") {
exclude group: 'org.apache.hadoop'
}
implementation("org.apache.spark:spark-sql_${project.ext.scala212MajorVersion}:$spark35Version") {
exclude group: 'org.apache.hadoop'
}
implementation("org.apache.spark:spark-streaming_${project.ext.scala212MajorVersion}:$spark35Version") {
exclude group: 'org.apache.hadoop'
}
implementation("org.scala-lang:scala-library:$scala212Version")
implementation("org.scala-lang:scala-reflect:$scala212Version")
implementation(project.ext.hadoopClient)
implementation("org.apache.hadoop:hadoop-common:${project.ext.hadoopVersion}")
implementation("org.apache.hadoop:hadoop-mapreduce-client-core:${project.ext.hadoopVersion}")
implementation("joda-time:joda-time:$jodaVersion")
compileOnly("org.apache.spark:spark-catalyst_${project.ext.scala212MajorVersion}:$spark35Version")
}
// Configure uber jar
jar {
dependsOn(project.configurations.embedded)
manifest {
attributes['Implementation-Title'] = 'opensearch-hadoop'
}
from(project.configurations.embedded.collect { it.isDirectory() ? it : zipTree(it)}) {
include "org/opensearch/**"
include "opensearch-hadoop-build.properties"
include "META-INF/services/*"
}
// Each integration will be copying it's entire jar contents into this master jar.
// There will be lots of duplicates since they all package up the core code inside of them.
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
javadoc {
options {
header = "opensearch-hadoop"
}
}
publishing {
publications {
main {
getPom().withXml { XmlProvider xml ->
Node root = xml.asNode()
// add clojars repo to pom
Node repositories = root.appendNode('repositories')
Node repository = repositories.appendNode('repository')
repository.appendNode('id', 'clojars.org')
repository.appendNode('url', 'https://clojars.org/repo')
// Correct the artifact Id, otherwise it is listed as 'dist'
root.get('artifactId').get(0).setValue(project.base.archivesName.get())
}
}
}
}
// Name of the directory under the root of the zip file that will contain the zip contents
String zipContentDir = "opensearch-hadoop-${project.version}"
// Create a zip task for creating the distribution
task('distZip', type: Zip) {
group = 'Distribution'
description = "Builds zip archive, containing all jars and docs, suitable for download page."
dependsOn(tasks.pack)
from(project.rootDir) {
include('README.md')
include('LICENSE.txt')
include('NOTICE.txt')
into(zipContentDir)
}
into("$zipContentDir/dist") {
from(project.configurations.dist)
from(project.configurations.sparkExtraJars)
from(tasks.jar)
from(tasks.javadocJar)
from(tasks.sourcesJar)
}
}
distribution {
dependsOn(distZip)
}
// Add a task in the root project that collects all the dependencyReport data for each project
// Concatenates the dependencies CSV files into a single file
task generateDependenciesReport(type: ConcatFilesTask) { concatDepsTask ->
dependsOn rootProject.allprojects.collect { it.tasks.withType(DependenciesInfoTask) }
rootProject.allprojects.collect {
files = fileTree(dir: project.rootDir, include: '**/dependencies.csv' )
it.tasks.withType(DependenciesInfoTask) { depTask ->
concatDepsTask.dependsOn depTask
concatDepsTask.getFiles().from(depTask.outputFile)
}
}
headerLine = "name,version,url,license"
target = new File(System.getProperty('csv')?: "${project.buildDir}/reports/dependencies/opensearch-hadoop-dependencies.csv")
}
project.tasks.named('dependencyLicenses', DependencyLicensesTask) {
it.dependencies = project.configurations.licenseChecks.incoming.artifactView {
componentFilter {
!(it instanceof ProjectComponentIdentifier)
}
}.files
}