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:
Chris Brody 2018-11-22 08:59:33 -05:00 committed by GitHub
parent a014228f7c
commit ef2434188e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View File

@ -295,7 +295,7 @@ function generateAttributeError (attribute, element, id) {
function getInstallDestination (obj) {
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,
// don't penalize it
return path.join(obj.targetDir, path.basename(obj.src));

View File

@ -82,6 +82,8 @@
<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/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" />
</platform>
</plugin>

View File

@ -163,6 +163,12 @@ describe('android project handler', function () {
'src/android/jniLibs/x86/libnative.so', temp,
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 () {
@ -372,6 +378,12 @@ describe('android project handler', function () {
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'));
});
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 () {