//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

subprojects {
    project.ext.topSrcDir = "$rootProject.projectDir/.."

    project.version = iceVersion
    project.group = "com.zeroc"

    apply plugin: 'java'
    apply plugin: 'idea'
    apply from: "$project.ext.topSrcDir/java/gradle/ice.gradle"

    slice.compat = true

    repositories {

        if(this.devRepo) {
            maven {
                url this.devRepo
            }
        }

        if(new File("/usr/share/maven-repo").exists()) {
            maven {
                url "/usr/share/maven-repo"
            }
        }

        mavenCentral()
    }

    jar {
        manifest {
            attributes("Built-By": "ZeroC, Inc.")
        }
    }

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

    idea.module {
        excludeDirs -= file(buildDir)
        buildDir.listFiles({d, f ->f != 'generated-src'} as FilenameFilter).each { excludeDirs += it }
    }
}

if(!System.env.ICE_BIN_DIST?.split(" ").find{ it == 'all' || it.contains('java')}) {
    task dist()
    dist.dependsOn(project(":ice-compat").assemble)
    dist.dependsOn(project(":glacier2-compat").assemble)
    dist.dependsOn(project(":icebt-compat").assemble)
    dist.dependsOn(project(":icegrid-compat").assemble)
    dist.dependsOn(project(":icebox-compat").assemble)
    dist.dependsOn(project(":icediscovery-compat").assemble)
    dist.dependsOn(project(":icelocatordiscovery-compat").assemble)
    dist.dependsOn(project(":icepatch2-compat").assemble)
    dist.dependsOn(project(":icestorm-compat").assemble)
}
