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

ext.testDir = "${projectDir}/src/main/java/test"
apply from: "slice.gradle"

sourceSets {
    main {
        java {
            exclude '**/lambda'
            exclude 'plugins'
        }
    }
}

dependencies {
    implementation localDependency('ice-compat')
    runtimeOnly localDependency('icediscovery-compat')
    runtimeOnly localDependency('icelocatordiscovery-compat')
    implementation localDependency('icebox-compat')
    implementation localDependency('glacier2-compat')
    implementation localDependency('icestorm-compat')
    implementation localDependency('icegrid-compat')
    implementation project(':testPlugins')
}

if(!gradle.startParameter.isOffline()) {
    dependencies {
        runtimeOnly "org.apache.commons:commons-compress:1.20"
    }
}

jar {
    if (GradleVersion.current() >= GradleVersion.version('8.0')) {
        archiveFileName = "test.jar"
        destinationDirectory = new File("$rootProject.projectDir/lib/")
    } else {
        archiveName = "test.jar"
        destinationDir = new File("$rootProject.projectDir/lib/")
    }
    manifest {
        attributes("Class-Path": configurations.runtimeClasspath.resolve().collect { it.toURI() }.join(' '))
    }
}

clean {
    delete("$rootProject.projectDir/lib/test.jar")
    ['src/main/java/test/IceGrid/simple/db'].each {
        delete fileTree(dir: it)
    }
    delete("src/main/java/test/Slice/generation/classes")
}
