blob: e919c6ff5a1a294ff38f4bf39a7e0cea9107835e [file] [log] [blame]
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* S4 Top Level Build Script
*
* To learn Gradle: http://www.gradle.org
*
* The S4 Project is built using a multilevel project. The subprojects are defined in
* file "settings.gradle".
*
* USAGE: gradle TASK1 TASK2 ... (If you have gradle installed.)
* USAGE: gradlew TASK1 TASK2 ... (Wrapper, doesn't require to install gradle.)
*
*
* Main Tasks:
*
* clean: deletes all the build dirs
* jar: creates all the jars in PROJECT/build/libs
* binImage: creates an image in the ./build subdir that includes jars, scripts,
* and other resources required to run the S4 server and sample applications.
* binTgz: same in a gzipped tar file in ./build/distributions.
* allImage: creates an image in the ./build subdir that includes what is in binImage
* plus sources, javadoc, and other documents.
* allTgz: same in a gzipped tar file in ./build/distributions.
* install: installs jars and POMs in local Maven repo (eg. ~/.m2)
*
*/
apply plugin: "java"
platformProjects = [project(':s4-core'), project(':s4-comm'), project(':s4-driver')]
allprojects {
version = new Version(major: 0, minor: 4, bugfix: 0, releaseType: 'SNAPSHOT')
archivesBaseName = 's4'
repositories {
/* Add lib dir as a repo. Some jar files that are not available
in a public repo are distributed in the lib dir. */
flatDir name: 'libDir', dirs: ["$projectDir/../lib", "$projectDir/lib", "$projectDir/../../lib"]
mavenLocal()
mavenRepo name: "gson", urls: "http://google-gson.googlecode.com/svn/mavenrepo"
mavenRepo name: "repository.jboss.org", urls: "https://repository.jboss.org/nexus/content/repositories/releases/"
mavenCentral()
}
}
/* All project libraries must be defined here. */
libraries = [
json: 'org.json:json:20090211',
lift_json: 'net.liftweb:lift-json_2.8.1:2.2',
gson: 'com.google.code.gson:gson:1.6',
zk: 'org.apache.zookeeper:zookeeper:3.3.1',
log4j: 'log4j:log4j:1.2.15',
flexjson: 'net.sf.flexjson:flexjson:2.1',
bcel: 'org.apache.bcel:bcel:5.2',
jakarta_regexp: 'jakarta-regexp:jakarta-regexp:1.4',
kryo: 'com.googlecode:kryo:1.04',
reflectasm: 'com.googlecode:reflectasm:1.01',
minlog: 'com.googlecode:minlog:1.2',
asm: 'asm:asm:3.2',
commons_cli: 'commons-cli:commons-cli:1.2',
commons_logging: 'commons-logging:commons-logging:1.1.1',
commons_jexl: 'commons-jexl:commons-jexl:1.1',
commons_codec: 'commons-codec:commons-codec:1.4',
commons_httpclient: 'commons-httpclient:commons-httpclient:3.1',
spring: 'org.springframework:spring:2.5.6',
junit: 'junit:junit:4.4',
scala_compiler: 'org.scala-lang:scala-compiler:2.8.1',
scala_library: 'org.scala-lang:scala-library:2.8.1',
jedis: 'redis.clients:jedis:2.0.0',
commons_pool: 'commons-pool:commons-pool:1.5.6',
]
subprojects {
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: "java"
sourceCompatibility = 1.6
targetCompatibility = 1.6
//defaultTasks 'build'
group = 'org.apache.s4'
/* Remove this once this bug is fixed: http://issues.gradle.org/browse/GRADLE-1157 */
eclipseClasspath {
downloadSources = false; // required for eclipseClasspath to work
}
/* Common dependencies applied to all subprojects. */
dependencies {
compile( libraries.log4j )
compile( libraries.commons_logging )
compile( libraries.spring )
testCompile( libraries.junit )
}
manifest.mainAttributes(
provider: 'gradle',
'Implementation-Url': 'http://s4.io',
'Implementation-Version': version,
'Implementation-Vendor': 'The S4 Project',
'Implementation-Vendor-Id': 'org.apache.s4'
)
}
dependsOnChildren()
distRootFolder = "$archivesBaseName-${-> version}"
/* Generate Javadoc. */
task s4Javadoc(type: Javadoc) {
source platformProjects.collect { project ->
project.sourceSets.main.allJava
}
destinationDir = new File(buildDir, 'javadoc')
// Might need a classpath
classpath = files(platformProjects.collect { project ->
project.sourceSets.main.compileClasspath
})
}
configurations {
allLibs
}
dependencies {
allLibs subprojects
}
binDistImage = copySpec {
/* Include all the resources. */
from project(':s4-core').sourceSets.main.resources
[project('s4-core'), project('s4-driver')].collect { project ->
into (project.name + "/lib") {
from project.configurations.runtime
from project.configurations.archives.allArtifactFiles.filter{ file -> !file.name.endsWith('-sources.jar') }
}
}
}
allDistImage = copySpec {
with binDistImage
subprojects.findAll {proj ->
into('src') {
from proj.sourceSets.main.allJava
}
switch(proj.name) {
case "s4-core":
break
case "s4-driver":
into ("${proj.name}/lib/python") {
from ("${proj.name}/python/")
}
into ("${proj.name}/lib/perl") {
from ("${proj.name}/perl/")
}
break
case "s4-example-driver":
into("s4-driver") {
from proj.sourceSets.main.resources
}
into ("s4-driver/lib") {
from proj.configurations.runtime
from proj.configurations.archives.allArtifactFiles
}
break
case "s4-tools-loadgenerator":
into("s4-tools-loadgenerator") {
from proj.sourceSets.main.resources
}
into ("s4-tools-loadgenerator/lib") {
from proj.configurations.runtime
from proj.configurations.archives.allArtifactFiles
}
break
case "s4-example-testinput":
print "Got here"
into("s4-example-testinput") {
from proj.sourceSets.main.resources
}
break
case ~/(s4\-example).*/:
into ("s4-example-apps/" + proj.name + "/lib") {
from(
proj.configurations.runtime
- project("s4-core").configurations.runtime
)
from proj.configurations.archives.allArtifactFiles
}
into ("s4-example-apps/" + proj.name) {
from proj.sourceSets.main.resources
}
break
default :
println("default")
}
//if(project.name != 's4-core') {
// into(project.name) {
// from project.sourceSets.main.resources
// }
//}
}
into('javadoc') {
from "$buildDir/javadoc"
}
}
task binImage(type: Copy) {
description = "Create binary image"
destinationDir = file("$buildDir/s4-image")
with binDistImage
}
task allImage(type: Copy, dependsOn: s4Javadoc) {
description = "Create complete image"
destinationDir = file("$buildDir/s4-image")
with allDistImage
}
allImage << {
// we need this because copyTask's fileMode property is not honored
ant.chmod(dir: "$buildDir/s4-image/scripts", perm: "u+x", includes: "*")
ant.chmod(dir: "$buildDir/s4-image/s4-tools-loadgenerator/scripts", perm: "u+x", includes: "*")
ant.chmod(dir: "$buildDir/s4-image/s4-driver/scripts", perm: "u+x", includes: "*")
}
task binTgz( type: Tar) {
description = "Build binary bundle in GZIP format"
classifier = 'bin'
compression = Compression.GZIP
into(distRootFolder) {
with binDistImage
}
}
task allTgz( type: Tar, dependsOn: s4Javadoc) {
description = "Build complete bundle in GZIP format"
classifier = 'all'
compression = Compression.GZIP
into(distRootFolder) {
with allDistImage
}
}
/* Generates the gradlew scripts.
http://www.gradle.org/1.0-milestone-3/docs/userguide/gradle_wrapper.html */
task wrapper(type: Wrapper) {
gradleVersion = '1.0-milestone-3'
}
class Version {
int major
int minor
int bugfix
String releaseType
String toString() {
"$major.$minor.$bugfix${releaseType ? '-'+releaseType : ''}"
}
}