using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.Helpers;
using Tango.Core.IO;
using Tango.Logging;
namespace Tango.Protobuf.Compilers
{
///
/// Represents a protobuf Java Compiler.
///
///
public class JavaCompiler : ProtoCompiler
{
///
/// Gets the compiler language.
///
public override CompilerLanguage Language => CompilerLanguage.Java;
///
/// Gets the protobuf compiler CLI arguments (without input/output files!).
///
///
protected override string GetProtoArguments()
{
return "--java_out";
}
///
/// Gets a value indicating whether this compiler uses the default folder structure when generating code.
///
public override bool UsesDefaultStructure => true;
public override CompilerFolderResult CompileFolder(string sourceFolder, params string[] includeFolders)
{
var temp = TemporaryManager.Default.CreateFolder();
PathHelper.CopyDirectory(sourceFolder, temp.Path, true);
List directories = Directory.GetDirectories(sourceFolder, "*", SearchOption.AllDirectories).Where(x => includeFolders == null || includeFolders.Length == 0 || includeFolders.Contains(Path.GetFileName(x))).ToList();
foreach (var dir in Directory.GetDirectories(temp.Path))
{
if (!directories.Select(x => Path.GetFileName(x)).Contains(Path.GetFileName(dir)))
{
Directory.Delete(dir, true);
}
}
return base.CompileFolder(temp.Path);
}
}
}