-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
131 lines (102 loc) · 4.1 KB
/
build.gradle
File metadata and controls
131 lines (102 loc) · 4.1 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
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'scala'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'distribution'
apply plugin: 'bol-base'
buildscript {
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.1'
}
}
version = deriveBolVersionFromEnvironment()
ext.isSnapshot = version.endsWith("-SNAPSHOT")
group = 'com.bol.services.genderclassification'
ext.libVersion = [
slf4j: '1.7.5',
scala: '2.11',
]
libVersion.scala_lib = "${libVersion.scala}.1"
repositories {
mavenLocal()
maven { url = 'http://artifactory.dev.bol.com/artifactory/repo' }
}
dependencies {
compile group: 'org.apache.spark', name:'spark-mllib_2.11', version: '1.3.1'
compile group: 'org.slf4j', name:'slf4j-api', version: '1.7.2'
compile group: 'ch.qos.logback', name:'logback-classic', version: '1.0.9'
compile group: 'ch.qos.logback', name:'logback-core', version: '1.0.9'
compile "com.typesafe.scala-logging:scala-logging_${libVersion.scala}:3.1.0"
testCompile "org.scalatest:scalatest_${libVersion.scala}:2.2.4"
testCompile 'org.mockito:mockito-all:1.8.4'
}
configurations {
/* We don't want the hadoop/hbase dependencies in our shadowJar because they are pro */
runtime.exclude module: 'hadoop-client'
runtime.exclude module: 'hadoop-common'
runtime.exclude module: 'spark-streaming_2.11'
runtime.exclude module: 'spark-core_2.11'
runtime.exclude module: 'spark-sql_2.11'
runtime.exclude module: 'spark-graphx_2.11'
runtime.exclude module: 'spark-core_2.11'
}
task assemble(overwrite: true, dependsOn: ['createTar'])
task copyBin(type: Copy) from "bin" into "$buildDir/contents/bin"
task copyLib(type: Copy) from "$buildDir/libs/brandAutocompleteBuilder-${version}-all.jar" into "$buildDir/contents/lib"
task copyEtc(type: Copy) from "etc" into "$buildDir/contents/etc"
task createTar(type: Tar, dependsOn: ['clean', 'shadowJar', 'copyBin', 'copyEtc', 'copyLib']) {
from "$buildDir/contents/"
compression = Compression.GZIP
archiveName = "${version}/bacr-${version}.tar.gz"
}
copyBin.dependsOn clean
copyEtc.dependsOn clean
shadowJar.dependsOn clean
copyLib.dependsOn shadowJar
shadowJar {
manifest {
attributes 'Implementation-Title': 'Brand AutoComplete Builder',
'Artifact-version': project.version
}
zip64 true
}
// =====================================================================================================================
// == IDE Integration
// =====================================================================================================================
import groovy.xml.StreamingMarkupBuilder
import groovy.xml.XmlUtil
def addScalaLibraryToIdeaModuleNode(node) {
def moduleRootManager = node.component.find { it['@name'] == 'NewModuleRootManager' }
def scalaSdkNamePrefix = 'scala-sdk-'
def scalaSdkName = scalaSdkNamePrefix + libVersion.scala_lib
def scalaSdkLibrary = moduleRootManager.orderEntry.find { it['@type'] == 'library' && it['@name'].startsWith(scalaSdkNamePrefix) }
if (scalaSdkLibrary != null) {
moduleRootManager.remove(scalaSdkLibrary)
}
moduleRootManager.appendNode('orderEntry', [type: 'library', name: scalaSdkName, level: 'application'])
}
def removeScalaFacetFromIdeaModule(moduleFile) {
def node = new XmlSlurper().parse(moduleFile)
def facetManager = node.component.find { it['@name'] == 'FacetManager' }
if(facetManager != null) {
def scala = facetManager.facet.find { it['@type'] == 'scala'}
if(scala != null) {
//delete
scala.replaceNode {}
}
}
moduleFile.withWriter { outWriter ->
XmlUtil.serialize(new StreamingMarkupBuilder().bind{ mkp.yield node }, outWriter)
}
}
gradle.taskGraph.afterTask { Task task, TaskState state ->
if (task.name == 'idea' && !state.failure) {
removeScalaFacetFromIdeaModule(file(new File(task.project.projectDir, task.project.name + '.iml')))
}
}
idea.module.iml {
// Adds scala as a library to the module
withXml {
addScalaLibraryToIdeaModuleNode(it.asNode())
}
}