forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaCompiler.cs
More file actions
29 lines (25 loc) · 947 Bytes
/
JavaCompiler.cs
File metadata and controls
29 lines (25 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.IO;
using Microsoft.Build.Utilities;
internal sealed class JavaCompiler
{
private readonly string _javaCompilerArgs;
private readonly string _workingDir;
private readonly TaskLoggingHelper _logger;
public JavaCompiler(
TaskLoggingHelper logger,
AndroidSdkHelper androidSdk,
string workingDir,
string javaVersion = "1.8")
{
_javaCompilerArgs = $"-classpath src -bootclasspath {androidSdk.AndroidJarPath} -source {javaVersion} -target {javaVersion}";
_workingDir = workingDir;
_logger = logger;
}
public void Compile(string javaSourceFile, string outputDir)
{
Utils.RunProcess(_logger, "javac", $"{_javaCompilerArgs} -d {outputDir} {javaSourceFile}", workingDir: _workingDir);
}
}