コード例 #1
0
        private string[] Find(string searchPattern)
        {
            List <string> result = new List <string>();

            foreach (string str in this)
            {
                AndroidFileLocator.Find(Path.Combine(str, searchPattern), result);
            }
            return(result.ToArray());
        }
コード例 #2
0
        public static string Run(string workingdir, string task, Progress progress = null)
        {
            string[] strArray = AndroidFileLocator.Find(Path.Combine(Path.Combine(Path.Combine(BuildPipeline.GetBuildToolsDirectory(BuildTarget.Android), "gradle"), "lib"), "gradle-launcher-*.jar"));
            if (strArray.Length != 1)
            {
                throw new Exception("Gradle install not valid");
            }
            string str3 = strArray[0];

            return(RunJava($"-classpath " { str3 } " org.gradle.launcher.GradleMain " { task } "", workingdir, progress));
        }
コード例 #3
0
        public int FindAndAddLibraryProjects(string searchPattern)
        {
            base.Clear();
            int num = 0;

            string[] strArray = new string[] { Path.Combine(searchPattern, ProjectPropertiesFileName), Path.Combine(searchPattern, "default.properties") };
            foreach (string str in strArray)
            {
                foreach (string str2 in AndroidFileLocator.Find(str))
                {
                    if (this.AddLibraryProject(str2))
                    {
                        num++;
                    }
                }
            }
            return(num);
        }
