Exemplo n.º 1
0
        private void BuildJavaFiles()
        {
            var javaPath = $"{CurrentDirectory}/../native_library/android/dummyane/src/main/java";

            foreach (var subDir in new DirectoryInfo(javaPath).GetDirectories())
            {
                subDir.Delete(true);
            }

            foreach (var s in GroupId.Split("."))
            {
                javaPath = javaPath + "/" + s;
                if (!Directory.Exists(javaPath))
                {
                    Directory.CreateDirectory(javaPath);
                }
            }

            var artifactIdSafe = ArtifactId.Replace("-", "_");

            File.WriteAllText($"{javaPath}/DummyANE.java",
                              $"package {GroupId}.{artifactIdSafe};public class DummyANE {{}}");

            var startInfo = new ProcessStartInfo(Shell)
            {
                CreateNoWindow   = false,
                UseShellExecute  = false,
                WorkingDirectory = $"{CurrentDirectory}/../native_library/android",
                WindowStyle      = ProcessWindowStyle.Hidden,
                Arguments        = $"{Gradlew} clean"
            };

            try {
                using var exeProcess = Process.Start(startInfo);
                exeProcess?.WaitForExit();
            }
            catch (Exception e) {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.Message);
                return;
            }

            startInfo.Arguments = $"{Gradlew} build";
            try {
                using var exeProcess = Process.Start(startInfo);
                exeProcess?.WaitForExit();
            }
            catch (Exception e) {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.Message);
                return;
            }

            Console.ResetColor();
        }