def packAPP(build_json=None, app_src=None, app_dest=None, app_name=None):
    LOG.info("Packing %s(%s)" % (app_name, app_src))
    if not os.path.exists(app_dest):
        try:
            os.makedirs(app_dest)
        except Exception as e:
            LOG.error("Fail to init package install dest dir: %s" % e)
            return False

    app_tpye = utils.safelyGetValue(build_json, "app-type")

    if utils.checkContains(BUILD_PARAMETERS.pkgtype, "APK") and app_tpye == "EXTENSION":
        if not build_extension.packExtension(build_json, app_src, app_dest, app_name):
            return False
        if not build_android.packAPK(build_json, app_src, app_dest, app_name):
            return False
    elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "APK") and app_tpye != "EMBEDDINGAPI":
        if not build_android.packAPK(build_json, app_src, app_dest, app_name):
            return False
    elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "CORDOVA"):
        if BUILD_PARAMETERS.subversion == "4.x":
            if not build_cordova.packCordova_cli(build_json, app_src, app_dest, app_name):
                return False
        else:
            if not build_cordova.packCordova(build_json, app_src, app_dest, app_name):
                return False
    elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "EMBEDDINGAPI") or app_tpye == "EMBEDDINGAPI":
        app_version = None
        if "_" in app_name:
            index_flag = app_name.index("_")
            app_version = app_name[index_flag + 1 :]
        if app_version:
            utils.replaceUserString(
                app_src, "AndroidManifest.xml", "org.xwalk.embedding.test", "org.xwalk.embedding.test." + app_version
            )
            utils.replaceUserString(
                app_src, "AndroidManifest.xml", "EmbeddingApiTestUnit", "EmbeddingApiTestUnit" + app_version
            )
            main_dest = os.path.join(app_src, "src/org/xwalk/embedding")
            utils.replaceUserString(
                main_dest, "MainActivity.java", "org.xwalk.embedding.test", "org.xwalk.embedding.test." + app_version
            )
        if BUILD_PARAMETERS.packtype and utils.checkContains(BUILD_PARAMETERS.packtype, "GRADLE"):
            if not build_embeddingapi.packEmbeddingAPI_gradle(build_json, app_src, app_dest, app_name, app_version):
                return False
        elif BUILD_PARAMETERS.packtype and utils.checkContains(BUILD_PARAMETERS.packtype, "MAVEN"):
            if not build_embeddingapi.packEmbeddingAPI_maven(build_json, app_src, app_dest, app_name, app_version):
                return False
        else:
            if not build_embeddingapi.packEmbeddingAPI_ant(build_json, app_src, app_dest, app_name, app_version):
                return False
    elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "DEB"):
        if not build_deb.packDeb(build_json, app_src, app_dest, app_name):
            return False
    else:
        LOG.error("Got wrong pkg type: %s" % BUILD_PARAMETERS.pkgtype)
        return False

    LOG.info("Success to pack APP: %s" % app_name)
    return True
Example #2
0
def packAPP(build_json=None, app_src=None, app_dest=None, app_name=None):
    LOG.info("Packing %s(%s)" % (app_name, app_src))
    if not os.path.exists(app_dest):
        try:
            os.makedirs(app_dest)
        except Exception as e:
            LOG.error("Fail to init package install dest dir: %s" % e)
            return False

    app_tpye = utils.safelyGetValue(build_json, 'app-type')

    if utils.checkContains(BUILD_PARAMETERS.pkgtype,
                           "APK") and app_tpye == "EXTENSION":
        if not build_extension.packExtension(build_json, app_src, app_dest,
                                             app_name):
            return False
        if not build_android.packAPK(build_json, app_src, app_dest, app_name):
            return False
    elif utils.checkContains(BUILD_PARAMETERS.pkgtype,
                             "APK") and app_tpye != "EMBEDDINGAPI":
        if not build_android.packAPK(build_json, app_src, app_dest, app_name):
            return False
    elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "CORDOVA"):
        if BUILD_PARAMETERS.subversion == '4.x':
            if not build_cordova.packCordova_cli(build_json, app_src, app_dest,
                                                 app_name):
                return False
        else:
            if not build_cordova.packCordova(build_json, app_src, app_dest,
                                             app_name):
                return False
    elif utils.checkContains(BUILD_PARAMETERS.pkgtype,
                             "EMBEDDINGAPI") or app_tpye == "EMBEDDINGAPI":
        app_version = None
        if "_" in app_name:
            index_flag = app_name.index("_")
            app_version = app_name[index_flag + 1:]
        if app_version:
            utils.replaceUserString(app_src, 'AndroidManifest.xml',
                                    'org.xwalk.embedding.test',
                                    "org.xwalk.embedding.test." + app_version)
            utils.replaceUserString(app_src, 'AndroidManifest.xml',
                                    'EmbeddingApiTestUnit',
                                    "EmbeddingApiTestUnit" + app_version)
            main_dest = os.path.join(app_src, "src/org/xwalk/embedding")
            utils.replaceUserString(main_dest, 'MainActivity.java',
                                    'org.xwalk.embedding.test',
                                    "org.xwalk.embedding.test." + app_version)
        if BUILD_PARAMETERS.packtype and utils.checkContains(
                BUILD_PARAMETERS.packtype, "GRADLE"):
            if not build_embeddingapi.packEmbeddingAPI_gradle(
                    build_json, app_src, app_dest, app_name, app_version):
                return False
        elif BUILD_PARAMETERS.packtype and utils.checkContains(
                BUILD_PARAMETERS.packtype, "MAVEN"):
            if not build_embeddingapi.packEmbeddingAPI_maven(
                    build_json, app_src, app_dest, app_name, app_version):
                return False
        else:
            if not build_embeddingapi.packEmbeddingAPI_ant(
                    build_json, app_src, app_dest, app_name, app_version):
                return False
    elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "DEB"):
        if not build_deb.packDeb(build_json, app_src, app_dest, app_name):
            return False
    else:
        LOG.error("Got wrong pkg type: %s" % BUILD_PARAMETERS.pkgtype)
        return False

    LOG.info("Success to pack APP: %s" % app_name)
    return True
