Skip to content

Commit

Permalink
Merge pull request #670 from jonpryor/jonp-quote-libjar
Browse files Browse the repository at this point in the history
[Xamarin.Android.Build.Tasks] Properly quote -libraryjars (#666)
  • Loading branch information
Aguilex authored Jun 23, 2017
2 parents 832f9e6 + 7355e47 commit 9359872
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void GenerateProguardCommands (CommandLineBuilder cmd)
cmd.AppendSwitch ("-dontoptimize");
cmd.AppendSwitch ("-dontobfuscate");
cmd.AppendSwitch ("-dontpreverify");
cmd.AppendSwitchIfNotNull ("-include ", $"'{Path.Combine (AndroidSdkBuildToolsPath, "mainDexClasses.rules")}'");
cmd.AppendSwitchUnquotedIfNotNull ("-include ", $"{enclosingChar}'{Path.Combine (AndroidSdkBuildToolsPath, "mainDexClasses.rules")}'{enclosingChar}");
}

void GenerateMainDexListBuilderCommands(CommandLineBuilder cmd)
Expand Down
7 changes: 4 additions & 3 deletions src/Xamarin.Android.Build.Tasks/Tasks/Proguard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,11 @@ protected override string GenerateCommandLineCommands ()
.Select (s => s.Trim ())
.Where (s => !string.IsNullOrWhiteSpace (s));

var enclosingChar = OS.IsWindows ? "\"" : string.Empty;

foreach (var file in configs) {
if (File.Exists (file))
cmd.AppendSwitchIfNotNull ("-include ", file);
cmd.AppendSwitchUnquotedIfNotNull ("-include ", $"{enclosingChar}'{file}'{enclosingChar}");
else
Log.LogWarning ("Proguard configuration file '{0}' was not found.", file);
}
Expand All @@ -179,10 +181,9 @@ protected override string GenerateCommandLineCommands ()
foreach (var jarfile in ExternalJavaLibraries.Select (p => p.ItemSpec))
libjars.Add (jarfile);

var enclosingChar = OS.IsWindows ? "\"" : string.Empty;
cmd.AppendSwitchUnquotedIfNotNull ("-injars ", $"{enclosingChar}'" + string.Join ($"'{Path.PathSeparator}'", injars.Distinct ()) + $"'{enclosingChar}");

cmd.AppendSwitchIfNotNull ("-libraryjars ", $"{enclosingChar}'" + string.Join ($"'{Path.PathSeparator}'", libjars.Distinct ()) + $"'{enclosingChar}");
cmd.AppendSwitchUnquotedIfNotNull ("-libraryjars ", $"{enclosingChar}'" + string.Join ($"'{Path.PathSeparator}'", libjars.Distinct ()) + $"'{enclosingChar}");

cmd.AppendSwitchIfNotNull ("-outjars ", ProguardJarOutput);

Expand Down

0 comments on commit 9359872

Please sign in to comment.