Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Other target-dir remapping fixes #577

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/templates/cordova/lib/pluginHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,13 @@ function getInstallDestination (obj) {
return path.join(APP_MAIN_PREFIX, 'java', obj.targetDir.substring(4), path.basename(obj.src));
} else if (obj.src.endsWith('.aidl')) {
return path.join(APP_MAIN_PREFIX, 'aidl', obj.targetDir.substring(4), path.basename(obj.src));
} else if (obj.targetDir.includes('libs')) {
} else if (obj.targetDir.startsWith('libs')) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From PR #576: What if there is a character other than / after libs?

if (obj.src.endsWith('.so')) {
return path.join(APP_MAIN_PREFIX, 'jniLibs', obj.targetDir.substring(5), path.basename(obj.src));
} else {
return path.join('app', obj.targetDir, path.basename(obj.src));
}
} else if (obj.targetDir.includes('src/main')) {
} else if (obj.targetDir.startsWith('src/main')) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From PR #576: What if there is a character other than / after src/main ?

return path.join('app', obj.targetDir, path.basename(obj.src));
} else {
// For all other source files not using the new app directory structure,
Expand Down
6 changes: 5 additions & 1 deletion spec/fixtures/org.test.plugins.dummyplugin/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
target-dir="src/com/phonegap/plugins/dummyplugin" />
<source-file src="src/android/DummyPlugin2.java"
target-dir="app/src/main/src/com/phonegap/plugins/dummyplugin" />
<source-file src="src/android/TestLib.jar"
<source-file src="src/android/test1.jar"
target-dir="app/libs" />
<source-file src="src/android/TestAar.aar"
target-dir="app/libs" />
Expand All @@ -84,6 +84,10 @@
<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" />
<source-file src="src/android/mysettings.xml"
target-dir="res/xml/appsrc/mainstreet" />
<source-file src="src/android/mysettings.xml"
target-dir="res/xml/glibsoft" />
<lib-file src="src/android/TestLib.jar" />
</platform>
</plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test
16 changes: 14 additions & 2 deletions spec/unit/pluginHandlers/handlers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('android project handler', function () {
it('Test#006b : should allow installing jar lib file from sources with new app target-dir scheme', function () {
android['source-file'].install(valid_source[2], dummyPluginInfo, dummyProject, {android_studio: true});
expect(copyFileSpy)
.toHaveBeenCalledWith(dummyplugin, 'src/android/TestLib.jar', temp, path.join('app/libs/TestLib.jar'), false);
.toHaveBeenCalledWith(dummyplugin, 'src/android/test1.jar', temp, path.join('app/libs/test1.jar'), false);
});

it('Test#006c : should allow installing aar lib file from sources with new app target-dir scheme', function () {
Expand Down Expand Up @@ -169,6 +169,18 @@ describe('android project handler', function () {
expect(copyFileSpy)
.toHaveBeenCalledWith(dummyplugin, 'src/android/DummyPlugin2.java', temp, path.join('app/src/main/java/com/appco/DummyPlugin2.java'), false);
});

it('Test#006k : should properly install non-Java sources with target-dir="src/mainstreetapps" (includes "src/main")', function () {
android['source-file'].install(valid_source[11], dummyPluginInfo, dummyProject, {android_studio: true});
expect(copyFileSpy)
.toHaveBeenCalledWith(dummyplugin, 'src/android/mysettings.xml', temp, path.join('app/src/main/res/xml/appsrc/mainstreet/mysettings.xml'), false);
});

it('Test#006l : should properly install non-Java sources with target-dir="src/com/glibsoft" (includes "libs")', function () {
android['source-file'].install(valid_source[12], dummyPluginInfo, dummyProject, {android_studio: true});
expect(copyFileSpy)
.toHaveBeenCalledWith(dummyplugin, 'src/android/mysettings.xml', temp, path.join('app/src/main/res/xml/glibsoft/mysettings.xml'), false);
});
});

describe('of <framework> elements', function () {
Expand Down Expand Up @@ -334,7 +346,7 @@ describe('android project handler', function () {
it('Test#019b : should remove stuff by calling common.removeFile for Android Studio projects, of jar with new app target-dir scheme', function () {
android['source-file'].install(valid_source[2], dummyPluginInfo, dummyProject, {android_studio: true});
android['source-file'].uninstall(valid_source[2], dummyPluginInfo, dummyProject, {android_studio: true});
expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/libs/TestLib.jar'));
expect(removeFileSpy).toHaveBeenCalledWith(temp, path.join('app/libs/test1.jar'));
});

it('Test#019c : should remove stuff by calling common.removeFile for Android Studio projects, of aar with new app target-dir scheme', function () {
Expand Down