ext.moduleName = 'aion.zero.impl'
test.dependsOn copyNativeLibsForModuleTests
unitTest.dependsOn copyNativeLibsForModuleTests
benchmarkTest.dependsOn copyNativeLibsForModuleTests
clean.dependsOn deleteNativeLibs

sourceSets {
    test {
        resources {
            srcDirs = ['test']
        }
    }

    unitTest {
        resources {
            srcDirs = ['test']
        }
        java {
            srcDirs = ['test']
            exclude '**/EquihashSolutionsGenerationTest210_9.java'
            exclude '**/BlockchainAccountStateBenchmark.java'
            exclude '**/TargettedEnergyLimitStrategyTest.java'
            compileClasspath += main.output + test.output
            runtimeClasspath += main.output + test.output
        }
    }

    benchmarkTest {
        resources {
            srcDirs = ['test']
        }
        java {
            srcDirs = ['test']
            include '**/EquihashSolutionsGenerationTest210_9.java'
            include '**/BlockchainAccountStateBenchmark.java'
	    include '**/TargettedEnergyLimitStrategyTest.java'
            compileClasspath += main.output + test.output
            runtimeClasspath += main.output + test.output
        }
    }
}

dependencies {
    compile project(':modAvmStub')
    compile project(':modUtil')
    compile project(':modLogger')
    compile project(':modRlp')
    compile project(':modCrypto')
    compile project(':modDbImpl')
    compile project(':modP2pImpl')
    compile project(':modP2p')
    compile project(':modEvtMgr')
    compile project(':modEvtMgrImpl')
    compile project(':modPrecompiled')
    compile project(':modTxPool')
    compile files("${rootProject.projectDir}/lib/fastvm-c7d37c5.jar")
    compile 'org.json:json:20180813'
    compile 'info.picocli:picocli:4.0.0'
    compile files("${rootProject.projectDir}/lib/aion-types-22a3be9.jar")

    runtimeOnly group: 'org.ow2.asm', name: 'asm', version: '6.2.1'
    runtimeOnly group: 'org.ow2.asm', name: 'asm-analysis', version: '6.2.1'
    runtimeOnly group: 'org.ow2.asm', name: 'asm-commons', version: '6.2.1'
    runtimeOnly group: 'org.ow2.asm', name: 'asm-tree', version: '6.2.1'
    runtimeOnly group: 'org.ow2.asm', name: 'asm-util', version: '6.2.1'
    
    testCompile project(path: ':modDbImpl', configuration: 'testClassesOut')
    
    testCompile 'junit:junit:4.12'
    testCompile 'pl.pragmatists:JUnitParams:1.1.1'
    testCompile 'org.hamcrest:hamcrest-all:1.3'
    testCompile group: 'org.apache.commons', name: 'commons-lang3', version: '3.4'
    testCompile "org.mockito:mockito-core:2.23.0"
    testCompile 'com.google.truth:truth:0.42'
    testCompile 'com.github.stefanbirkner:system-rules:1.19.0'
}

task preBuild(type: Exec) {
    commandLine 'sh', "${rootProject.projectDir}/script/prebuild.sh"
}

task postBuild(type: Exec) { 
    commandLine 'sh', "${rootProject.projectDir}/script/postbuild.sh"
}

configurations {
    unitTestCompile.extendsFrom testCompile
    unitTestRuntime.extendsFrom testRuntime

    benchmarkTestCompile.extendsFrom testCompile
    benchmarkTestRuntime.extendsFrom testRuntime
}


compileJava {
    dependsOn preBuild
    finalizedBy postBuild
    doFirst { 
        options.compilerArgs += ['-h', file("./build/native")]
    }
}

// Skip unit tests when doing build task; unit tests are all mixed up with 
// long-running integration tests in this module,so doing this to avoid 
// build taking too long.
build.dependsOn.remove("check")
