Skip to content

Instantly share code, notes, and snippets.

@jarutis
Created May 21, 2016 05:29
Show Gist options
  • Save jarutis/1b8aedf5b13146c52a6e5cb9e2a2feca to your computer and use it in GitHub Desktop.
Save jarutis/1b8aedf5b13146c52a6e5cb9e2a2feca to your computer and use it in GitHub Desktop.
build.gradle for which ensime fails to collect provided deps
apply plugin: AddEnsimePlugin
class AddEnsimePlugin implements Plugin<Gradle> {
def supportedPlugins = [
'org.gradle.api.plugins.JavaPlugin',
'org.gradle.api.plugins.ScalaPlugin',
'jp.leafytree.gradle.AndroidScalaPlugin'
]
void apply(Gradle gradle) {
def added = false
gradle.allprojects { project ->
project.with {
if (parent == null) {
buildscript {
repositories {
jcenter()
maven {
name 'JFrog OSS Snapshot Repository'
url 'http://oss.jfrog.org/oss-snapshot-local'
}
}
dependencies {
classpath 'net.coacoas.gradle:ensime-gradle:0.2.7'
}
}
}
plugins.whenPluginAdded { plugin ->
if (!added && supportedPlugins.contains(plugin.class.name)) {
rootProject.apply plugin: 'org.ensime.gradle'
added = true
println("[Ensime] Using scala version " + project.scalaVersionFull)
ensime {
scalaVersion = project.scalaVersionFull
}
}
}
}
}
}
}
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'org.github.ngbinh.scalastyle:gradle-scalastyle-plugin_2.11:0.7.2'
}
}
plugins {
id 'net.nemerosa.versioning' version '1.5.0'
}
project(':spark') {
apply plugin: 'scala'
apply plugin: 'scalaStyle'
addCucumberSuite 'cucumberTest'
configurations.testCompile {
resolutionStrategy.force "com.google.guava:guava:14.0.1"
}
plugins.withType(IdeaPlugin) {
idea.module.scopes.PROVIDED.plus = [ configurations.provided, configurations.cucumberTestCompile ]
}
ext {
sparkVersion = '1.6.0'
hbaseVersion = "1.0.0-${cdhVersion}"
hadoopVersion = "2.6.0-${cdhVersion}"
cucumberVersion = '1.2.4'
}
if ((project.hasProperty('tags') && project.tags.split(",").contains("@dev"))) {
// running with @dev - no parallelism
project.set("cucumberParallelism", 1)
} else if (System.getenv("HOME") != null) {
// running on Jenkins. Jenkins reports 2 cores via availableProcessors, but
// the server has 32. Force more than 2 for cucumber.
project.set("cucumberParallelism", 8)
} else {
// otherwise use all available cores by default
project.set("cucumberParallelism", Runtime.runtime.availableProcessors())
}
cucumberTest {
stepDefinitionRoots = ['steps', 'steps.setup']
isStrict = true
maxParallelForks = project.cucumberParallelism
junitReport = true
tags = project.hasProperty('tags') && project.tags ? project.tags.split(',') : ['~@ignore']
}
cucumberTest.systemProperty("-XX:MaxPermSize", "256M")
cucumberTest.systemProperty("-Dspark.serializer", "org.apache.spark.serializer.KryoSerializer")
cucumberTest.systemProperty("-Dspark.kryo.registrator", "vinted.warehouse.serializers.VintedKryoRegistrator")
task cucumber(dependsOn: cucumberTest) // alias cucumber to cucumberTest
dependencies {
provided "org.apache.spark:spark-core_${scalaVersion}:${sparkVersion}"
provided "org.apache.spark:spark-sql_${scalaVersion}:${sparkVersion}"
provided "org.apache.spark:spark-hive_${scalaVersion}:${sparkVersion}"
provided "org.apache.hadoop:hadoop-common:${hadoopVersion}"
provided 'org.apache.hadoop:hadoop-mapreduce-client-core:${hadoopVersion}'
// hbase rdd
compile "eu.unicredit:hbase-rdd_${scalaVersion}:0.5.3"
provided "org.apache.hbase:hbase-common:${hbaseVersion}"
provided "org.apache.hbase:hbase-client:${hbaseVersion}"
provided "org.apache.hbase:hbase-server:${hbaseVersion}"
// hbase minicluster
testCompile "org.apache.hbase:hbase-testing-util:0.98.11-hadoop2"
testCompile "org.xerial.snappy:snappy-java:1.1.2-RC3"
// guava < 15.0 necessary to start HBase mini cluster, more here http://goo.gl/PfZzJ9
testCompile "com.google.guava:guava:14.0.1"
// algebird
compile "com.twitter:chill-algebird_${scalaVersion}:0.6.0"
compile "com.twitter:algebird-core_${scalaVersion}:0.11.0"
// cucumber tests
cucumberTestCompile "info.cukes:cucumber-scala_${scalaVersion}:${cucumberVersion}"
cucumberTestCompile "org.apache.spark:spark-core_${scalaVersion}:${sparkVersion}"
cucumberTestCompile "org.apache.spark:spark-sql_${scalaVersion}:${sparkVersion}"
cucumberTestCompile "org.apache.spark:spark-hive_${scalaVersion}:${sparkVersion}"
cucumberTestCompile "software.betamax:betamax-core:2.0.0-SNAPSHOT"
cucumberTestCompile "org.codehaus.groovy:groovy-all:1.8.8"
cucumberTestCompile "org.scalatest:scalatest_${scalaVersion}:2+"
testCompile "org.scalatest:scalatest_${scalaVersion}:2+"
testCompile "org.scalacheck:scalacheck_${scalaVersion}:1.12.2"
testCompile "net.manub:scalatest-embedded-kafka_${scalaVersion}:0.4.3"
compile 'joda-time:joda-time:2.3'
compile 'org.joda:joda-convert:1.7'
compile 'org.apache.commons:commons-math3:3.6'
compile 'commons-codec:commons-codec:1.10'
compile "com.owlike:genson-scala_${scalaVersion}:1.3"
compile 'net.sf.uadetector:uadetector-resources:2014.10'
compile 'com.typesafe:config:1.2.1'
compile 'org.roaringbitmap:RoaringBitmap:0.4.9'
compile 'com.vinted:ab-java:1.0.6'
compile "com.tresata:spark-kafka_${scalaVersion}:0.6.0"
compile("com.sanoma.cda:maxmind-geoip2-scala_${scalaVersion}:1.5.1") {
exclude(group: "com.fasterxml.jackson.core")
exclude(group: "com.google.guava")
}
compile files('libs/btc-ascii-table-1.0.jar')
compile "org.scalactic:scalactic_${scalaVersion}:3.0.0-M15"
tattletale "org.jboss.tattletale:tattletale:1.2.0.Beta2"
}
sourceSets {
main.compileClasspath += configurations.provided
test.compileClasspath += configurations.provided
test.runtimeClasspath += configurations.provided
}
def configureScalaTest = {
main = 'org.scalatest.tools.Runner'
args = [
'-R', 'build/classes/test',
// D - print test durations
// I - print a short summary of failed tests at the end
'-oDI',
'-u', 'build/test-results',
'-w', project.hasProperty('package') ? project.package : ''
]
classpath = sourceSets.test.runtimeClasspath
jvmArgs ("-XX:MaxPermSize=256m",
"-Dspark.serializer=org.apache.spark.serializer.KryoSerializer",
"-Dspark.kryo.registrator=vinted.warehouse.serializers.VintedKryoRegistrator",
"-Dorg.xerial.snappy.disable.bundled.libs=false")
}
task scalaTestFast(type: JavaExec) {
configure configureScalaTest
// exclude slow tests, will run in scalaTestSlow
args += ['-l', 'org.scalatest.tags.Slow']
}
task scalaTestSlow(type: JavaExec) {
configure configureScalaTest
args += ['-n', 'org.scalatest.tags.Slow']
}
task(scalaTest) << {
}
// run slow tests after the fasts ones, and only if slow tests are not disabled
// e.g. so one can write ./gradlew build -PexcludeSlowTests
scalaTest.dependsOn scalaTestFast
scalaTest.dependsOn scalaTestSlow
scalaTestSlow.mustRunAfter scalaTestFast
if (project.hasProperty('excludeSlowTests')) {
// gradle will report the task as SKIPPED
scalaTestSlow.enabled = false
}
test.dependsOn scalaTest
scalaTest.mustRunAfter scalaStyle
tasks.withType(ScalaCompile).each {
it.scalaCompileOptions.useAnt = false
it.scalaCompileOptions.optimize = true
it.scalaCompileOptions.additionalParameters = []
}
versionFile {
file = new File(project.buildDir, 'resources/main/application.properties')
}
shadowJar {
classifier = 'dist'
}
shadowJar.dependsOn versionDisplay
shadowJar.dependsOn versionFile
build.dependsOn clean
build.mustRunAfter clean
build.dependsOn shadowJar
scalaStyle {
configLocation = "scalastyle-config.xml"
includeTestSourceDirectory = true
source = "src/main/scala"
}
test.dependsOn scalaStyle
// https://github.com/ngbinh/gradle-scalastyle-plugin
// for inspecting dependency and other issues
task createTattletaleProperties {
ext.props = [reports:"*", enableDot:"true"]
ext.destFile = new File(buildDir, "tattletale.properties")
inputs.properties props
outputs.file destFile
doLast {
def properties = new Properties()
properties.putAll(props)
destFile.withOutputStream { os ->
properties.store(os, null)
}
}
}
test.dependsOn project.tasks.cucumber
project.tasks.cucumber.mustRunAfter scalaStyle
task tattletale(type: JavaExec, dependsOn: [createTattletaleProperties, jar]) {
ext.outputDir = new File(buildDir, "reports/tattletale")
outputs.dir outputDir
inputs.files configurations.runtime.files
inputs.file jar.archivePath
doFirst {
outputDir.mkdirs()
}
main = "org.jboss.tattletale.Main"
classpath = configurations.tattletale
systemProperties "jboss-tattletale.properties": createTattletaleProperties.destFile
args([configurations.runtime.files, jar.archivePath].flatten().join("#"))
args outputDir
}
}
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url 'https://github.com/saulius/mvn-repo/raw/master/releases' }
maven {
url "http://repo.bodar.com"
}
}
dependencies {
classpath 'com.github.saulius:gradle-cucumber-jvm-plugin:0.8.1'
}
}
plugins {
id 'com.github.johnrengelman.shadow' version '1.2.3'
}
allprojects {
ext {
scalaVersion = "2.10"
scalaVersionFull = "2.10.5"
cdhVersion = "cdh5.5.1"
}
apply plugin: 'idea'
apply plugin: 'eclipse'
configurations {
provided
provided.extendsFrom(compile)
tattletale
}
task wrapper(type: Wrapper) {
gradleVersion = '2.13'
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'cucumber-jvm'
apply plugin: 'com.github.johnrengelman.shadow'
repositories {
mavenCentral()
maven {
url 'http://repo.typesafe.com/typesafe/releases/'
}
maven {
url 'https://repository.cloudera.com/artifactory/cloudera-repos/'
}
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
maven { url 'https://github.com/vinted/android-binaries/raw/master' }
maven { url 'https://github.com/saulius/mvn-repo/raw/master/releases' }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment