swh:1:snp:764524290233376de64947417267228741ce2485
Tip revision: ba743dc3315dc49109913b3253da8e841b08f2de authored by Bhavani Sudha Saktheeswaran on 27 May 2014, 19:57:06 UTC
Releasing Voldemort 1.8.3
Releasing Voldemort 1.8.3
Tip revision: ba743dc
build.gradle
import java.util.jar.JarEntry;
apply plugin: 'java'
apply plugin: 'scala'
def String getProjectProperty(String propertyName) {
String propertyValue = "null"
if (hasProperty(propertyName)) {
propertyValue = this.properties[propertyName]
}
else {
throw GradleScriptException("PropertyName " + propertyName + " is not defined in properties file")
}
return propertyValue
}
def projectName = "voldemort"
def sourceDir = getProjectProperty('src.dir')
def distDir = getProjectProperty('dist.dir')
def classesDir = getProjectProperty('classes.dir')
def javaDir = getProjectProperty('java.dir')
def libDir = getProjectProperty('lib.dir')
def resourcesDir = getProjectProperty('resources.dir')
def javaDocDir = getProjectProperty('javadoc.dir')
def testClassesDir = getProjectProperty('testclasses.dir')
def commonTestSrcDir = getProjectProperty('commontestsrc.dir')
def unitTestSrcDir = getProjectProperty('unittestsrc.dir')
def intTestSrcDir = getProjectProperty('inttestsrc.dir')
def longTestSrcDir = getProjectProperty('longtestsrc.dir')
def contribClassesDir = getProjectProperty('contrib.classes.dir')
def contribRootDir = getProjectProperty('contrib.root.dir')
def voldVersion = getProjectProperty('curr.release')
def javacVersion = getProjectProperty('javac.version')
def scalaVersion = getProjectProperty('scalac.version')
//This is the javaCompile variable version. Directly defining 'def version' will override this and cause nightmare
version = voldVersion
def archiveDirectoryName = projectName + '-' + version
def archiveDirectoryPath = distDir + "/" + archiveDirectoryName
def deleteDirectoryContents(directory) {
project.file(directory).deleteDir()
project.file(directory).mkdirs()
}
println 'java source target compatibility version ' + javacVersion
sourceCompatibility = javacVersion
targetCompatibility = javacVersion
compileJava.options.debug = true
tasks.withType(ScalaCompile) {
scalaClasspath = files("lib/scala-compiler-${scalaVersion}.jar",
"lib/scala-reflect-${scalaVersion}.jar",
"lib/scala-library-${scalaVersion}.jar")
}
repositories {
flatDir { dirs libDir }
flatDir { dirs contribRootDir }
}
sourceSets {
main {
java { srcDirs = [javaDir]}
scala {
srcDirs = [sourceDir]
include '**/*.scala'
}
resources {
srcDirs = [javaDir]
include '**/*.xsd'
}
output.classesDir = classesDir
}
buildTest {
java {
srcDirs = [
commonTestSrcDir ,
unitTestSrcDir,
intTestSrcDir ,
longTestSrcDir
]
}
output.classesDir = testClassesDir
compileClasspath += sourceSets.main.runtimeClasspath
}
test {
//There is some gradle weird behavior going on here. If I dont have standard tests
// and only other tests like junitLong gradle completes without running any tests
// and says junit upto date. So including this block and controlling in the task
// block to run only client and server tests which takes 3 minutes.
java {
srcDirs = [unitTestSrcDir ]
}
resources {
srcDir resourcesDir
}
compileClasspath += sourceSets.main.runtimeClasspath + sourceSets.buildTest.runtimeClasspath
}
contrib {
java { srcDirs = [contribRootDir]}
resources {
srcDir resourcesDir
}
compileClasspath += sourceSets.main.runtimeClasspath
output.classesDir = contribClassesDir
}
junitLong {
java {
srcDirs = [longTestSrcDir ]
}
resources {
srcDir resourcesDir
}
compileClasspath += sourceSets.main.runtimeClasspath + sourceSets.buildTest.runtimeClasspath
}
}
compileJava.dependsOn clean
task compileJava.doLast {
project.copy {
from (javaDir) { exclude '**/*.java','**/*.html','**/*.scala', '**/log4j.properties' }
into classesDir
}
project.copy {
from (javaDir) { include 'log4j.properties' }
into resourcesDir
}
}
compileBuildTestJava.doLast {
project.copy {
from (commonTestSrcDir) { exclude '**/*.java','**/*.html' }
from (unitTestSrcDir) { exclude '**/*.java','**/*.html' }
into testClassesDir
}
}
compileContribJava.doLast {
project.copy {
from (contribRootDir + '/ec2-testing/resources')
into contribClassesDir
}
}
dependencies {
compile fileTree(dir: libDir, includes: ['**/*.jar'])
buildTestCompile sourceSets.main.output
contribCompile sourceSets.main.output
contribCompile sourceSets.buildTest.output
testCompile sourceSets.buildTest.output
contribCompile fileTree(dir: contribRootDir, includes: ['**/*.jar'])
buildTestCompile 'junit:junit:4.6'
}
task testJar(type: Jar) {
dependsOn sourceSets.buildTest.output
baseName = projectName + "-test"
from sourceSets.buildTest.output
destinationDir = project.file(distDir)
}
task voldJar(type:Jar) {
baseName = projectName
manifest {
attributes 'Voldemort-Implementation-Version' : version,
'Implementation-Title': 'Voldemort',
'Implementation-Version': version,
'Implementation-Vendor' :'LinkedIn'
}
from sourceSets.main.output
destinationDir = project.file(distDir)
}
task contribJar(type:Jar) {
dependsOn voldJar, testJar, sourceSets.contrib.output
baseName = projectName + "-contrib"
from sourceSets.contrib.output
destinationDir = project.file(distDir)
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'src'
from sourceSets.main.java.srcDirs
destinationDir = project.file(distDir)
}
artifacts {
archives voldJar
archives testJar
archives contribJar
archives sourcesJar
}
clean {
delete(distDir)
doLast { deleteDirectoryContents(javaDocDir) }
}
task copySources (type: Copy) {
from ('.') { include 'bin/**' }
from ('.') { include distDir + '/*.jar'}
from ('.') { exclude distDir + '/**' ,'bin/**' , 'build/**', '.git/**' , '.gradle/**' }
into archiveDirectoryPath
}
task zip (type: Zip) {
dependsOn copySources
baseName = projectName
from(distDir) {
include archiveDirectoryName + '/bin/**'
fileMode = 0755
}
from(distDir) {
include archiveDirectoryName + '/**'
exclude archiveDirectoryName + '/bin/**'
}
destinationDir = project.file(distDir)
}
task tar (type: Tar) {
dependsOn copySources
compression = Compression.GZIP
baseName = projectName
extension = "tar.gz"
from(distDir) {
include archiveDirectoryName + '/bin/**'
fileMode = 0755
}
from(distDir) {
include archiveDirectoryName + '/**'
exclude archiveDirectoryName + '/bin/**'
}
destinationDir = project.file(distDir)
}
jar.dependsOn contribJar,sourcesJar
compileContribJava.dependsOn voldJar
copySources.dependsOn jar
tasks.withType(Test) {
// ant restarts jvm for each tests, If not restarted the test runs into outOfMemory even
// if you set the JVM to 8gb. On inspecting most of the space is consumed by int[] of
// Histogram in the NioSelectorManager. I believe this could be explained by
// creating lots of client factory which creates lot of NIO threads. Did not proceed
// further as I will be maintaining compatbility with ant. Also if you dont fork for each
// tests JMX bean related tests will fail.
// Do not set the max parallelism as there are tests that uses the same port and will
// run into bind exceptions.
maxHeapSize = "2g"
forkEvery = 1
useJUnit()
testLogging {
events "passed", "skipped", "failed"
exceptionFormat = 'full'
}
afterTest { test, result ->
logger.lifecycle("testFinished: $test, result: $result.resultType")
}
//all standard error messages from tests will get routed to 'DEBUG' level messages.
//logging.captureStandardError(LogLevel.DEBUG)
//all standard output messages from tests will get routed to 'DEBUG' level messages.
//logging.captureStandardOutput(LogLevel.DEBUG)
}
task junit(type: Test) {
dependsOn buildTestRuntime
description = "Runs acceptance tests"
include '**/*Test.*'
exclude '**/Abstract*'
testClassesDir = sourceSets.test.output.classesDir
classpath += sourceSets.test.runtimeClasspath
}
task junitLong(type: Test) {
dependsOn buildTestRuntime
description = "Runs long junit tests"
include '**/*Test.*'
testClassesDir = sourceSets.junitLong.output.classesDir
classpath += sourceSets.junitLong.runtimeClasspath
}
task junitRebalance(type: Test) {
dependsOn buildTestRuntime
description = "Runs acceptance tests"
include '**/*Rebalance*Test.*'
exclude '**/Abstract*'
testClassesDir = sourceSets.test.output.classesDir
classpath += sourceSets.test.runtimeClasspath
}
task junitRebalanceLong(type: Test) {
dependsOn buildTestRuntime
description = "Runs acceptance tests"
include '**/*Rebalance*Test.*'
testClassesDir = sourceSets.junitLong.output.classesDir
classpath += sourceSets.junitLong.runtimeClasspath
}
task contribJunit(type: Test) {
dependsOn buildTestRuntime
description = "Run contrib junit tests except EC2 and Krati tests."
include '**/*Test.class'
exclude '**/*PerformanceTest.class'
exclude '**/*RemoteTest.class'
exclude '**/Ec2*Test.class'
exclude '**/Krati*Test.class'
exclude '**/HadoopStoreBuilder*Test.class'
testClassesDir = sourceSets.contrib.output.classesDir
classpath += sourceSets.contrib.runtimeClasspath
}
task junitAll(type: Test) {
dependsOn junitLong
dependsOn contribJunit
}
test {
// Gradle is really weird. if I dont have this block, all the other tests does
// not run and says UP-T0-DATE without running anything. If I keep this block
// and says exclude **/* "gradle junit" has 349 test failures due to resources.
// So keeping this block to let it pass. Will follow up with our gradle expert
// to understand what is going on here. You can avoid running tests all together
// by running "gradle jar" which avoids the testing phase completely.
// If this block is defined above the other tests, the tests could not find the
// resources.
dependsOn buildTestRuntime
description = "Runs acceptance tests"
include '**/*Server*Test.*'
include '**/*Client*Test.*'
exclude '**/Abstract*'
testClassesDir = sourceSets.test.output.classesDir
classpath += sourceSets.test.runtimeClasspath
}