plugins {
    id 'java-library'
}

group = 'com.emc.ecs.sync'

repositories {
    mavenLocal()
    mavenCentral()
    jcenter()
}

java {
    sourceCompatibility = JavaVersion.VERSION_1_8
}

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
    options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation'
    options.deprecation = true
}

// have a single log4j2.xml file for tests in all modules
sourceSets {
    test {
        resources {
            srcDirs += "${rootDir}/test-resources"
        }
    }
}

// make sure all tests run across all modules
test {
    ignoreFailures = true
}

configurations {
    // required to support the "internal" platform module, which is not intended to be published, but only serves as
    // dependency version management
    internal {
        canBeResolved = false
        canBeConsumed = false
    }
    compileClasspath.extendsFrom(internal)
    runtimeClasspath.extendsFrom(internal)
    testCompileClasspath.extendsFrom(internal)
    testRuntimeClasspath.extendsFrom(internal)
    testFixturesCompileClasspath.extendsFrom(internal)
    testFixturesRuntimeClasspath.extendsFrom(internal)
    // Share the test report data to be aggregated for the whole project
    binaryTestResultsElements {
        canBeResolved = false
        canBeConsumed = true
        attributes {
            attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.DOCUMENTATION))
            attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType, 'test-report-data'))
        }
        outgoing.artifact(test.binaryResultsDirectory)
    }
    all {
        // make sure we don't pull in log4j 1.x or commons-logging from transitives
        exclude group: 'log4j', module: 'log4j'
        exclude group: 'org.slf4j', module: 'slf4j-log4j12'
        exclude group: 'commons-logging', module: 'commons-logging'
        // update netty to latest
        resolutionStrategy.dependencySubstitution {
            // this is a special case, because Netty changed its group coordinate
            substitute module("org.jboss.netty:netty") using module("io.netty:netty:3.10.6.Final") because "Netty relocated to a different group after 3.2.9"
        }
        // resolutionStrategy.force 'io.netty:netty:3.10.6.Final'
    }
}