mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-07 14:53:00 +08:00
Resolve issue with plugin target-dir="app*" subdirs (#572)
(subdirectories) such as "appco", with unit tests to verify Needed for @katzer plugins that use de/appplant subdirectory, for example: * cordova-plugin-local-notifications * cordova-plugin-badge * cordova-plugin-background-mode Also needed for cordova-plugin-inappbrowser Co-authored-by: Christopher J. Brody <chris.brody@gmail.com> Co-authored-by: Julio César <jcesarmobile@gmail.com> Co-authored-by: Jan Piotrowski <piotrowski+github@gmail.com>
This commit is contained in:
parent
f2d700515d
commit
8586d4a7ba
2
bin/templates/cordova/lib/pluginHandlers.js
vendored
2
bin/templates/cordova/lib/pluginHandlers.js
vendored
@ -320,7 +320,7 @@ function generateAttributeError (attribute, element, id) {
|
|||||||
function getInstallDestination (obj) {
|
function getInstallDestination (obj) {
|
||||||
var APP_MAIN_PREFIX = 'app/src/main';
|
var APP_MAIN_PREFIX = 'app/src/main';
|
||||||
|
|
||||||
if (obj.targetDir.includes('app')) {
|
if (obj.targetDir.startsWith('app')) {
|
||||||
// If any source file is using the new app directory structure,
|
// If any source file is using the new app directory structure,
|
||||||
// don't penalize it
|
// don't penalize it
|
||||||
return path.join(obj.targetDir, path.basename(obj.src));
|
return path.join(obj.targetDir, path.basename(obj.src));
|
||||||
|
@ -82,6 +82,8 @@
|
|||||||
<source-file src="src/android/testaar2.aar" target-dir="libs" />
|
<source-file src="src/android/testaar2.aar" target-dir="libs" />
|
||||||
<source-file src="src/android/testjar2.jar" target-dir="libs" />
|
<source-file src="src/android/testjar2.jar" target-dir="libs" />
|
||||||
<source-file src="src/android/jniLibs/x86/libnative.so" target-dir="libs/x86" />
|
<source-file src="src/android/jniLibs/x86/libnative.so" target-dir="libs/x86" />
|
||||||
|
<source-file src="src/android/DummyPlugin2.java"
|
||||||
|
target-dir="src/com/appco" />
|
||||||
<lib-file src="src/android/TestLib.jar" />
|
<lib-file src="src/android/TestLib.jar" />
|
||||||
</platform>
|
</platform>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
@ -169,6 +169,12 @@ describe('android project handler', function () {
|
|||||||
'src/android/jniLibs/x86/libnative.so', temp,
|
'src/android/jniLibs/x86/libnative.so', temp,
|
||||||
path.join('app/src/main/jniLibs/x86/libnative.so'), false);
|
path.join('app/src/main/jniLibs/x86/libnative.so'), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Test#006j : should allow installing sources with target-dir that includes "app"', function () {
|
||||||
|
android['source-file'].install(valid_source[10], dummyPluginInfo, dummyProject, {android_studio: true});
|
||||||
|
expect(copyFileSpy)
|
||||||
|
.toHaveBeenCalledWith(dummyplugin, 'src/android/DummyPlugin2.java', temp, path.join('app/src/main/java/com/appco/DummyPlugin2.java'), false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('of <framework> elements', function () {
|
describe('of <framework> elements', function () {
|
||||||
@ -378,6 +384,12 @@ describe('android project handler', function () {
|
|||||||
android['source-file'].uninstall(valid_source[9], dummyPluginInfo, dummyProject, {android_studio: true});
|
android['source-file'].uninstall(valid_source[9], dummyPluginInfo, dummyProject, {android_studio: true});
|
||||||
expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/jniLibs/x86/libnative.so'));
|
expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/jniLibs/x86/libnative.so'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Test#019j : should remove stuff by calling common.deleteJava for Android Studio projects, with target-dir that includes "app"', function () {
|
||||||
|
android['source-file'].install(valid_source[10], dummyPluginInfo, dummyProject, {android_studio: true});
|
||||||
|
android['source-file'].uninstall(valid_source[10], dummyPluginInfo, dummyProject, {android_studio: true});
|
||||||
|
expect(deleteJavaSpy).toHaveBeenCalledWith(temp, path.join('app/src/main/java/com/appco/DummyPlugin2.java'));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('of <framework> elements', function () {
|
describe('of <framework> elements', function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user