parent
408bf02b89
commit
179caec389
414 changed files with 2302 additions and 69860 deletions
@ -1 +1,2 @@ |
||||
bin/templates/project/assets/www/cordova.js |
||||
bin/templates/project/assets/www/cordova.js |
||||
test/app |
||||
|
@ -1 +1 @@ |
||||
7.1.4 |
||||
8.0.0 |
||||
|
@ -1,38 +1,36 @@ |
||||
image: |
||||
- Previous Visual Studio 2015 |
||||
|
||||
environment: |
||||
ANDROID_HOME: "C:\\android" |
||||
matrix: |
||||
- nodejs_version: "4" |
||||
- nodejs_version: "6" |
||||
- nodejs_version: "8" |
||||
|
||||
init: |
||||
- mkdir "%ANDROID_HOME% |
||||
- cd "%ANDROID_HOME%" |
||||
- appveyor DownloadFile "https://dl.google.com/android/repository/tools_r25.2.3-windows.zip" |
||||
- 7z x "tools_r25.2.3-windows.zip" > nul |
||||
- cd "C:\projects\cordova-android" |
||||
ANDROID_HOME: "C:\\android" |
||||
|
||||
# If the gradle daemon is used, the build hangs after generating the wrapper |
||||
GRADLE_OPTS: -Dorg.gradle.daemon=false |
||||
|
||||
# URL for SDK Tools, Revision 26.1.1 (September 2017) |
||||
SDK_TOOLS_URL: https://dl.google.com/android/repository/sdk-tools-windows-4333796.zip |
||||
|
||||
matrix: |
||||
- nodejs_version: 6 |
||||
- nodejs_version: 8 |
||||
- nodejs_version: 10 |
||||
|
||||
install: |
||||
- choco install gradle -version 3.4.1 |
||||
- gradle -version |
||||
- echo y | "%ANDROID_HOME%\tools\android.bat" --silent update sdk --no-ui --all --filter platform-tools,tools,build-tools-26.0.2,android-26,android-25,extra-google-m2repository,extra-android-m2repository |
||||
# on windows we need to accept sublicenses for the new tooling, wee. 30 is an arbitrary number, |
||||
# but should be the maximum number of licenses we explicitly need to type "Y ENTER" for. |
||||
# also, the sdkmanager in all its glory leaks a bit of output to stderr, and powershell |
||||
# and appveyor interpret that as errors, and blows up. so, when piping in our "Y ENTER" |
||||
# responses, we invoke cmd so we can redirect stderr to stdout, and tell it to --update itself. |
||||
- ps: for($i=0;$i -lt 30;$i++) { $response += "y`n"}; $response | cmd /c 'C:\android\tools\bin\sdkmanager.bat 2>&1' --update |
||||
- ps: Install-Product node $env:nodejs_version |
||||
- npm install |
||||
# below is a workaround on using gradle installed via choco on appveyor |
||||
- set path=C:\ProgramData\chocolatey\lib\gradle\tools\gradle-3.4.1\bin;%path% |
||||
# Install Android SDK Tools |
||||
- mkdir "%ANDROID_HOME%" |
||||
- appveyor DownloadFile "%SDK_TOOLS_URL%" -FileName "%TMP%/sdk-tools.zip" |
||||
- 7z x "%TMP%/sdk-tools.zip" -o"%ANDROID_HOME%" > nul |
||||
- set PATH=%PATH%;"%ANDROID_HOME%\tools\bin" |
||||
|
||||
- yes 2> nul | sdkmanager --licenses > nul |
||||
- sdkmanager "build-tools;28.0.3" |
||||
|
||||
- choco install gradle --version 3.4.1 |
||||
|
||||
- ps: Install-Product node $env:nodejs_version |
||||
- npm install |
||||
|
||||
build: off |
||||
|
||||
test_script: |
||||
- node --version |
||||
- npm --version |
||||
- npm test |
||||
- gradle --version |
||||
- node --version |
||||
- npm --version |
||||
- npm test |
||||
|
@ -1,11 +0,0 @@ |
||||
/* |
||||
* This is a simple routine that checks if project is an Android Studio Project |
||||
* |
||||
* @param {String} root Root folder of the project |
||||
*/ |
||||
|
||||
/* jshint esnext: false */ |
||||
|
||||
module.exports.isAndroidStudioProject = function isAndroidStudioProject (root) { |
||||
return true; |
||||
}; |
124
node_modules/cordova-android/bin/templates/cordova/lib/builders/GenericBuilder.js
generated
vendored
124
node_modules/cordova-android/bin/templates/cordova/lib/builders/GenericBuilder.js
generated
vendored
@ -1,124 +0,0 @@ |
||||
/* |
||||
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. |
||||
*/ |
||||
/* eslint no-self-assign: 0 */ |
||||
/* eslint no-unused-vars: 0 */ |
||||
|
||||
var Q = require('q'); |
||||
var fs = require('fs'); |
||||
var path = require('path'); |
||||
var shell = require('shelljs'); |
||||
var events = require('cordova-common').events; |
||||
|
||||
function GenericBuilder (projectDir) { |
||||
this.root = projectDir || path.resolve(__dirname, '../../..'); |
||||
this.binDirs = { |
||||
studio: path.join(this.root, 'app', 'build', 'outputs', 'apk'), |
||||
gradle: path.join(this.root, 'build', 'outputs', 'apk') |
||||
}; |
||||
} |
||||
|
||||
GenericBuilder.prototype.prepEnv = function () { |
||||
return Q(); |
||||
}; |
||||
|
||||
GenericBuilder.prototype.build = function () { |
||||
events.emit('log', 'Skipping build...'); |
||||
return Q(null); |
||||
}; |
||||
|
||||
GenericBuilder.prototype.clean = function () { |
||||
return Q(); |
||||
}; |
||||
|
||||
GenericBuilder.prototype.findOutputApks = function (build_type, arch) { |
||||
var self = this; |
||||
return Object.keys(this.binDirs).reduce(function (result, builderName) { |
||||
var binDir = self.binDirs[builderName]; |
||||
return result.concat(findOutputApksHelper(binDir, build_type, builderName === 'ant' ? null : arch)); |
||||
}, []).sort(apkSorter); |
||||
}; |
||||
|
||||
module.exports = GenericBuilder; |
||||
|
||||
function apkSorter (fileA, fileB) { |
||||
// De-prioritize arch specific builds
|
||||
var archSpecificRE = /-x86|-arm/; |
||||
if (archSpecificRE.exec(fileA)) { |
||||
return 1; |
||||
} else if (archSpecificRE.exec(fileB)) { |
||||
return -1; |
||||
} |
||||
|
||||
// De-prioritize unsigned builds
|
||||
var unsignedRE = /-unsigned/; |
||||
if (unsignedRE.exec(fileA)) { |
||||
return 1; |
||||
} else if (unsignedRE.exec(fileB)) { |
||||
return -1; |
||||
} |
||||
|
||||
var timeDiff = fs.statSync(fileB).mtime - fs.statSync(fileA).mtime; |
||||
return timeDiff === 0 ? fileA.length - fileB.length : timeDiff; |
||||
} |
||||
|
||||
function findOutputApksHelper (dir, build_type, arch) { |
||||
var shellSilent = shell.config.silent; |
||||
shell.config.silent = true; |
||||
|
||||
// list directory recursively
|
||||
var ret = shell.ls('-R', dir).map(function (file) { |
||||
// ls does not include base directory
|
||||
return path.join(dir, file); |
||||
}).filter(function (file) { |
||||
// find all APKs
|
||||
return file.match(/\.apk?$/i); |
||||
}).filter(function (candidate) { |
||||
var apkName = path.basename(candidate); |
||||
// Need to choose between release and debug .apk.
|
||||
if (build_type === 'debug') { |
||||
return /-debug/.exec(apkName) && !/-unaligned|-unsigned/.exec(apkName); |
||||
} |
||||
if (build_type === 'release') { |
||||
return /-release/.exec(apkName) && !/-unaligned/.exec(apkName); |
||||
} |
||||
return true; |
||||
}).sort(apkSorter); |
||||
|
||||
shellSilent = shellSilent; |
||||
|
||||
if (ret.length === 0) { |
||||
return ret; |
||||
} |
||||
// Assume arch-specific build if newest apk has -x86 or -arm.
|
||||
var archSpecific = !!/-x86|-arm/.exec(path.basename(ret[0])); |
||||
// And show only arch-specific ones (or non-arch-specific)
|
||||
ret = ret.filter(function (p) { |
||||
/* jshint -W018 */ |
||||
return !!/-x86|-arm/.exec(path.basename(p)) === archSpecific; |
||||
/* jshint +W018 */ |
||||
}); |
||||
|
||||
if (archSpecific && ret.length > 1 && arch) { |
||||
ret = ret.filter(function (p) { |
||||
return path.basename(p).indexOf('-' + arch) !== -1; |
||||
}); |
||||
} |
||||
|
||||
return ret; |
||||
} |
331
node_modules/cordova-android/bin/templates/cordova/lib/builders/GradleBuilder.js
generated
vendored
331
node_modules/cordova-android/bin/templates/cordova/lib/builders/GradleBuilder.js
generated
vendored
@ -1,331 +0,0 @@ |
||||
/* |
||||
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. |
||||
*/ |
||||
|
||||
var Q = require('q'); |
||||
var fs = require('fs'); |
||||
var util = require('util'); |
||||
var path = require('path'); |
||||
var shell = require('shelljs'); |
||||
var superspawn = require('cordova-common').superspawn; |
||||
var CordovaError = require('cordova-common').CordovaError; |
||||
var events = require('cordova-common').events; |
||||
var check_reqs = require('../check_reqs'); |
||||
|
||||
var GenericBuilder = require('./GenericBuilder'); |
||||
|
||||
var MARKER = 'YOUR CHANGES WILL BE ERASED!'; |
||||
var SIGNING_PROPERTIES = '-signing.properties'; |
||||
var TEMPLATE = |
||||
'# This file is automatically generated.\n' + |
||||
'# Do not modify this file -- ' + MARKER + '\n'; |
||||
|
||||
function GradleBuilder (projectRoot) { |
||||
GenericBuilder.call(this, projectRoot); |
||||
|
||||
this.binDirs = { gradle: this.binDirs.gradle }; |
||||
} |
||||
|
||||
util.inherits(GradleBuilder, GenericBuilder); |
||||
|
||||
GradleBuilder.prototype.getArgs = function (cmd, opts) { |
||||
if (cmd === 'release') { |
||||
cmd = 'cdvBuildRelease'; |
||||
} else if (cmd === 'debug') { |
||||
cmd = 'cdvBuildDebug'; |
||||
} |
||||
var args = [cmd, '-b', path.join(this.root, 'build.gradle')]; |
||||
if (opts.arch) { |
||||
args.push('-PcdvBuildArch=' + opts.arch); |
||||
} |
||||
|
||||
// 10 seconds -> 6 seconds
|
||||
args.push('-Dorg.gradle.daemon=true'); |
||||
// to allow dex in process
|
||||
args.push('-Dorg.gradle.jvmargs=-Xmx2048m'); |
||||
// allow NDK to be used - required by Gradle 1.5 plugin
|
||||
args.push('-Pandroid.useDeprecatedNdk=true'); |
||||
args.push.apply(args, opts.extraArgs); |
||||
// Shaves another 100ms, but produces a "try at own risk" warning. Not worth it (yet):
|
||||
// args.push('-Dorg.gradle.parallel=true');
|
||||
return args; |
||||
}; |
||||
|
||||
/* |
||||
* This returns a promise |
||||
*/ |
||||
|
||||
GradleBuilder.prototype.runGradleWrapper = function (gradle_cmd, gradle_file) { |
||||
var gradlePath = path.join(this.root, 'gradlew'); |
||||
gradle_file = path.join(this.root, (gradle_file || 'wrapper.gradle')); |
||||
if (fs.existsSync(gradlePath)) { |
||||
// Literally do nothing, for some reason this works, while !fs.existsSync didn't on Windows
|
||||
} else { |
||||
return superspawn.spawn(gradle_cmd, ['-p', this.root, 'wrapper', '-b', gradle_file], { stdio: 'pipe' }) |
||||
.progress(function (stdio) { |
||||
suppressJavaOptionsInfo(stdio); |
||||
}); |
||||
} |
||||
}; |
||||
|
||||
/* |
||||
* We need to kill this in a fire. |
||||
*/ |
||||
|
||||
GradleBuilder.prototype.readProjectProperties = function () { |
||||
function findAllUniq (data, r) { |
||||
var s = {}; |
||||
var m; |
||||
while ((m = r.exec(data))) { |
||||
s[m[1]] = 1; |
||||
} |
||||
return Object.keys(s); |
||||
} |
||||
|
||||
var data = fs.readFileSync(path.join(this.root, 'project.properties'), 'utf8'); |
||||
return { |
||||
libs: findAllUniq(data, /^\s*android\.library\.reference\.\d+=(.*)(?:\s|$)/mg), |
||||
gradleIncludes: findAllUniq(data, /^\s*cordova\.gradle\.include\.\d+=(.*)(?:\s|$)/mg), |
||||
systemLibs: findAllUniq(data, /^\s*cordova\.system\.library\.\d+=(.*)(?:\s|$)/mg) |
||||
}; |
||||
}; |
||||
|
||||
GradleBuilder.prototype.extractRealProjectNameFromManifest = function () { |
||||
var manifestPath = path.join(this.root, 'AndroidManifest.xml'); |
||||
var manifestData = fs.readFileSync(manifestPath, 'utf8'); |
||||
var m = /<manifest[\s\S]*?package\s*=\s*"(.*?)"/i.exec(manifestData); |
||||
if (!m) { |
||||
throw new CordovaError('Could not find package name in ' + manifestPath); |
||||
} |
||||
|
||||
var packageName = m[1]; |
||||
var lastDotIndex = packageName.lastIndexOf('.'); |
||||
return packageName.substring(lastDotIndex + 1); |
||||
}; |
||||
|
||||
// Makes the project buildable, minus the gradle wrapper.
|
||||
GradleBuilder.prototype.prepBuildFiles = function () { |
||||
// Update the version of build.gradle in each dependent library.
|
||||
var pluginBuildGradle = path.join(this.root, 'cordova', 'lib', 'plugin-build.gradle'); |
||||
var propertiesObj = this.readProjectProperties(); |
||||
var subProjects = propertiesObj.libs; |
||||
|
||||
// Check and copy the gradle file into the subproject.
|
||||
// Called by the loop below this function def.
|
||||
var checkAndCopy = function (subProject, root) { |
||||
var subProjectGradle = path.join(root, subProject, 'build.gradle'); |
||||
// This is the future-proof way of checking if a file exists
|
||||
// This must be synchronous to satisfy a Travis test
|
||||
try { |
||||
fs.accessSync(subProjectGradle, fs.F_OK); |
||||
} catch (e) { |
||||
shell.cp('-f', pluginBuildGradle, subProjectGradle); |
||||
} |
||||
}; |
||||
|
||||
// Some dependencies on Android don't use gradle, or don't have default
|
||||
// gradle files. This copies a dummy gradle file into them
|
||||
for (var i = 0; i < subProjects.length; ++i) { |
||||
if (subProjects[i] !== 'CordovaLib' && subProjects[i] !== 'app') { |
||||
checkAndCopy(subProjects[i], this.root); |
||||
} |
||||
} |
||||
|
||||
var name = this.extractRealProjectNameFromManifest(); |
||||
// Remove the proj.id/name- prefix from projects: https://issues.apache.org/jira/browse/CB-9149
|
||||
var settingsGradlePaths = subProjects.map(function (p) { |
||||
var realDir = p.replace(/[/\\]/g, ':'); |
||||
var libName = realDir.replace(name + '-', ''); |
||||
var str = 'include ":' + libName + '"\n'; |
||||
if (realDir.indexOf(name + '-') !== -1) { str += 'project(":' + libName + '").projectDir = new File("' + p + '")\n'; } |
||||
return str; |
||||
}); |
||||
|
||||
// Write the settings.gradle file.
|
||||
fs.writeFileSync(path.join(this.root, 'settings.gradle'), |
||||
'// GENERATED FILE - DO NOT EDIT\n' + |
||||
'include ":"\n' + settingsGradlePaths.join('')); |
||||
// Update dependencies within build.gradle.
|
||||
var buildGradle = fs.readFileSync(path.join(this.root, 'build.gradle'), 'utf8'); |
||||
var depsList = ''; |
||||
var root = this.root; |
||||
|
||||
// Cordova Plugins can be written as library modules that would use Cordova as a
|
||||
// dependency. Because we need to make sure that Cordova is compiled only once for
|
||||
// dexing, we make sure to exclude CordovaLib from these modules
|
||||
var insertExclude = function (p) { |
||||
var gradlePath = path.join(root, p, 'build.gradle'); |
||||
var projectGradleFile = fs.readFileSync(gradlePath, 'utf-8'); |
||||
if (projectGradleFile.indexOf('CordovaLib') !== -1) { |
||||
depsList += '{\n exclude module:("CordovaLib")\n }\n'; |
||||
} else { |
||||
depsList += '\n'; |
||||
} |
||||
}; |
||||
|
||||
subProjects.forEach(function (p) { |
||||
events.emit('log', 'Subproject Path: ' + p); |
||||
var libName = p.replace(/[/\\]/g, ':').replace(name + '-', ''); |
||||
depsList += ' implementation(project(path: "' + libName + '"))'; |
||||
insertExclude(p); |
||||
}); |
||||
|
||||
// For why we do this mapping: https://issues.apache.org/jira/browse/CB-8390
|
||||
var SYSTEM_LIBRARY_MAPPINGS = [ |
||||
[/^\/?extras\/android\/support\/(.*)$/, 'com.android.support:support-$1:+'], |
||||
[/^\/?google\/google_play_services\/libproject\/google-play-services_lib\/?$/, 'com.google.android.gms:play-services:+'] |
||||
]; |
||||
propertiesObj.systemLibs.forEach(function (p) { |
||||
var mavenRef; |
||||
// It's already in gradle form if it has two ':'s
|
||||
if (/:.*:/.exec(p)) { |
||||
mavenRef = p; |
||||
} else { |
||||
for (var i = 0; i < SYSTEM_LIBRARY_MAPPINGS.length; ++i) { |
||||
var pair = SYSTEM_LIBRARY_MAPPINGS[i]; |
||||
if (pair[0].exec(p)) { |
||||
mavenRef = p.replace(pair[0], pair[1]); |
||||
break; |
||||
} |
||||
} |
||||
if (!mavenRef) { |
||||
throw new CordovaError('Unsupported system library (does not work with gradle): ' + p); |
||||
} |
||||
} |
||||
depsList += ' compile "' + mavenRef + '"\n'; |
||||
}); |
||||
|
||||
// This code is dangerous and actually writes gradle declarations directly into the build.gradle
|
||||
// Try not to mess with this if possible
|
||||
buildGradle = buildGradle.replace(/(SUB-PROJECT DEPENDENCIES START)[\s\S]*(\/\/ SUB-PROJECT DEPENDENCIES END)/, '$1\n' + depsList + ' $2'); |
||||
var includeList = ''; |
||||
propertiesObj.gradleIncludes.forEach(function (includePath) { |
||||
includeList += 'apply from: "' + includePath + '"\n'; |
||||
}); |
||||
buildGradle = buildGradle.replace(/(PLUGIN GRADLE EXTENSIONS START)[\s\S]*(\/\/ PLUGIN GRADLE EXTENSIONS END)/, '$1\n' + includeList + '$2'); |
||||
fs.writeFileSync(path.join(this.root, 'build.gradle'), buildGradle); |
||||
}; |
||||
|
||||
GradleBuilder.prototype.prepEnv = function (opts) { |
||||
var self = this; |
||||
return check_reqs.check_gradle().then(function (gradlePath) { |
||||
return self.runGradleWrapper(gradlePath); |
||||
}).then(function () { |
||||
return self.prepBuildFiles(); |
||||
}).then(function () { |
||||
// We now copy the gradle out of the framework
|
||||
// This is a dirty patch to get the build working
|
||||
/* |
||||
var wrapperDir = path.join(self.root, 'CordovaLib'); |
||||
|