Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
217 lines (186 sloc) 6.08 KB
description = 'Spring Data GemFire Examples'
apply plugin: 'base'
allprojects {
group = 'org.springframework.data'
logging.captureStandardOutput LogLevel.DEBUG
repositories {
// Public Spring artifacts
maven { url 'http://repo.spring.io/libs-release' }
maven { url 'http://repo.spring.io/libs-milestone' }
maven { url 'http://repo.spring.io/libs-snapshot' }
maven { url "http://repo.spring.io/plugins-release" }
}
}
task listProjects << {
subprojects.each { project ->
project.allprojects.each {
println it.name
println it.tasks
}
}
}
subprojects { subproject ->
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'eclipse' // `gradle eclipse` to generate .classpath/.project
apply plugin: 'maven'
apply {
task "run-${subproject.name}"(dependsOn: 'classes') << {
subproject.tasks['run'].execute()
}
}
install {
repositories.mavenInstaller {
customizePom(pom, subproject)
}
}
dependencies {
compile "org.springframework.data:spring-data-gemfire:$version"
compile "javax.inject:javax.inject:1"
compile "javax.annotation:jsr250-api:1.0"
runtime "cglib:cglib-nodep:3.0"
runtime "log4j:log4j:$log4jVersion"
runtime "org.slf4j:slf4j-log4j12:$slf4jVersion"
runtime "org.springframework.shell:spring-shell:$springShellVersion"
testCompile "junit:junit:$junitVersion"
testCompile "org.springframework:spring-test:$springVersion"
}
sourceCompatibility = 1.6
targetCompatibility = 1.6
eclipse {
project {
natures += 'org.springframework.ide.eclipse.core.springnature'
}
}
[compileJava, compileTestJava]*.options*.compilerArgs = ["-Xlint:-serial"]
task sourcesJar(type: Jar) {
classifier = 'sources'
}
artifacts {
archives sourcesJar
}
task run(type: JavaExec) {
description = 'Runs the application'
def mainClass = rootProject.hasProperty('main') ? "${rootProject.getProperty('main')}" : 'Main'
main = "org.springframework.data.gemfire.examples.$mainClass"
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
systemProperties = System.getProperties()
if (rootProject.hasProperty('args')) {
args = ["${rootProject.getProperty('args')}"]
}
}
}
task 'run-generic-server'(type: JavaExec) {
description "Runs a generic server"
main = 'org.springframework.data.gemfire.examples.GenericServer'
classpath = subprojects.find { it.name == 'spring-gemfire-examples-common' }
.sourceSets.main.runtimeClasspath;
standardInput = System.in
systemProperties = System.getProperties()
if (rootProject.hasProperty('args')) {
args = ["${rootProject.getProperty('args')}"]
}
}
project('spring-gemfire-examples-common') {
dependencies {
compile "org.springframework.data:spring-data-gemfire:$version"
compile "org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final"
compile "commons-cli:commons-cli:1.2"
runtime fileTree(dir: '../lib', include: '*.jar')
}
}
tasks.addRule("Pattern: <COMMAND>-locator-<PORT>") { String taskName ->
def command
if (taskName.startsWith('start-locator') || taskName.startsWith('stop-locator')) {
command = '--' + taskName.split('-')[0]
def project = rootProject.allprojects.find { it.name == 'spring-gemfire-examples-common' }
task(taskName, dependsOn: project.classes) << {
javaexec {
main = 'org.springframework.data.gemfire.examples.Locator'
classpath = project.sourceSets.main.runtimeClasspath
standardInput = System.in
def targs = [command, '--port', "${taskName.split('-').last()}"]
if (rootProject.hasProperty('args')) {
def str = "${rootProject.getProperty('args')}"
str.split(',').each {
targs.addAll(it.tokenize('='))
}
}
if (rootProject.hasProperty('props')) {
targs.addAll(['--properties', "${rootProject.getProperty('props')}"])
}
args = targs
}
}
}
}
task wrapper(type: Wrapper) {
description = 'Generates gradlew[.bat] scripts'
gradleVersion = '1.12'
}
def customizePom(def pom, def gradleProject) {
pom.whenConfigured { generatedPom ->
// respect 'optional' and 'provided' dependencies
def deps = gradleProject.configurations.runtime.allDependencies
def optionalDeps = deps.findAll { dep ->
dep.asDynamicObject.hasProperty('optional') && dep.optional
}
def providedDeps = deps.findAll { dep ->
dep.asDynamicObject.hasProperty('provided') && dep.provided
}
generatedPom.dependencies.each { mavenDep ->
mavenDep.optional = optionalDeps.any { optionalDep ->
optionalDep.group == mavenDep.groupId &&
optionalDep.name == mavenDep.artifactId &&
optionalDep.version == mavenDep.version
}
boolean isProvided = providedDeps.any { providedDep ->
providedDep.group == mavenDep.groupId &&
providedDep.name == mavenDep.artifactId &&
providedDep.version == mavenDep.version
}
if (isProvided) {
mavenDep.scope = 'provided'
}
}
// eliminate test-scoped dependencies (no need in maven central poms)
generatedPom.dependencies.removeAll { dep ->
dep.scope == 'test'
}
// add all items necessary for maven central publication
generatedPom.project {
name = gradleProject.description
description = gradleProject.description
url = 'https://github.com/spring-projects/spring-gemfire-examples'
organization {
name = 'SpringSource'
url = 'http://springsource.org'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
scm {
url = 'https://github.com/spring-projects/spring-gemfire-examples'
connection = 'scm:git:git://github.com/spring-projects/spring-gemfire-examples'
developerConnection = 'scm:git:git://github.com/spring-projects/spring-gemfire-examples'
}
developers {
developer {
id = 'jblum'
name = 'John Blum'
email = 'jblum@pivotal.io'
}
developer {
id = 'dturanski'
name = 'David Turanski'
email = 'dturanski@pivotal.io'
}
}
}
}
}