// Path: src/com/thoughtworks/calabash/android/CalabashLogger.java
// public static void error(Object message) {
//     if (shouldLog && isNotEmpty(message))
//         log.error(message);
// }
// 
// Path: src/com/thoughtworks/calabash/android/CalabashLogger.java
// public static void info(Object message) {
//     if (shouldLog && isNotEmpty(message)) {
//         log.info(message);
//     }
// }


import org.joda.time.DateTime;
import org.jruby.RubyArray;
import org.jruby.RubyHash;
import org.jruby.embed.LocalContextScope;
import org.jruby.embed.LocalVariableBehavior;
import org.jruby.embed.PathType;
import org.jruby.embed.ScriptingContainer;
import java.io.File;
import java.io.FileFilter;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.thoughtworks.calabash.android.CalabashLogger.error;
import static com.thoughtworks.calabash.android.CalabashLogger.info;
import static java.io.File.separator;
import static java.lang.String.format;

        if (gems == null || gems.length == 0)
            throw new CalabashException("Couldn't find any gems inside " + gemsDir.getAbsolutePath());

        for (File gem : gems) {
            File libPath = new File(gem, "lib");
            loadPaths.add(libPath.getAbsolutePath());
        }

        return loadPaths;
    }


    public void setup() throws CalabashException {
        try {
            addSystemCommandHack();
            createDebugCertificateIfMissing();
            String jrubyClasspath = getClasspathFor("jruby");
            addContainerEnv("CLASSPATH", jrubyClasspath);
            container.runScriptlet(format("Dir.chdir '%s'", apk.getParent()));

            container.put(ARGV, new String[]{"resign", apk.getAbsolutePath()});
            String calabashAndroid = new File(getCalabashGemDirectory(), "calabash-android").getAbsolutePath();
            container.runScriptlet(PathType.ABSOLUTE, calabashAndroid);
            info("Done signing the app");

            container.put(ARGV, new String[]{"build", apk.getAbsolutePath()});
            container.runScriptlet(PathType.ABSOLUTE, calabashAndroid);
            info("App build complete");
        } catch (Exception e) {
// Path: src/com/thoughtworks/calabash/android/CalabashLogger.java
// public static void error(Object message) {
//     if (shouldLog && isNotEmpty(message))
//         log.error(message);
// }
// 
// Path: src/com/thoughtworks/calabash/android/CalabashLogger.java
// public static void info(Object message) {
//     if (shouldLog && isNotEmpty(message)) {
//         log.info(message);
//     }
// }


// Path: src/com/thoughtworks/calabash/android/CalabashWrapper.java
import org.joda.time.DateTime;
import org.jruby.RubyArray;
import org.jruby.RubyHash;
import org.jruby.embed.LocalContextScope;
import org.jruby.embed.LocalVariableBehavior;
import org.jruby.embed.PathType;
import org.jruby.embed.ScriptingContainer;
import java.io.File;
import java.io.FileFilter;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.thoughtworks.calabash.android.CalabashLogger.error;
import static com.thoughtworks.calabash.android.CalabashLogger.info;
import static java.io.File.separator;
import static java.lang.String.format;


        if (gems == null || gems.length == 0)
            throw new CalabashException("Couldn't find any gems inside " + gemsDir.getAbsolutePath());

        for (File gem : gems) {
            File libPath = new File(gem, "lib");
            loadPaths.add(libPath.getAbsolutePath());
        }

        return loadPaths;
    }


    public void setup() throws CalabashException {
        try {
            addSystemCommandHack();
            createDebugCertificateIfMissing();
            String jrubyClasspath = getClasspathFor("jruby");
            addContainerEnv("CLASSPATH", jrubyClasspath);
            container.runScriptlet(format("Dir.chdir '%s'", apk.getParent()));

            container.put(ARGV, new String[]{"resign", apk.getAbsolutePath()});
            String calabashAndroid = new File(getCalabashGemDirectory(), "calabash-android").getAbsolutePath();
            container.runScriptlet(PathType.ABSOLUTE, calabashAndroid);
            info("Done signing the app");

            container.put(ARGV, new String[]{"build", apk.getAbsolutePath()});
            container.runScriptlet(PathType.ABSOLUTE, calabashAndroid);
            info("App build complete");
        } catch (Exception e) {
            error("Failed to setup calabash for project: %s", e, apk.getAbsolutePath());