mirror of
https://github.com/apache/cordova-android.git
synced 2026-01-30 00:05:28 +08:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
725e75fa0d | ||
|
|
36c6f44697 | ||
|
|
750531c4bc | ||
|
|
8a69e32800 | ||
|
|
ea6477f4d3 | ||
|
|
e32bcd88aa | ||
|
|
1efcbfa1d5 | ||
|
|
f19ffd7abd |
@@ -20,6 +20,13 @@
|
||||
-->
|
||||
## Release Notes for Cordova (Android) ##
|
||||
|
||||
### 7.1.2 (Nov 08, 2018)
|
||||
* [CB-14127](https://issues.apache.org/jira/browse/CB-14127): Always put the Google repo above jcenter
|
||||
* [CB-14165](https://issues.apache.org/jira/browse/CB-14165): Emulator: handle "device still connecting" error (#457)
|
||||
* [CB-14125](https://issues.apache.org/jira/browse/CB-14125): Increase old plugin compatibility
|
||||
* [CB-13830](https://issues.apache.org/jira/browse/CB-13830): Add handlers for plugins that use non-Java source files, such as Camera
|
||||
* [CB-14038](https://issues.apache.org/jira/browse/CB-14038): fix false positive detecting project type
|
||||
|
||||
### 7.1.1 (Jul 11, 2018)
|
||||
* Fix unsafe property access in run.js (#445)
|
||||
* Emit log event instead of logging directly (#452)
|
||||
|
||||
2
bin/templates/cordova/Api.js
vendored
2
bin/templates/cordova/Api.js
vendored
@@ -248,7 +248,7 @@ Api.prototype.addPlugin = function (plugin, installOptions) {
|
||||
}).then(function () {
|
||||
if (plugin.getFrameworks(this.platform).length === 0) return;
|
||||
selfEvents.emit('verbose', 'Updating build files since android plugin contained <framework>');
|
||||
// This should pick the correct builder, not just get gradle
|
||||
// This should pick the correct builder, not just get gradle
|
||||
require('./lib/builders/builders').getBuilder(this.builder).prepBuildFiles();
|
||||
}.bind(this))
|
||||
// CB-11022 Return truthy value to prevent running prepare after
|
||||
|
||||
33
bin/templates/cordova/lib/AndroidStudio.js
vendored
33
bin/templates/cordova/lib/AndroidStudio.js
vendored
@@ -6,37 +6,6 @@
|
||||
|
||||
/* jshint esnext: false */
|
||||
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var CordovaError = require('cordova-common').CordovaError;
|
||||
|
||||
module.exports.isAndroidStudioProject = function isAndroidStudioProject (root) {
|
||||
var eclipseFiles = ['AndroidManifest.xml', 'libs', 'res'];
|
||||
var androidStudioFiles = ['app', 'app/src/main'];
|
||||
|
||||
// assume it is an AS project and not an Eclipse project
|
||||
var isEclipse = false;
|
||||
var isAS = true;
|
||||
|
||||
if (!fs.existsSync(root)) {
|
||||
throw new CordovaError('AndroidStudio.js:inAndroidStudioProject root does not exist: ' + root);
|
||||
}
|
||||
|
||||
// if any of the following exists, then we are not an ASProj
|
||||
eclipseFiles.forEach(function (file) {
|
||||
if (fs.existsSync(path.join(root, file))) {
|
||||
isEclipse = true;
|
||||
}
|
||||
});
|
||||
|
||||
// if it is NOT an eclipse project, check that all required files exist
|
||||
if (!isEclipse) {
|
||||
androidStudioFiles.forEach(function (file) {
|
||||
if (!fs.existsSync(path.join(root, file))) {
|
||||
console.log('missing file :: ' + file);
|
||||
isAS = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
return (!isEclipse && isAS);
|
||||
return true;
|
||||
};
|
||||
|
||||
110
bin/templates/cordova/lib/builders/StudioBuilder.js
vendored
110
bin/templates/cordova/lib/builders/StudioBuilder.js
vendored
@@ -215,28 +215,28 @@ StudioBuilder.prototype.prepBuildFiles = function () {
|
||||
StudioBuilder.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 () {
|
||||
// If the gradle distribution URL is set, make sure it points to version we want.
|
||||
// If it's not set, do nothing, assuming that we're using a future version of gradle that we don't want to mess with.
|
||||
// For some reason, using ^ and $ don't work. This does the job, though.
|
||||
var distributionUrlRegex = /distributionUrl.*zip/;
|
||||
var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\\://services.gradle.org/distributions/gradle-4.1-all.zip';
|
||||
var gradleWrapperPropertiesPath = path.join(self.root, 'gradle', 'wrapper', 'gradle-wrapper.properties');
|
||||
shell.chmod('u+w', gradleWrapperPropertiesPath);
|
||||
shell.sed('-i', distributionUrlRegex, 'distributionUrl=' + distributionUrl, gradleWrapperPropertiesPath);
|
||||
.then(function (gradlePath) {
|
||||
return self.runGradleWrapper(gradlePath);
|
||||
}).then(function () {
|
||||
return self.prepBuildFiles();
|
||||
}).then(function () {
|
||||
// If the gradle distribution URL is set, make sure it points to version we want.
|
||||
// If it's not set, do nothing, assuming that we're using a future version of gradle that we don't want to mess with.
|
||||
// For some reason, using ^ and $ don't work. This does the job, though.
|
||||
var distributionUrlRegex = /distributionUrl.*zip/;
|
||||
var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\\://services.gradle.org/distributions/gradle-4.1-all.zip';
|
||||
var gradleWrapperPropertiesPath = path.join(self.root, 'gradle', 'wrapper', 'gradle-wrapper.properties');
|
||||
shell.chmod('u+w', gradleWrapperPropertiesPath);
|
||||
shell.sed('-i', distributionUrlRegex, 'distributionUrl=' + distributionUrl, gradleWrapperPropertiesPath);
|
||||
|
||||
var propertiesFile = opts.buildType + SIGNING_PROPERTIES;
|
||||
var propertiesFilePath = path.join(self.root, propertiesFile);
|
||||
if (opts.packageInfo) {
|
||||
fs.writeFileSync(propertiesFilePath, TEMPLATE + opts.packageInfo.toProperties());
|
||||
} else if (isAutoGenerated(propertiesFilePath)) {
|
||||
shell.rm('-f', propertiesFilePath);
|
||||
}
|
||||
});
|
||||
var propertiesFile = opts.buildType + SIGNING_PROPERTIES;
|
||||
var propertiesFilePath = path.join(self.root, propertiesFile);
|
||||
if (opts.packageInfo) {
|
||||
fs.writeFileSync(propertiesFilePath, TEMPLATE + opts.packageInfo.toProperties());
|
||||
} else if (isAutoGenerated(propertiesFilePath)) {
|
||||
shell.rm('-f', propertiesFilePath);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -248,33 +248,33 @@ StudioBuilder.prototype.build = function (opts) {
|
||||
var args = this.getArgs(opts.buildType === 'debug' ? 'debug' : 'release', opts);
|
||||
|
||||
return spawn(wrapper, args, {stdio: 'pipe'})
|
||||
.progress(function (stdio) {
|
||||
if (stdio.stderr) {
|
||||
/*
|
||||
* Workaround for the issue with Java printing some unwanted information to
|
||||
* stderr instead of stdout.
|
||||
* This function suppresses 'Picked up _JAVA_OPTIONS' message from being
|
||||
* printed to stderr. See https://issues.apache.org/jira/browse/CB-9971 for
|
||||
* explanation.
|
||||
*/
|
||||
var suppressThisLine = /^Picked up _JAVA_OPTIONS: /i.test(stdio.stderr.toString());
|
||||
if (suppressThisLine) {
|
||||
return;
|
||||
.progress(function (stdio) {
|
||||
if (stdio.stderr) {
|
||||
/*
|
||||
* Workaround for the issue with Java printing some unwanted information to
|
||||
* stderr instead of stdout.
|
||||
* This function suppresses 'Picked up _JAVA_OPTIONS' message from being
|
||||
* printed to stderr. See https://issues.apache.org/jira/browse/CB-9971 for
|
||||
* explanation.
|
||||
*/
|
||||
var suppressThisLine = /^Picked up _JAVA_OPTIONS: /i.test(stdio.stderr.toString());
|
||||
if (suppressThisLine) {
|
||||
return;
|
||||
}
|
||||
process.stderr.write(stdio.stderr);
|
||||
} else {
|
||||
process.stdout.write(stdio.stdout);
|
||||
}
|
||||
process.stderr.write(stdio.stderr);
|
||||
} else {
|
||||
process.stdout.write(stdio.stdout);
|
||||
}
|
||||
}).catch(function (error) {
|
||||
if (error.toString().indexOf('failed to find target with hash string') >= 0) {
|
||||
return check_reqs.check_android_target(error).then(function () {
|
||||
// If due to some odd reason - check_android_target succeeds
|
||||
// we should still fail here.
|
||||
return Q.reject(error);
|
||||
});
|
||||
}
|
||||
return Q.reject(error);
|
||||
});
|
||||
}).catch(function (error) {
|
||||
if (error.toString().indexOf('failed to find target with hash string') >= 0) {
|
||||
return check_reqs.check_android_target(error).then(function () {
|
||||
// If due to some odd reason - check_android_target succeeds
|
||||
// we should still fail here.
|
||||
return Q.reject(error);
|
||||
});
|
||||
}
|
||||
return Q.reject(error);
|
||||
});
|
||||
};
|
||||
|
||||
StudioBuilder.prototype.clean = function (opts) {
|
||||
@@ -284,16 +284,16 @@ StudioBuilder.prototype.clean = function (opts) {
|
||||
return Q().then(function () {
|
||||
return spawn(wrapper, args, {stdio: 'inherit'});
|
||||
})
|
||||
.then(function () {
|
||||
shell.rm('-rf', path.join(builder.root, 'out'));
|
||||
.then(function () {
|
||||
shell.rm('-rf', path.join(builder.root, 'out'));
|
||||
|
||||
['debug', 'release'].forEach(function (config) {
|
||||
var propertiesFilePath = path.join(builder.root, config + SIGNING_PROPERTIES);
|
||||
if (isAutoGenerated(propertiesFilePath)) {
|
||||
shell.rm('-f', propertiesFilePath);
|
||||
}
|
||||
['debug', 'release'].forEach(function (config) {
|
||||
var propertiesFilePath = path.join(builder.root, config + SIGNING_PROPERTIES);
|
||||
if (isAutoGenerated(propertiesFilePath)) {
|
||||
shell.rm('-f', propertiesFilePath);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = StudioBuilder;
|
||||
|
||||
3
bin/templates/cordova/lib/emulator.js
vendored
3
bin/templates/cordova/lib/emulator.js
vendored
@@ -344,7 +344,8 @@ module.exports.wait_for_emulator = function (port) {
|
||||
}, function (error) {
|
||||
if ((error && error.message &&
|
||||
(error.message.indexOf('not found') > -1)) ||
|
||||
(error.message.indexOf('device offline') > -1)) {
|
||||
(error.message.indexOf('device offline') > -1) ||
|
||||
(error.message.indexOf('device still connecting') > -1)) {
|
||||
// emulator not yet started, continue waiting
|
||||
return self.wait_for_emulator(port);
|
||||
} else {
|
||||
|
||||
33
bin/templates/cordova/lib/pluginHandlers.js
vendored
33
bin/templates/cordova/lib/pluginHandlers.js
vendored
@@ -34,15 +34,7 @@ var handlers = {
|
||||
// a later plugins release. This is for legacy plugins to work with Cordova.
|
||||
|
||||
if (options && options.android_studio === true) {
|
||||
// If a Java file is using the new directory structure, don't penalize it
|
||||
if (!obj.targetDir.includes('app/src/main')) {
|
||||
if (obj.src.endsWith('.java')) {
|
||||
dest = path.join('app/src/main/java', obj.targetDir.substring(4), path.basename(obj.src));
|
||||
} else if (obj.src.endsWith('.xml')) {
|
||||
// We are making a huge assumption here that XML files will be going to res/xml or values/xml
|
||||
dest = path.join('app/src/main', obj.targetDir, path.basename(obj.src));
|
||||
}
|
||||
}
|
||||
dest = studioPathRemap(obj);
|
||||
}
|
||||
|
||||
if (options && options.force) {
|
||||
@@ -55,10 +47,16 @@ var handlers = {
|
||||
var dest = path.join(obj.targetDir, path.basename(obj.src));
|
||||
|
||||
if (options && options.android_studio === true) {
|
||||
dest = path.join('app/src/main/java', obj.targetDir.substring(4), path.basename(obj.src));
|
||||
dest = studioPathRemap(obj);
|
||||
}
|
||||
|
||||
deleteJava(project.projectDir, dest);
|
||||
// TODO: Add Koltin extension to uninstall, since they are handled like Java files
|
||||
if (obj.src.endsWith('java')) {
|
||||
deleteJava(project.projectDir, dest);
|
||||
} else {
|
||||
// Just remove the file, not the whole parent directory
|
||||
removeFile(project.projectDir, dest);
|
||||
}
|
||||
}
|
||||
},
|
||||
'lib-file': {
|
||||
@@ -318,3 +316,16 @@ function removeFileAndParents (baseDir, destFile, stopper) {
|
||||
function generateAttributeError (attribute, element, id) {
|
||||
return 'Required attribute "' + attribute + '" not specified in <' + element + '> element from plugin: ' + id;
|
||||
}
|
||||
|
||||
function studioPathRemap (obj) {
|
||||
// If a Java file is using the new directory structure, don't penalize it
|
||||
if (!obj.targetDir.includes('app/src/main')) {
|
||||
if (obj.src.endsWith('.java')) {
|
||||
return path.join('app/src/main/java', obj.targetDir.substring(4), path.basename(obj.src));
|
||||
} else {
|
||||
// For all other files, add 'app/src/main' to the targetDir if it didn't have it already
|
||||
return path.join('app/src/main', obj.targetDir, path.basename(obj.src));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
// Coho updates this line:
|
||||
var VERSION = "7.1.1";
|
||||
var VERSION = "7.1.2";
|
||||
|
||||
module.exports.version = VERSION;
|
||||
|
||||
|
||||
4
bin/templates/project/assets/www/cordova.js
vendored
4
bin/templates/project/assets/www/cordova.js
vendored
@@ -19,7 +19,7 @@
|
||||
under the License.
|
||||
*/
|
||||
;(function() {
|
||||
var PLATFORM_VERSION_BUILD_LABEL = '7.1.1';
|
||||
var PLATFORM_VERSION_BUILD_LABEL = '7.1.2';
|
||||
// file: src/scripts/require.js
|
||||
|
||||
/* jshint -W079 */
|
||||
@@ -2186,4 +2186,4 @@ window.cordova = require('cordova');
|
||||
|
||||
require('cordova/init');
|
||||
|
||||
})();
|
||||
})();
|
||||
|
||||
@@ -24,10 +24,10 @@ ext {
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
maven {
|
||||
url "https://maven.google.com"
|
||||
}
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -42,7 +42,7 @@ apply plugin: 'com.github.dcendents.android-maven'
|
||||
apply plugin: 'com.jfrog.bintray'
|
||||
|
||||
group = 'org.apache.cordova'
|
||||
version = '7.1.1'
|
||||
version = '7.1.2'
|
||||
|
||||
android {
|
||||
compileSdkVersion cdvCompileSdkVersion
|
||||
@@ -129,9 +129,9 @@ bintray {
|
||||
licenses = ['Apache-2.0']
|
||||
labels = ['android', 'cordova', 'phonegap']
|
||||
version {
|
||||
name = '7.1.1'
|
||||
name = '7.1.2'
|
||||
released = new Date()
|
||||
vcsTag = '7.1.1'
|
||||
vcsTag = '7.1.2'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import android.webkit.WebChromeClient.CustomViewCallback;
|
||||
* are not expected to implement it.
|
||||
*/
|
||||
public interface CordovaWebView {
|
||||
public static final String CORDOVA_VERSION = "7.1.1";
|
||||
public static final String CORDOVA_VERSION = "7.1.2";
|
||||
|
||||
void init(CordovaInterface cordova, List<PluginEntry> pluginEntries, CordovaPreferences preferences);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cordova-android",
|
||||
"version": "7.1.1",
|
||||
"version": "7.1.2",
|
||||
"description": "cordova-android release",
|
||||
"bin": {
|
||||
"create": "bin/create"
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
|
||||
Copyright 2013 Anis Kadri
|
||||
|
||||
Licensed 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.
|
||||
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:windowSoftInputMode="adjustPan"
|
||||
package="com.alunny.childapp" android:versionName="1.1" android:versionCode="5">
|
||||
<supports-screens
|
||||
android:largeScreens="true"
|
||||
android:normalScreens="true"
|
||||
android:smallScreens="true"
|
||||
android:xlargeScreens="true"
|
||||
android:resizeable="true"
|
||||
android:anyDensity="true"
|
||||
/>
|
||||
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_SMS" />
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<uses-permission android:name="android.permission.RECORD_VIDEO"/>
|
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
|
||||
|
||||
<uses-feature android:name="android.hardware.camera" />
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" />
|
||||
|
||||
<application android:icon="@drawable/icon" android:label="@string/app_name"
|
||||
android:debuggable="true">
|
||||
<activity android:name="ChildApp" android:label="@string/app_name"
|
||||
android:configChanges="orientation|keyboardHidden">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="org.test.DroidGap" android:label="@string/app_name"
|
||||
android:configChanges="orientation|keyboardHidden">
|
||||
<intent-filter>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
<uses-sdk android:minSdkVersion="5" />
|
||||
</manifest>
|
||||
54
spec/fixtures/android_project/res/xml/config.xml
vendored
54
spec/fixtures/android_project/res/xml/config.xml
vendored
@@ -1,54 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<cordova>
|
||||
<!--
|
||||
access elements control the Android whitelist.
|
||||
Domains are assumed blocked unless set otherwise
|
||||
-->
|
||||
|
||||
<access origin="http://127.0.0.1*"/> <!-- allow local pages -->
|
||||
|
||||
<!-- <access origin="https://example.com" /> allow any secure requests to example.com -->
|
||||
<!-- <access origin="https://example.com" subdomains="true" /> such as above, but including subdomains, such as www -->
|
||||
<!-- <access origin=".*"/> Allow all domains, suggested development use only -->
|
||||
|
||||
<log level="DEBUG"/>
|
||||
<preference name="useBrowserHistory" value="false" />
|
||||
<plugins>
|
||||
<plugin name="App" value="org.apache.cordova.App"/>
|
||||
<plugin name="Geolocation" value="org.apache.cordova.GeoBroker"/>
|
||||
<plugin name="Device" value="org.apache.cordova.Device"/>
|
||||
<plugin name="Accelerometer" value="org.apache.cordova.AccelListener"/>
|
||||
<plugin name="Compass" value="org.apache.cordova.CompassListener"/>
|
||||
<plugin name="Media" value="org.apache.cordova.AudioHandler"/>
|
||||
<plugin name="Camera" value="org.apache.cordova.CameraLauncher"/>
|
||||
<plugin name="org.apache.cordova.core.contacts" value="org.apache.cordova.ContactManager"/>
|
||||
<plugin name="File" value="org.apache.cordova.FileUtils"/>
|
||||
<plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/>
|
||||
<plugin name="Notification" value="org.apache.cordova.Notification"/>
|
||||
<plugin name="Storage" value="org.apache.cordova.Storage"/>
|
||||
<plugin name="Temperature" value="org.apache.cordova.TempListener"/>
|
||||
<plugin name="FileTransfer" value="org.apache.cordova.FileTransfer"/>
|
||||
<plugin name="Capture" value="org.apache.cordova.Capture"/>
|
||||
<plugin name="Battery" value="org.apache.cordova.BatteryListener"/>
|
||||
<plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/>
|
||||
</plugins>
|
||||
</cordova>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
@@ -14,6 +15,7 @@ buildscript {
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +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 path = require('path');
|
||||
var AndroidProject = require('../../bin/templates/cordova/lib/AndroidProject');
|
||||
var android_project = path.join(__dirname, '../fixtures/android_project');
|
||||
|
||||
describe('AndroidProject class', function () {
|
||||
describe('getPackageName method', function () {
|
||||
it('Test#001 : should return an android project\'s proper package name', function () {
|
||||
expect(AndroidProject.getProjectFile(android_project).getPackageName())
|
||||
.toEqual('com.alunny.childapp');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -8,9 +8,4 @@ describe('AndroidStudio module', function () {
|
||||
var isAndStud = AndroidStudio.isAndroidStudioProject(root);
|
||||
expect(isAndStud).toBe(true);
|
||||
});
|
||||
it('should return false non Android Studio project', function () {
|
||||
var root = path.join(__dirname, '../fixtures/android_project/');
|
||||
var isAndStud = AndroidStudio.isAndroidStudioProject(root);
|
||||
expect(isAndStud).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -28,7 +28,7 @@ var temp = path.join(os.tmpdir(), 'plugman');
|
||||
var plugins_dir = path.join(temp, 'cordova/plugins');
|
||||
var dummyplugin = path.join(__dirname, '../../fixtures/org.test.plugins.dummyplugin');
|
||||
var faultyplugin = path.join(__dirname, '../../fixtures/org.test.plugins.faultyplugin');
|
||||
var android_project = path.join(__dirname, '../../fixtures/android_project/*');
|
||||
var android_studio_project = path.join(__dirname, '../../fixtures/android_studio_project/*');
|
||||
|
||||
var PluginInfo = require('cordova-common').PluginInfo;
|
||||
var AndroidProject = require('../../../bin/templates/cordova/lib/AndroidProject');
|
||||
@@ -60,48 +60,44 @@ describe('android project handler', function () {
|
||||
});
|
||||
|
||||
describe('of <lib-file> elements', function () {
|
||||
it('Test#001 : should copy files', function () {
|
||||
android['lib-file'].install(valid_libs[0], dummyPluginInfo, dummyProject);
|
||||
expect(copyFileSpy).toHaveBeenCalledWith(dummyplugin, 'src/android/TestLib.jar', temp, path.join('libs', 'TestLib.jar'), false);
|
||||
});
|
||||
it('Test#002 : should copy files for Android Studio projects', function () {
|
||||
it('Test#001 : should copy files for Android Studio projects', function () {
|
||||
android['lib-file'].install(valid_libs[0], dummyPluginInfo, dummyProject, {android_studio: true});
|
||||
expect(copyFileSpy).toHaveBeenCalledWith(dummyplugin, 'src/android/TestLib.jar', temp, path.join('app', 'libs', 'TestLib.jar'), false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('of <resource-file> elements', function () {
|
||||
it('Test#003 : should copy files to the correct location on a non-Android Studio project', function () {
|
||||
android['resource-file'].install(valid_resources[0], dummyPluginInfo, dummyProject);
|
||||
expect(copyFileSpy).toHaveBeenCalledWith(dummyplugin, 'android-resource.xml', temp, path.join('res', 'xml', 'dummy.xml'), false);
|
||||
it('Test#002 : should copy files to the correct location on an Android Studio project', function () {
|
||||
android['resource-file'].install(valid_resources[0], dummyPluginInfo, dummyProject, {android_studio: true});
|
||||
expect(copyFileSpy).toHaveBeenCalledWith(dummyplugin, 'android-resource.xml', temp, path.join('app', 'src', 'main', 'res', 'xml', 'dummy.xml'), false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('of <source-file> elements', function () {
|
||||
beforeEach(function () {
|
||||
shell.cp('-rf', android_project, temp);
|
||||
shell.cp('-rf', android_studio_project, temp);
|
||||
});
|
||||
|
||||
it('Test#004 : should copy stuff from one location to another by calling common.copyFile', function () {
|
||||
it('Test#003 : should copy stuff from one location to another by calling common.copyFile', function () {
|
||||
android['source-file'].install(valid_source[0], dummyPluginInfo, dummyProject);
|
||||
expect(copyFileSpy)
|
||||
.toHaveBeenCalledWith(dummyplugin, 'src/android/DummyPlugin.java', temp, path.join('src/com/phonegap/plugins/dummyplugin/DummyPlugin.java'), false);
|
||||
});
|
||||
|
||||
it('Test#005 : should install source files to the right location for Android Studio projects', function () {
|
||||
it('Test#004 : should install source files to the right location for Android Studio projects', function () {
|
||||
android['source-file'].install(valid_source[0], dummyPluginInfo, dummyProject, {android_studio: true});
|
||||
expect(copyFileSpy)
|
||||
.toHaveBeenCalledWith(dummyplugin, 'src/android/DummyPlugin.java', temp, path.join('app/src/main/java/com/phonegap/plugins/dummyplugin/DummyPlugin.java'), false);
|
||||
});
|
||||
|
||||
it('Test#006 : should throw if source file cannot be found', function () {
|
||||
it('Test#005 : should throw if source file cannot be found', function () {
|
||||
common.__set__('copyFile', copyFileOrig);
|
||||
expect(function () {
|
||||
android['source-file'].install(invalid_source[0], faultyPluginInfo, dummyProject);
|
||||
}).toThrow(new Error('"' + path.resolve(faultyplugin, 'src/android/NotHere.java') + '" not found!'));
|
||||
});
|
||||
|
||||
it('Test#007 : should throw if target file already exists', function () {
|
||||
it('Test#006 : should throw if target file already exists', function () {
|
||||
// write out a file
|
||||
var target = path.resolve(temp, 'src/com/phonegap/plugins/dummyplugin');
|
||||
shell.mkdir('-p', target);
|
||||
@@ -122,7 +118,7 @@ describe('android project handler', function () {
|
||||
var copyNewFileSpy = jasmine.createSpy('copyNewFile');
|
||||
|
||||
beforeEach(function () {
|
||||
shell.cp('-rf', android_project, temp);
|
||||
shell.cp('-rf', android_studio_project, temp);
|
||||
|
||||
spyOn(dummyProject, 'addSystemLibrary');
|
||||
spyOn(dummyProject, 'addSubProject');
|
||||
@@ -134,23 +130,23 @@ describe('android project handler', function () {
|
||||
common.__set__('copyNewFile', copyNewFileOrig);
|
||||
});
|
||||
|
||||
it('Test#008 : should throw if framework doesn\'t have "src" attribute', function () {
|
||||
it('Test#007 : should throw if framework doesn\'t have "src" attribute', function () {
|
||||
expect(function () { android.framework.install({}, dummyPluginInfo, dummyProject); }).toThrow();
|
||||
});
|
||||
|
||||
it('Test#009 : should install framework without "parent" attribute into project root', function () {
|
||||
it('Test#008 : should install framework without "parent" attribute into project root', function () {
|
||||
var framework = {src: 'plugin-lib'};
|
||||
android.framework.install(framework, dummyPluginInfo, dummyProject);
|
||||
expect(dummyProject.addSystemLibrary).toHaveBeenCalledWith(dummyProject.projectDir, someString);
|
||||
});
|
||||
|
||||
it('Test#010 : should install framework with "parent" attribute into parent framework dir', function () {
|
||||
it('Test#009 : should install framework with "parent" attribute into parent framework dir', function () {
|
||||
var childFramework = {src: 'plugin-lib2', parent: 'plugin-lib'};
|
||||
android.framework.install(childFramework, dummyPluginInfo, dummyProject);
|
||||
expect(dummyProject.addSystemLibrary).toHaveBeenCalledWith(path.resolve(dummyProject.projectDir, childFramework.parent), someString);
|
||||
});
|
||||
|
||||
it('Test#011 : should not copy anything if "custom" attribute is not set', function () {
|
||||
it('Test#010 : should not copy anything if "custom" attribute is not set', function () {
|
||||
var framework = {src: 'plugin-lib'};
|
||||
var cpSpy = spyOn(shell, 'cp');
|
||||
android.framework.install(framework, dummyPluginInfo, dummyProject);
|
||||
@@ -158,14 +154,14 @@ describe('android project handler', function () {
|
||||
expect(cpSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('Test#012 : should copy framework sources if "custom" attribute is set', function () {
|
||||
it('Test#011 : should copy framework sources if "custom" attribute is set', function () {
|
||||
var framework = {src: 'plugin-lib', custom: true};
|
||||
android.framework.install(framework, dummyPluginInfo, dummyProject);
|
||||
expect(dummyProject.addSubProject).toHaveBeenCalledWith(dummyProject.projectDir, someString);
|
||||
expect(copyNewFileSpy).toHaveBeenCalledWith(dummyPluginInfo.dir, framework.src, dummyProject.projectDir, someString, false);
|
||||
});
|
||||
|
||||
it('Test#013 : should install gradleReference using project.addGradleReference', function () {
|
||||
it('Test#012 : should install gradleReference using project.addGradleReference', function () {
|
||||
var framework = {src: 'plugin-lib', custom: true, type: 'gradleReference'};
|
||||
android.framework.install(framework, dummyPluginInfo, dummyProject);
|
||||
expect(copyNewFileSpy).toHaveBeenCalledWith(dummyPluginInfo.dir, framework.src, dummyProject.projectDir, someString, false);
|
||||
@@ -183,13 +179,13 @@ describe('android project handler', function () {
|
||||
platformWwwDest = path.resolve(dummyProject.platformWww, 'plugins', dummyPluginInfo.id, jsModule.src);
|
||||
});
|
||||
|
||||
it('Test#014 : should put module to both www and platform_www when options.usePlatformWww flag is specified', function () {
|
||||
it('Test#013 : should put module to both www and platform_www when options.usePlatformWww flag is specified', function () {
|
||||
android['js-module'].install(jsModule, dummyPluginInfo, dummyProject, {usePlatformWww: true});
|
||||
expect(fs.writeFileSync).toHaveBeenCalledWith(wwwDest, jasmine.any(String), 'utf-8');
|
||||
expect(fs.writeFileSync).toHaveBeenCalledWith(platformWwwDest, jasmine.any(String), 'utf-8');
|
||||
});
|
||||
|
||||
it('Test#015 : should put module to www only when options.usePlatformWww flag is not specified', function () {
|
||||
it('Test#014 : should put module to www only when options.usePlatformWww flag is not specified', function () {
|
||||
android['js-module'].install(jsModule, dummyPluginInfo, dummyProject);
|
||||
expect(fs.writeFileSync).toHaveBeenCalledWith(wwwDest, jasmine.any(String), 'utf-8');
|
||||
expect(fs.writeFileSync).not.toHaveBeenCalledWith(platformWwwDest, jasmine.any(String), 'utf-8');
|
||||
@@ -206,13 +202,13 @@ describe('android project handler', function () {
|
||||
platformWwwDest = path.resolve(dummyProject.platformWww, asset.target);
|
||||
});
|
||||
|
||||
it('Test#016 : should put asset to both www and platform_www when options.usePlatformWww flag is specified', function () {
|
||||
it('Test#015 : should put asset to both www and platform_www when options.usePlatformWww flag is specified', function () {
|
||||
android.asset.install(asset, dummyPluginInfo, dummyProject, {usePlatformWww: true});
|
||||
expect(copyFileSpy).toHaveBeenCalledWith(dummyPluginInfo.dir, asset.src, dummyProject.www, asset.target);
|
||||
expect(copyFileSpy).toHaveBeenCalledWith(dummyPluginInfo.dir, asset.src, dummyProject.platformWww, asset.target);
|
||||
});
|
||||
|
||||
it('Test#017 : should put asset to www only when options.usePlatformWww flag is not specified', function () {
|
||||
it('Test#016 : should put asset to www only when options.usePlatformWww flag is not specified', function () {
|
||||
android.asset.install(asset, dummyPluginInfo, dummyProject);
|
||||
expect(copyFileSpy).toHaveBeenCalledWith(dummyPluginInfo.dir, asset.src, dummyProject.www, asset.target);
|
||||
expect(copyFileSpy).not.toHaveBeenCalledWith(dummyPluginInfo.dir, asset.src, dummyProject.platformWww, asset.target);
|
||||
@@ -232,7 +228,7 @@ describe('android project handler', function () {
|
||||
beforeEach(function () {
|
||||
shell.mkdir('-p', temp);
|
||||
shell.mkdir('-p', plugins_dir);
|
||||
shell.cp('-rf', android_project, temp);
|
||||
shell.cp('-rf', android_studio_project, temp);
|
||||
AndroidProject.purgeCache();
|
||||
dummyProject = AndroidProject.getProjectFile(temp);
|
||||
common.__set__('removeFile', removeFileSpy);
|
||||
@@ -246,12 +242,7 @@ describe('android project handler', function () {
|
||||
});
|
||||
|
||||
describe('of <lib-file> elements', function () {
|
||||
it('Test#018 : should remove jar files', function () {
|
||||
android['lib-file'].install(valid_libs[0], dummyPluginInfo, dummyProject);
|
||||
android['lib-file'].uninstall(valid_libs[0], dummyPluginInfo, dummyProject);
|
||||
expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('libs/TestLib.jar'));
|
||||
});
|
||||
it('Test#019 : should remove jar files for Android Studio projects', function () {
|
||||
it('Test#017 : should remove jar files for Android Studio projects', function () {
|
||||
android['lib-file'].install(valid_libs[0], dummyPluginInfo, dummyProject, {android_studio: true});
|
||||
android['lib-file'].uninstall(valid_libs[0], dummyPluginInfo, dummyProject, {android_studio: true});
|
||||
expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/libs/TestLib.jar'));
|
||||
@@ -259,12 +250,7 @@ describe('android project handler', function () {
|
||||
});
|
||||
|
||||
describe('of <resource-file> elements', function () {
|
||||
it('Test#020 : should remove files', function () {
|
||||
android['resource-file'].install(valid_resources[0], dummyPluginInfo, dummyProject);
|
||||
android['resource-file'].uninstall(valid_resources[0], dummyPluginInfo, dummyProject);
|
||||
expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('res/xml/dummy.xml'));
|
||||
});
|
||||
it('Test#021 : should remove files for Android Studio projects', function () {
|
||||
it('Test#018 : should remove files for Android Studio projects', function () {
|
||||
android['resource-file'].install(valid_resources[0], dummyPluginInfo, dummyProject, {android_studio: true});
|
||||
android['resource-file'].uninstall(valid_resources[0], dummyPluginInfo, dummyProject, {android_studio: true});
|
||||
expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/res/xml/dummy.xml'));
|
||||
@@ -272,12 +258,7 @@ describe('android project handler', function () {
|
||||
});
|
||||
|
||||
describe('of <source-file> elements', function () {
|
||||
it('Test#022 : should remove stuff by calling common.deleteJava', function () {
|
||||
android['source-file'].install(valid_source[0], dummyPluginInfo, dummyProject);
|
||||
android['source-file'].uninstall(valid_source[0], dummyPluginInfo, dummyProject);
|
||||
expect(deleteJavaSpy).toHaveBeenCalledWith(temp, path.join('src/com/phonegap/plugins/dummyplugin/DummyPlugin.java'));
|
||||
});
|
||||
it('Test#023 : should remove stuff by calling common.deleteJava for Android Studio projects', function () {
|
||||
it('Test#019 : should remove stuff by calling common.deleteJava for Android Studio projects', function () {
|
||||
android['source-file'].install(valid_source[0], dummyPluginInfo, dummyProject, {android_studio: true});
|
||||
android['source-file'].uninstall(valid_source[0], dummyPluginInfo, dummyProject, {android_studio: true});
|
||||
expect(deleteJavaSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/java/com/phonegap/plugins/dummyplugin/DummyPlugin.java'));
|
||||
@@ -296,30 +277,30 @@ describe('android project handler', function () {
|
||||
spyOn(dummyProject, 'removeGradleReference');
|
||||
});
|
||||
|
||||
it('Test#024 : should throw if framework doesn\'t have "src" attribute', function () {
|
||||
it('Test#020 : should throw if framework doesn\'t have "src" attribute', function () {
|
||||
expect(function () { android.framework.uninstall({}, dummyPluginInfo, dummyProject); }).toThrow();
|
||||
});
|
||||
|
||||
it('Test#025 : should uninstall framework without "parent" attribute into project root', function () {
|
||||
it('Test#021 : should uninstall framework without "parent" attribute into project root', function () {
|
||||
var framework = {src: 'plugin-lib'};
|
||||
android.framework.uninstall(framework, dummyPluginInfo, dummyProject);
|
||||
expect(dummyProject.removeSystemLibrary).toHaveBeenCalledWith(dummyProject.projectDir, someString);
|
||||
});
|
||||
|
||||
it('Test#026 : should uninstall framework with "parent" attribute into parent framework dir', function () {
|
||||
it('Test#022 : should uninstall framework with "parent" attribute into parent framework dir', function () {
|
||||
var childFramework = {src: 'plugin-lib2', parent: 'plugin-lib'};
|
||||
android.framework.uninstall(childFramework, dummyPluginInfo, dummyProject);
|
||||
expect(dummyProject.removeSystemLibrary).toHaveBeenCalledWith(path.resolve(dummyProject.projectDir, childFramework.parent), someString);
|
||||
});
|
||||
|
||||
it('Test#027 : should remove framework sources if "custom" attribute is set', function () {
|
||||
it('Test#023 : should remove framework sources if "custom" attribute is set', function () {
|
||||
var framework = {src: 'plugin-lib', custom: true};
|
||||
android.framework.uninstall(framework, dummyPluginInfo, dummyProject);
|
||||
expect(dummyProject.removeSubProject).toHaveBeenCalledWith(dummyProject.projectDir, someString);
|
||||
expect(removeFileSpy).toHaveBeenCalledWith(dummyProject.projectDir, someString);
|
||||
});
|
||||
|
||||
it('Test#28 : should install gradleReference using project.removeGradleReference', function () {
|
||||
it('Test#24 : should install gradleReference using project.removeGradleReference', function () {
|
||||
var framework = {src: 'plugin-lib', custom: true, type: 'gradleReference'};
|
||||
android.framework.uninstall(framework, dummyPluginInfo, dummyProject);
|
||||
expect(removeFileSpy).toHaveBeenCalledWith(dummyProject.projectDir, someString);
|
||||
@@ -345,13 +326,13 @@ describe('android project handler', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('Test#029 : should put module to both www and platform_www when options.usePlatformWww flag is specified', function () {
|
||||
it('Test#025 : should put module to both www and platform_www when options.usePlatformWww flag is specified', function () {
|
||||
android['js-module'].uninstall(jsModule, dummyPluginInfo, dummyProject, {usePlatformWww: true});
|
||||
expect(shell.rm).toHaveBeenCalledWith('-Rf', wwwDest);
|
||||
expect(shell.rm).toHaveBeenCalledWith('-Rf', platformWwwDest);
|
||||
});
|
||||
|
||||
it('Test#030 : should put module to www only when options.usePlatformWww flag is not specified', function () {
|
||||
it('Test#026 : should put module to www only when options.usePlatformWww flag is not specified', function () {
|
||||
android['js-module'].uninstall(jsModule, dummyPluginInfo, dummyProject);
|
||||
expect(shell.rm).toHaveBeenCalledWith('-Rf', wwwDest);
|
||||
expect(shell.rm).not.toHaveBeenCalledWith('-Rf', platformWwwDest);
|
||||
@@ -375,13 +356,13 @@ describe('android project handler', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('Test#031 : should put module to both www and platform_www when options.usePlatformWww flag is specified', function () {
|
||||
it('Test#027 : should put module to both www and platform_www when options.usePlatformWww flag is specified', function () {
|
||||
android.asset.uninstall(asset, dummyPluginInfo, dummyProject, {usePlatformWww: true});
|
||||
expect(shell.rm).toHaveBeenCalledWith(jasmine.any(String), wwwDest);
|
||||
expect(shell.rm).toHaveBeenCalledWith(jasmine.any(String), platformWwwDest);
|
||||
});
|
||||
|
||||
it('Test#032 : should put module to www only when options.usePlatformWww flag is not specified', function () {
|
||||
it('Test#028 : should put module to www only when options.usePlatformWww flag is not specified', function () {
|
||||
android.asset.uninstall(asset, dummyPluginInfo, dummyProject);
|
||||
expect(shell.rm).toHaveBeenCalledWith(jasmine.any(String), wwwDest);
|
||||
expect(shell.rm).not.toHaveBeenCalledWith(jasmine.any(String), platformWwwDest);
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.0.1'
|
||||
@@ -33,8 +33,8 @@ buildscript {
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user