/* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ def DEFAULT_VERSION = "org.xwalk:xwalk_core_library_beta:13+" def DEFAULT_COMMAND_LINE = "--disable-pull-to-refresh-effect" repositories { maven { url 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2' } } if (cdvBuildMultipleApks == null) { ext.cdvBuildMultipleApks = true } if (cdvMinSdkVersion == null) { ext.cdvMinSdkVersion = 14 } def getConfigPreference(name, defaultValue) { name = name.toLowerCase() def xml = file("res/xml/config.xml").getText() // Disable namespace awareness since Cordova doesn't use them properly def root = new XmlParser(false, false).parseText(xml) def ret = defaultValue root.preference.each { it -> def attrName = it.attribute("name") if (attrName && attrName.toLowerCase() == name) { ret = it.attribute("value") } } return ret } // Set defaults before project's build-extras.gradle if (!project.hasProperty('xwalkVersion')) { ext.xwalkVersion = getConfigPreference("xwalkversion", DEFAULT_VERSION) } if (!project.hasProperty('xwalkCommandLine')) { ext.xwalkCommandLine = getConfigPreference("xwalkcommandline", DEFAULT_COMMAND_LINE) } // Apply values after project's build-extras.gradle cdvPluginPostBuildExtras.add({ def xwalkSpec = xwalkVersion if ((xwalkSpec =~ /:/).count == 1) { xwalkSpec = "org.xwalk:${xwalkSpec}" } else if ((xwalkSpec =~ /:/).count == 0) { if (xwalkSpec ==~ /\d+/) { xwalkSpec = "${xwalkSpec}+" } xwalkSpec = "org.xwalk:xwalk_core_library_beta:${xwalkSpec}" } dependencies { compile xwalkSpec } if (file('assets/xwalk-command-line').exists()) { println('Not writing assets/xwalk-command-line since file already exists.') return } android.applicationVariants.all { variant -> def variantName = variant.name.capitalize() def mergeTask = tasks["merge${variantName}Assets"] def processTask = tasks["process${variantName}Resources"] def outFile = new File (mergeTask.outputDir, "xwalk-command-line") def newTask = project.task("createXwalkCommandLineFile${variantName}") << { mergeTask.outputDir.mkdirs() outFile.write("xwalk ${xwalkCommandLine}\n") } newTask.dependsOn(mergeTask) processTask.dependsOn(newTask) } })