project.ext {
    mainSamplesClass = "jadx.samples.RunTests"  
    samplesJadxSrcDir = "${buildDir}/samples-jadx/src"
    samplesJadxOutDir = "${buildDir}/samples-jadx/output"
}

dependencies {
    compile(project(":jadx-core"))
    compile(project(":jadx-cli"))
}

compileJava {
    options.compilerArgs << '-g:none'
}

sonarRunner {
    skipProject = true
}

task samplesRun(type: JavaExec, dependsOn: compileJava) {  
    classpath = sourceSets.main.output
    main = mainSamplesClass  
}

task samplesJar(type: Jar, dependsOn: samplesRun) {
    baseName = 'samples'
    from sourceSets.main.output
}

task samplesJadxCreate(type: JavaExec, dependsOn: samplesJar) {  
    classpath = sourceSets.main.output + configurations.compile
    main = project(":jadx-cli").mainClassName 
    args = ['-d', samplesJadxSrcDir, samplesJar.archivePath]
}

task samplesJadxCompile(type: JavaCompile, dependsOn: samplesJadxCreate) {  
    classpath = configurations.compile
    destinationDir = file samplesJadxOutDir
    source = samplesJadxSrcDir
}

task samplesJadxRun(type: JavaExec, dependsOn: samplesJadxCompile) {  
    classpath = files samplesJadxOutDir
    main = mainSamplesClass  
}

task samples(dependsOn: samplesJadxRun) {
}

task cleanGeneratedFiles(type: Delete) {
    delete samplesJadxSrcDir
    delete samplesJadxOutDir
}

clean.dependsOn cleanGeneratedFiles
