apply plugin: 'java'
apply plugin: 'eclipse'

springVersion = '3.0.5.RELEASE'
springLdapVersion = '1.3.0.RELEASE'
ehcacheVersion = '1.6.2'
aspectjVersion = '1.6.9'
apacheDsVersion = '1.5.5'
jstlVersion = '1.2'
jettyVersion = '6.1.22'
hsqlVersion = '1.8.0.10'
slf4jVersion = '1.6.1'
logbackVersion = '0.9.24'

configurations {
    // Configuration which is ONLY used for compileJava and will not be inherited by any others
    // Revisit post Gradle 1.0
    compileOnly
    // Used to identify deps which should be marked as "provided" in maven poms
    provided
    testCompile.extendsFrom provided
    compile.transitive = false
    testCompile.transitive = false
}

dependencies {
    compileOnly 'commons-logging:commons-logging:1.1.1'

    compile ("org.springframework:spring-core:$springVersion") {
        exclude(group: 'commons-logging', module: 'commons-logging')
    }

    testCompile 'junit:junit:4.7',
            'org.mockito:mockito-core:1.8.5',
            "org.springframework:spring-test:$springVersion"

    // Use slf4j/logback for logging
    testRuntime "org.slf4j:jcl-over-slf4j:$slf4jVersion",
                "ch.qos.logback:logback-classic:$logbackVersion"
}

[configurations.runtime, configurations.default]*.exclude(module: 'commons-logging')

sourceSets.main.compileClasspath += configurations.compileOnly
sourceSets.main.compileClasspath += configurations.provided

[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

test {
    jvmArgs = ['-ea', '-Xmx500m']
    maxParallelForks = guessMaxForks()
    testReport = false
}

def guessMaxForks() {
    int processors = Runtime.runtime.availableProcessors()
    return Math.max(2, (int) (processors / 2))
}

