/*
 * Copyright 2010 the original author or authors.
 *
 * Licensed 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.
 */

import org.gradle.build.GenerateReleasesXml

apply plugin: 'groovy'
apply from: "$rootDir/gradle/integTest.gradle"

configurations {
    testFixtures
    testFixturesRuntime {
        extendsFrom testFixtures, testRuntime
    }
    integTestFixtures {
        extendsFrom testFixtures
    }
    integTestFixturesRuntime {
        extendsFrom integTestFixtures, integTestRuntime
    }
    excludedInEclipse
}

dependencies {
    groovy libraries.groovy_depends

    compile "commons-httpclient:commons-httpclient:3.0@jar", "commons-codec:commons-codec:1.2@jar", libraries.jcl_to_slf4j

    compile libraries.ivy, "com.jcraft:jsch:0.1.42@jar", 'com.jcraft:jzlib:1.0.7@jar'

    publishCompile libraries.slf4j_api

    compile libraries.ant,
            libraries.logback_classic,
            libraries.logback_core,
            libraries.jul_to_slf4j,
            libraries.commons_io,
            libraries.commons_lang,
            "commons-codec:commons-codec:1.2@jar",
            libraries.guava,
            "commons-collections:commons-collections:3.2.1@jar",
            "slide:webdavlib:2.0@jar",
            libraries.asm_all,
            'org.fusesource.jansi:jansi:1.2.1',
            'org.jruby.ext.posix:jna-posix:1.0.3'

    runtime libraries.jna

    runtime libraries.log4j_to_slf4j, libraries.jcl_to_slf4j

    // tried with scope 'runtime' but this gives a cyclic task dependency
    testRuntime project(":coreImpl")
    testRuntime 'xerces:xercesImpl:2.9.1'

    testCompile libraries.xmlunit

    compile libraries.ant_launcher

    integTestCompile libraries.jetty_depends

    testFixtures sourceSets.test.output, sourceSets.main.output, project(':coreImpl')
    integTestFixtures sourceSets.integTest.output

    excludedInEclipse project(":coreImpl")
}

task releasesResource(type: GenerateReleasesXml) {
    destFile = new File(generatedResourcesDir, "org/gradle/releases.xml")
}
sourceSets.main.output.dir generatedResourcesDir, buildBy: releasesResource

[compileGroovy, compileTestGroovy]*.groovyOptions*.fork(memoryInitialSize: '128M', memoryMaximumSize: '1G')

test {
    jvmArgs '-Xms128m', '-Xmx512m', '-XX:MaxPermSize=128m', '-XX:+HeapDumpOnOutOfMemoryError'
}

// (SF) See issue GRADLE-1581
// needs to be excluded because Eclipse does not recognize the difference between test & prod dependency
// this is not a best solution. I guess we should move the tests that depend on coreIml from the core subproject or fix eclipse :)
eclipse.classpath.minusConfigurations += configurations.excludedInEclipse