def packAPP(build_json=None, app_src=None, app_dest=None, app_name=None):
    LOG.info("Packing %s(%s)" % (app_name, app_src))
    if not os.path.exists(app_dest):
        try:
            os.makedirs(app_dest)
        except Exception as e:
            LOG.error("Fail to init package install dest dir: %s" % e)
            return False

    app_tpye = utils.safelyGetValue(build_json, 'app-type')

    if utils.checkContains(BUILD_PARAMETERS.pkgtype, "APK") and app_tpye == "EXTENSION":
        if not build_extension.packExtension(build_json, app_src, app_dest, app_name):
            return False
        if not build_android.packAPK(build_json, app_src, app_dest, app_name):
            return False
    elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "APK") and app_tpye != "EMBEDDINGAPI":
        if not build_android.packAPK(build_json, app_src, app_dest, app_name):
            return False
    elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "CORDOVA"):
        if not build_cordova.packCordova(build_json, app_src, app_dest, app_name):
            return False
    elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "EMBEDDINGAPI") or app_tpye == "EMBEDDINGAPI":
        app_version = None
        if "_" in app_name:
            index_flag = app_name.index("_")
            app_version = app_name[index_flag + 1:]
        if app_version:
            utils.replaceUserString(
                app_src,
                'AndroidManifest.xml',
                'org.xwalk.embedding.test',
                "org.xwalk.embedding.test." +
                app_version)
            utils.replaceUserString(
                app_src,
                'AndroidManifest.xml',
                'org.xwalk.embedding.asynctest',
                "org.xwalk.embedding.asynctest." +
                app_version)
            utils.replaceUserString(
                app_src,
                'AndroidManifest.xml',
                'EmbeddingApiTestUnit',
                "EmbeddingApiTestUnit" +
                app_version)
            utils.replaceUserString(
                app_src,
                'AndroidManifest.xml',
                'EmbeddingApiAsynctestUnit',
                "EmbeddingApiAsynctestUnit" +
                app_version)
            if app_version != "v6":
                utils.replaceUserString(
                    app_src,
                    'AndroidManifest.xml',
                    '<provider android:name=\"org.xwalk.embedding.base.TestContentProvider\"' +
                    ' android:authorities=\"org.xwalk.embedding.base.TestContentProvider\" />',
                    "")
            main_dest = os.path.join(app_src, "src/org/xwalk/embedding")
            utils.replaceUserString(
                main_dest,
                'MainActivity.java',
                'org.xwalk.embedding.test',
                "org.xwalk.embedding.test." +
                app_version)
            utils.replaceUserString(
                main_dest,
                'MainActivity.java',
                'org.xwalk.embedding.asynctest',
                "org.xwalk.embedding.asynctest." +
                app_version)
        if BUILD_PARAMETERS.packtype and utils.checkContains(
                BUILD_PARAMETERS.packtype, "GRADLE"):
            if not build_embeddingapi.packEmbeddingAPI_gradle(
                    build_json, app_src, app_dest, app_name, app_version):
                return False
        elif BUILD_PARAMETERS.packtype and utils.checkContains(BUILD_PARAMETERS.packtype, "MAVEN"):
            if not build_embeddingapi.packEmbeddingAPI_maven(
                    build_json, app_src, app_dest, app_name, app_version):
                return False
        else:
            if not build_embeddingapi.packEmbeddingAPI_ant(
                    build_json, app_src, app_dest, app_name, app_version):
                return False
    elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "DEB"):
        if not build_deb.packDeb(build_json, app_src, app_dest, app_name):
            return False
    elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "MSI"):
        if not build_msi.packMsi(build_json, app_src, app_dest, app_name):
            return False
    elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "ios"):
        if not build_ios.packIOS(build_json, app_src, app_dest, app_name):
            return False
    elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "iot"):
        if not build_iot.packIoT(build_json, app_src, app_dest, app_name):
            return False
    else:
        LOG.error("Got wrong pkg type: %s" % BUILD_PARAMETERS.pkgtype)
        return False

    LOG.info("Success to pack APP: %s" % app_name)
    return True