コード例 #4
0
        private static string GuessJDKLocation()
        {
            string environmentVariable = Environment.GetEnvironmentVariable("JAVA_HOME");

            if (IsValidJDKHome(environmentVariable))
            {
                return(environmentVariable);
            }
            string str3 = Environment.GetEnvironmentVariable("ProgramFiles");
            string str4 = Environment.GetEnvironmentVariable("ProgramFiles(x86)");

            string[] strArray = new string[] { "/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home/", "/System/Library/Frameworks/JavaVM.framework/Versions/Current/Home/", "/Library/Java/JavaVirtualMachines/*/Contents/Home/", "/System/Library/Java/JavaVirtualMachines/*/Contents/Home/", "/System/Library/Frameworks/JavaVM.framework/Versions/*/Home/", str3 + @"\Java*\jdk*\", str4 + @"\Java*\jdk*\", "/usr/lib/jvm/default-java", "/etc/alternatives/java_sdk", "/usr/lib/jvm/java", "/usr/lib/jvm/*/", "/opt/java*" };
            foreach (string str5 in strArray)
            {
                foreach (string str6 in AndroidFileLocator.Find(str5))
                {
                    if (IsValidJDKHome(str6))
                    {
                        return(str6);
                    }
                }
            }
            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                string[] strArray4 = new string[] { @"HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\1.7", @"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Development Kit\1.7", @"HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\1.8", @"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Development Kit\1.8" };
                foreach (string str7 in strArray4)
                {
                    environmentVariable = Registry.GetValue(str7, "JavaHome", "").ToString();
                    if (IsValidJDKHome(environmentVariable))
                    {
                        return(environmentVariable);
                    }
                }
            }
            return("");
        }
コード例 #5
0
        public override void ExportWithCurrentSettings()
        {
            string str;
            bool   flag = false;

            if (base.m_TargetPath == null)
            {
                str  = Path.Combine("Temp", "gradleOut");
                flag = true;
                Directory.CreateDirectory(str);
                string[] strArray = AndroidFileLocator.Find(Path.Combine(str, "*"));
                foreach (string str2 in strArray)
                {
                    string fileName = Path.GetFileName(str2);
                    if ((fileName != "build") && (fileName != ".gradle"))
                    {
                        try
                        {
                            FileUtil.DeleteFileOrDirectory(str2);
                        }
                        catch (IOException)
                        {
                        }
                    }
                }
            }
            else
            {
                str = Path.Combine(base.m_TargetPath, base.m_ProductName);
            }
            int targetSDKVersion = base.m_TargetSDKVersion;
            Dictionary <string, string> templateValues = new Dictionary <string, string> {
                {
                    "BUILDTOOLS",
                    base.m_GoogleBuildTools.ToString()
                },
                {
                    "APIVERSION",
                    targetSDKVersion.ToString()
                },
                {
                    "TARGETSDKVERSION",
                    targetSDKVersion.ToString()
                }
            };

            string[] components = new string[] { str, "src", "main" };
            string   str4       = Paths.Combine(components);
            string   target     = Path.Combine(str, "libs");

            Directory.CreateDirectory(str);
            string sDKRootDir = AndroidSDKTools.GetInstance().SDKRootDir;
            string path       = Path.Combine(str, "local.properties");

            if (!File.Exists(path) || flag)
            {
                File.WriteAllText(path, $"sdk.dir={sDKRootDir.Replace(@"\", @"\\")}
");
            }
            AndroidProjectExport.CopyFile(base.m_UnityJavaLibrary, Path.Combine(Path.Combine(str, "libs"), "unity-classes.jar"));
            AndroidProjectExport.CopyFile(Path.Combine(base.m_UnityAndroidBuildTools, "UnityProGuardTemplate.txt"), Path.Combine(str, "proguard-unity.txt"));
            try
            {
                string[] textArray2 = new string[] { str4, "assets", "bin", "Data" };
                Directory.Delete(Paths.Combine(textArray2), true);
            }
            catch (IOException)
            {
            }
            try
            {
                Directory.Delete(Path.Combine(str4, "res"), true);
            }
            catch (IOException)
            {
            }
            AndroidProjectExport.CopyDir(Path.Combine(base.m_StagingArea, "res"), Path.Combine(str4, "res"));
            AndroidProjectExport.CopyDir(Path.Combine(base.m_StagingArea, "plugins"), target);
            AndroidProjectExport.CopyDir(Path.Combine(base.m_StagingArea, "libs"), Path.Combine(str4, "jniLibs"));
            AndroidProjectExport.CopyDir(Path.Combine(base.m_StagingArea, "assets"), Path.Combine(str4, "assets"));
            string[] strArray3 = AndroidFileLocator.Find(Path.Combine(Path.Combine(base.m_StagingArea, "aar"), "*.aar"));
            string   str9      = "";

            foreach (string str10 in strArray3)
            {
                string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(str10);
                string str12 = Path.GetFileName(str10);
                str9 = str9 + $"	compile(name: '{fileNameWithoutExtension}', ext:'aar')
";
                AndroidProjectExport.CopyFile(str10, Path.Combine(target, str12));
            }
            templateValues["DEPS"] = str9;
            if (flag)
            {
                AndroidProjectExport.CopyFile(Path.Combine(base.m_StagingArea, "AndroidManifest.xml"), Path.Combine(str4, "AndroidManifest.xml"));
            }
            else
            {
                AndroidProjectExport.GenerateAndroidManifest(str4, base.m_StagingArea, base.m_PackageName, false);
                AndroidProjectExport.CopyAndPatchJavaSources(Path.Combine(str4, "java"), base.m_UnityJavaSources, base.m_PackageName);
            }
            string str13 = Path.Combine(str, "build.gradle");

            if (File.Exists(str13) && !File.ReadAllText(str13).StartsWith("// GENERATED BY UNITY"))
            {
                str13 = Path.Combine(str, "build.gradle.NEW");
            }
            this.WriteGradleBuildFiles(str, str13, templateValues);
            if (base.m_UseObb)
            {
                AndroidProjectExport.CopyFile(Path.Combine(base.m_StagingArea, "main.obb"), Path.Combine(str, $"{base.m_ProductName}.main.obb"));
            }
            else
            {
                AndroidProjectExport.CopyDir(Path.Combine(base.m_StagingArea, "raw"), Path.Combine(str4, "assets"));
            }
        }