/*
 * Copyright 2012, Google Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 *     * Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 * copyright notice, this list of conditions and the following disclaimer
 * in the documentation and/or other materials provided with the
 * distribution.
 *     * Neither the name of Google Inc. nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
configurations {
    proguard
}

dependencies {
    compile project(':util')
    compile project(':dexlib')
    compile 'commons-cli:commons-cli:1.2'
    compile 'com.google.code.findbugs:jsr305:1.3.9'

    proguard 'net.sf.proguard:proguard-base:4.8'
}

// We have to do this in taskGraph.whenReady, so that we use the correct
// version to resolve the project dependencies
gradle.taskGraph.whenReady {
    // build a jar containing all dependencies
    jar {
        from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }

        manifest {
            attributes("Main-Class": "org.jf.baksmali.main")
        }
    }

    proguard {
        def outFile = relativePath(buildDir) + '/libs/' + jar.baseName + '-' + jar.version + '-small' + '.' + jar.extension

        inputs.file jar.archivePath
        outputs.file outFile

        args '-injars ' + jar.archivePath
        args '-outjars ' + outFile
    }

    processResources.inputs.properties('version': { -> version})
    processResources.expand('version': { -> version})
}

task proguard(type: JavaExec, dependsOn: jar) {
    classpath = configurations.proguard
    main = 'proguard.ProGuard'
    args '-libraryjars ' + System.properties['java.home'] + '/lib/rt.jar'
    args '-dontobfuscate'
    args '-dontoptimize'
    args '-keep public class org.jf.baksmali.main { public static void main(java.lang.String[]); }'
    args '-keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); }'
    args '-dontwarn com.google.common.base.**'
    args '-dontnote com.google.common.base.**'
}

release.dependsOn(proguard)