Skip to content

Commit

Permalink
Merge pull request #9827 from jquick-axway/TIMOB-25773-7_1_X
Browse files Browse the repository at this point in the history
[7_1_X][TIMOB-25773] Android: Fixed app build failure caused by " -" in project path
  • Loading branch information
mukherjee2 committed Feb 21, 2018
2 parents 2e189b0 + a43af1a commit 27b51bf
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions android/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4216,17 +4216,28 @@ AndroidBuilder.prototype.runDexer = function runDexer(next) {
return done();
}

// Double quotes given path and escapes double quote characters in file/directory names.
function quotePath(filePath) {
if (!filePath) {
return '""';
}
if (process.platform !== 'win32') {
filePath = filePath.replace(/"/g, '\\"');
}
return '"' + filePath + '"';
}

// Create a ProGuard config file.
let proguardConfig
= '-dontoptimize\n'
+ '-dontobfuscate\n'
+ '-dontpreverify\n'
+ '-dontwarn **\n'
+ '-libraryjars ' + shrinkedAndroid + '\n';
+ '-libraryjars ' + quotePath(shrinkedAndroid) + '\n';
for (let index = 0; index < injarsCore.length; index++) {
proguardConfig += '-injars ' + injarsCore[index] + '(!META-INF/**)\n';
proguardConfig += '-injars ' + quotePath(injarsCore[index]) + '(!META-INF/**)\n';
}
proguardConfig += '-outjars ' + outjar + '\n';
proguardConfig += '-outjars ' + quotePath(outjar) + '\n';
const mainDexProGuardFilePath = path.join(this.buildDir, 'mainDexProGuard.txt');
fs.writeFileSync(mainDexProGuardFilePath, proguardConfig);

Expand All @@ -4235,11 +4246,11 @@ AndroidBuilder.prototype.runDexer = function runDexer(next) {
// such as the JARs Google provides with Android build-tools v27. Google now acquires the newest
// version of ProGuard via Gradle/Maven, which is kept up to date by the ProGuard maintainers.
const gradleAppFileName = (process.platform === 'win32') ? 'gradlew.bat' : 'gradlew';
appc.subprocess.run(path.join(this.buildDir, gradleAppFileName), [
'-b', path.join(this.buildDir, 'proguard.gradle'),
appc.subprocess.run(quotePath(path.join(this.buildDir, gradleAppFileName)), [
'-b', quotePath(path.join(this.buildDir, 'proguard.gradle')),
'-Pforceprocessing=true',
'-Pconfiguration=' + baserules + pathArraySeparator + mainDexProGuardFilePath
], {}, function (code, out, err) {
'-Pconfiguration=' + quotePath(baserules) + pathArraySeparator + quotePath(mainDexProGuardFilePath)
], { shell: true, windowsHide: true }, function (code, out, err) {
if (code) {
this.logger.error(__('Failed to run dexer:'));
this.logger.error();
Expand Down

0 comments on commit 27b51bf

Please sign in to comment.