forked from unchartedsoftware/salt-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
238 lines (205 loc) · 6.84 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
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
238
/**
* $ ./gradlew
* The default task will build the project and run the test suite inside
* your local spark environment (spark-submit must be on the PATH).
*
* To build and install library, run ./gradlew jar install
*
* To generate documentation and docs JAR, run ./gradlew docsJar
*
* A coverage report will be present at build/reports/scoverage/index.html
*
*/
buildscript {
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.github.maiflai:gradle-scalatest:0.9'
classpath 'org.scoverage:gradle-scoverage:1.0.9'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.4.0'
classpath 'org.github.ngbinh.scalastyle:gradle-scalastyle-plugin_2.11:0.7.2'
}
}
apply plugin: 'java'
apply plugin: 'scala'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'com.github.maiflai.scalatest'
apply plugin: 'scoverage'
apply plugin: 'idea'
apply plugin: 'com.github.kt3k.coveralls'
apply plugin: 'scalaStyle'
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
mavenLocal()
mavenCentral()
}
configurations {
provided
}
group = 'software.uncharted.salt'
archivesBaseName = 'salt-core'
version = '3.0.0-SNAPSHOT'
project.ext {
scalaBinaryVersion = '2.10'
scalaVersion = '2.10.6'
sparkVersion = System.getenv("SPARK_VERSION") ?: '1.6.0'
scoverageVersion = '1.1.1'
artifactName = archivesBaseName
description = 'A Spark Scala library for creating interactive visualizations to explore massive datasets.'
inceptionYear = '2015'
url = 'https://github.com/unchartedsoftware/salt'
ossrhUsername = project.hasProperty('ossrhUsername') ? project.getProperty('ossrhUsername') : ''
ossrhPassword = project.hasProperty('ossrhPassword') ? project.getProperty('ossrhPassword') : ''
}
jar {
baseName = "${artifactName}"
version = version
dependsOn configurations.runtime
from {
(configurations.runtime - configurations.provided).collect {
it.isDirectory() ? it : zipTree(it)
}
} {
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
}
}
task docs(type: ScalaDoc) {
source = sourceSets.main.allScala
}
task docsJar(type: Jar, dependsOn: docs) {
classifier = 'javadoc'
from docs.destinationDir
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
checkScoverage {
minimumRate = 0.9
}
task testJar(type: Jar) {
classifier = 'tests'
from sourceSets.test.output
}
task test(overwrite: true, type: Exec, dependsOn: [jar, jarScoverage, testJar, docsJar, scalaStyle]) {
executable = 'spark-submit'
args = ["--packages","org.scalatest:scalatest_${scalaBinaryVersion}:2.2.5,org.scoverage:scalac-scoverage-runtime_${scalaBinaryVersion}:${scoverageVersion}","--jars","/opt/salt/build/libs/${artifactName}-${version}-scoverage.jar","--class","software.uncharted.salt.Main","build/libs/${artifactName}-${version}-tests.jar"]
}
task debug(overwrite: true, type: Exec, dependsOn: [jar, jarScoverage, testJar, docsJar, scalaStyle]) {
executable = 'spark-submit'
environment.put 'SPARK_JAVA_OPTS', '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9999'
args = ["--packages","org.scalatest:scalatest_${scalaBinaryVersion}:2.2.5,org.scoverage:scalac-scoverage-runtime_${scalaBinaryVersion}:${scoverageVersion}","--jars","/opt/salt/build/libs/${artifactName}-${version}-scoverage.jar","--class","software.uncharted.salt.Main","build/libs/${artifactName}-${version}-tests.jar"]
}
task coverage(overwrite: true, dependsOn: test) << {
reportScoverage.execute()
checkScoverage.execute()
}
coveralls {
coberturaReportPath = "${buildDir}/reports/scoverage/cobertura.xml"
}
//////////////////////////////////////
//BEGIN nexus oss
//////////////////////////////////////
artifacts {
archives docsJar, testJar, sourcesJar
}
signing {
sign configurations.archives
}
//make sure assemble doesn't depend on signing
gradle.taskGraph.whenReady { taskGraph ->
def tasks = taskGraph.getAllTasks()
if (tasks.find {it.name == 'assemble'}) {
tasks.findAll {it.name == 'signArchives' || it.name == 'signDocsJar' || it.name == 'signTestJar' || it.name == 'signSourcesJar'}.each { task ->
task.enabled = false
}
}
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom.project {
name = artifactName
packaging = 'jar'
// optionally artifactId can be defined here
description = description
url = url
scm {
connection 'scm:git:git://github.com/unchartedsoftware/salt.git'
developerConnection 'scm:git:[email protected]:unchartedsoftware/salt.git'
url 'https://github.com/unchartedsoftware/salt'
}
licenses {
license {
name 'The Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'smcintyre'
name = 'Sean McIntyre'
email = '[email protected]'
}
}
}
}
}
}
//////////////////////////////////////
//END nexus oss
//////////////////////////////////////
scalaStyle {
configLocation = "scalastyle_config.xml"
includeTestSourceDirectory = true
source = sourceSets.main.allScala
testSource = sourceSets.test.allScala
failOnWarning = true
}
sourceSets {
main { compileClasspath += configurations.provided }
test {
compileClasspath += configurations.provided
runtimeClasspath += configurations.provided
}
scoverage { compileClasspath += configurations.provided }
testScoverage { compileClasspath += configurations.provided }
}
dependencies {
//scala
provided("org.scala-lang:scala-library:${scalaVersion}")
//spark
provided "org.apache.spark:spark-core_${scalaBinaryVersion}:${sparkVersion}"
provided "org.apache.spark:spark-sql_${scalaBinaryVersion}:${sparkVersion}"
//scalatest
testCompile "org.scalatest:scalatest_${scalaBinaryVersion}:2.2.5"
testRuntime 'org.pegdown:pegdown:1.1.0'
//scoverage
scoverage "org.scoverage:scalac-scoverage-plugin_${scalaBinaryVersion}:${scoverageVersion}",
"org.scoverage:scalac-scoverage-runtime_${scalaBinaryVersion}:${scoverageVersion}"
}
task wrapper(type: Wrapper) {
gradleVersion = '2.10'
}
idea {
module {
inheritOutputDirs = false
outputDir = file("$buildDir/classes/main/")
scopes.PROVIDED.plus += [ configurations.provided ]
}
}
defaultTasks 'coverage'