/* 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. */ import java.util.regex.Pattern ext.cordova = {} apply from: 'cordova.gradle', to: ext.cordova apply plugin: 'android' buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.10.+' } } ext.multiarch=false dependencies { compile fileTree(dir: 'libs', include: '*.jar') for (subproject in getProjectList()) { compile project(subproject) } } android { sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] aidl.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] } } defaultConfig { versionCode Integer.parseInt("" + getVersionCodeFromManifest() + "0") } compileSdkVersion cordova.cordovaSdkVersion buildToolsVersion cordova.cordovaBuildToolsVersion if (multiarch || System.env.BUILD_MULTIPLE_APKS) { productFlavors { armv7 { versionCode defaultConfig.versionCode + 2 ndk { abiFilters "armeabi-v7a", "" } } x86 { versionCode defaultConfig.versionCode + 4 ndk { abiFilters "x86", "" } } all { ndk { abiFilters "all", "" } } } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } } task wrapper(type: Wrapper) { gradleVersion = '1.12' } def getVersionCodeFromManifest() { def manifestFile = file(android.sourceSets.main.manifest.srcFile) def pattern = Pattern.compile("versionCode=\"(\\d+)\"") def matcher = pattern.matcher(manifestFile.getText()) matcher.find() return Integer.parseInt(matcher.group(1)) } def getProjectList() { def manifestFile = file("project.properties") def pattern = Pattern.compile("android.library.reference.(\\d+)\\s*=\\s*(.*)") def matcher = pattern.matcher(manifestFile.getText()) def projects = [] while (matcher.find()) { projects.add(":" + matcher.group(2).replace("/",":")) } return projects }