Skip to content

Commit 10f3e9e

Browse files
committed
Added ToJavaEscapedPath
1 parent 81497e1 commit 10f3e9e

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/Xamarin.Android.Build.Tasks/Tasks/JavaCompileToolTask.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private void GenerateResponseFile ()
7878
// Include any user .java files
7979
if (JavaSourceFiles != null)
8080
foreach (var file in JavaSourceFiles.Where (p => Path.GetExtension (p.ItemSpec) == ".java"))
81-
sw.WriteLine (string.Format ("\"{0}\"", file.ItemSpec.Replace (@"\", @"\\")));
81+
sw.WriteLine (string.Format ("\"{0}\"", file.ItemSpec.ToJavaEscapedPath ()));
8282

8383
foreach (var file in Directory.GetFiles (StubSourceDirectory, "*.java", SearchOption.AllDirectories)) {
8484
// This makes sense. BAD sense. but sense.
@@ -95,7 +95,7 @@ private void GenerateResponseFile ()
9595
// Since '\' is an escape character, we need to escape it.
9696
// [0] http://download.oracle.com/javase/1.4.2/docs/api/java/io/StreamTokenizer.html#quoteChar(int)
9797
sw.WriteLine (string.Format ("\"{0}\"",
98-
file.Replace (@"\", @"\\").Normalize (NormalizationForm.FormC)));
98+
file.ToJavaEscapedPath ()));
9999
}
100100
}
101101
}

src/Xamarin.Android.Build.Tasks/Tasks/Javac.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ protected override string GenerateCommandLineCommands ()
6767

6868
protected override void WriteOptionsToResponseFile (StreamWriter sw)
6969
{
70-
WriteLineToStreamWriterAndLog (sw, $"-d {Files.GetShortPath(ClassesOutputDirectory).Replace(@"\", @"\\").Normalize(NormalizationForm.FormC)}");
71-
WriteLineToStreamWriterAndLog (sw, "-bootclasspath {0}", Files.GetShortPath(JavaPlatformJarPath).Replace(@"\", @"\\").Normalize(NormalizationForm.FormC));
72-
WriteLineToStreamWriterAndLog (sw, "-classpath \"{0}\"", Jars == null || !Jars.Any () ? null : string.Join (Path.PathSeparator.ToString (), Jars.Select (i => i.ItemSpec.Replace(@"\", @"\\").Normalize(NormalizationForm.FormC))));
70+
WriteLineToStreamWriterAndLog (sw, $"-d \"{Files.GetShortPath(ClassesOutputDirectory).ToJavaEscapedPath ()}\"");
71+
WriteLineToStreamWriterAndLog (sw, "-bootclasspath \"{0}\"", Files.GetShortPath(JavaPlatformJarPath).ToJavaEscapedPath ());
72+
WriteLineToStreamWriterAndLog (sw, "-classpath \"{0}\"", Jars == null || !Jars.Any () ? null : string.Join (Path.PathSeparator.ToString (), Jars.Select (i => i.ItemSpec.ToJavaEscapedPath ())));
7373
WriteLineToStreamWriterAndLog (sw, $"-encoding UTF8");
7474
}
7575

src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
namespace Xamarin.Android.Tasks
2121
{
22-
public class MonoAndroidHelper
22+
public static class MonoAndroidHelper
2323
{
2424
static Lazy<string> uname = new Lazy<string> (GetOSBinDirName, System.Threading.LazyThreadSafetyMode.PublicationOnly);
2525

@@ -600,5 +600,10 @@ public static Dictionary<string, string> LoadResourceCaseMap (string resourceCas
600600
}
601601
return result;
602602
}
603+
604+
public static string ToJavaEscapedPath (this string value)
605+
{
606+
return value.Replace (@"\", @"\\").Normalize (NormalizationForm.FormC);
607+
}
603608
}
604609
}

0 commit comments

Comments
 (0)