diff --git a/runtime/CSharp/Antlr4BuildTasks/Antlr4.v3.5.targets b/runtime/CSharp/Antlr4BuildTasks/Antlr4.v3.5.targets index cf9cddeebe..c9cf79eaee 100644 --- a/runtime/CSharp/Antlr4BuildTasks/Antlr4.v3.5.targets +++ b/runtime/CSharp/Antlr4BuildTasks/Antlr4.v3.5.targets @@ -138,6 +138,7 @@ ToolPath="$(Antlr4ToolLocation)" JavaVendor="$(Antlr4JavaVendor)" JavaInstallation="$(Antlr4JavaInstallation)" + JavaExecutable="$(Antlr4JavaExecutable)" BuildTaskPath="$(Antlr4BuildTaskLocation)" OutputPath="$(IntermediateOutputPath)" TargetLanguage="%(Antlr4.TargetLanguage)" diff --git a/runtime/CSharp/Antlr4BuildTasks/Antlr4.v4.0.targets b/runtime/CSharp/Antlr4BuildTasks/Antlr4.v4.0.targets index 01c36179ea..a96c1bd513 100644 --- a/runtime/CSharp/Antlr4BuildTasks/Antlr4.v4.0.targets +++ b/runtime/CSharp/Antlr4BuildTasks/Antlr4.v4.0.targets @@ -133,6 +133,7 @@ ToolPath="$(Antlr4ToolLocation)" JavaVendor="$(Antlr4JavaVendor)" JavaInstallation="$(Antlr4JavaInstallation)" + JavaExecutable="$(Antlr4JavaExecutable)" BuildTaskPath="$(Antlr4BuildTaskLocation)" OutputPath="$(IntermediateOutputPath)" TargetLanguage="%(Antlr4.TargetLanguage)" diff --git a/runtime/CSharp/Antlr4BuildTasks/Antlr4ClassGenerationTask.cs b/runtime/CSharp/Antlr4BuildTasks/Antlr4ClassGenerationTask.cs index 750d0b090c..fb4b46dfd9 100644 --- a/runtime/CSharp/Antlr4BuildTasks/Antlr4ClassGenerationTask.cs +++ b/runtime/CSharp/Antlr4BuildTasks/Antlr4ClassGenerationTask.cs @@ -163,6 +163,12 @@ public string JavaInstallation set; } + public string JavaExecutable + { + get; + set; + } + [Output] public ITaskItem[] GeneratedCodeFiles { @@ -332,6 +338,7 @@ private AntlrClassGenerationTaskInternal CreateBuildTaskWrapper(AppDomain domain wrapper.AbstractGrammar = AbstractGrammar; wrapper.JavaVendor = JavaVendor; wrapper.JavaInstallation = JavaInstallation; + wrapper.JavaExecutable = JavaExecutable; return wrapper; } diff --git a/runtime/CSharp/Antlr4BuildTasks/Antlr4ClassGenerationTaskInternal.cs b/runtime/CSharp/Antlr4BuildTasks/Antlr4ClassGenerationTaskInternal.cs index 091646b722..99eeca3f1d 100644 --- a/runtime/CSharp/Antlr4BuildTasks/Antlr4ClassGenerationTaskInternal.cs +++ b/runtime/CSharp/Antlr4BuildTasks/Antlr4ClassGenerationTaskInternal.cs @@ -130,6 +130,12 @@ public string JavaInstallation set; } + public string JavaExecutable + { + get; + set; + } + public IList SourceCodeFiles { get @@ -239,8 +245,16 @@ public bool Execute() { try { - string javaHome = JavaHome; - string java = Path.Combine(Path.Combine(javaHome, "bin"), "java.exe"); + string java; + if (!string.IsNullOrEmpty(JavaExecutable)) + { + java = JavaExecutable; + } + else + { + string javaHome = JavaHome; + java = Path.Combine(Path.Combine(javaHome, "bin"), "java.exe"); + } List arguments = new List(); arguments.Add("-cp");