From 99882693c2b838e0ab9e2202ea5469d1550f964a Mon Sep 17 00:00:00 2001 From: BergWerkGIS Date: Thu, 8 Mar 2018 12:29:41 +0100 Subject: [PATCH] remove Android pre-build checks for duplicate libraries --- .../Build/Mapbox_Android_prebuild_checks.cs | 101 ------------------ .../Mapbox_Android_prebuild_checks.cs.meta | 12 --- .../Tests/DuplicateAndroidLibraries.cs.cs | 42 -------- .../DuplicateAndroidLibraries.cs.cs.meta | 12 --- 4 files changed, 167 deletions(-) delete mode 100644 sdkproject/Assets/Mapbox/Unity/Editor/Build/Mapbox_Android_prebuild_checks.cs delete mode 100644 sdkproject/Assets/Mapbox/Unity/Editor/Build/Mapbox_Android_prebuild_checks.cs.meta delete mode 100644 sdkproject/Assets/Mapbox/Unity/Editor/Tests/DuplicateAndroidLibraries.cs.cs delete mode 100644 sdkproject/Assets/Mapbox/Unity/Editor/Tests/DuplicateAndroidLibraries.cs.cs.meta diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/Build/Mapbox_Android_prebuild_checks.cs b/sdkproject/Assets/Mapbox/Unity/Editor/Build/Mapbox_Android_prebuild_checks.cs deleted file mode 100644 index e24650ed2..000000000 --- a/sdkproject/Assets/Mapbox/Unity/Editor/Build/Mapbox_Android_prebuild_checks.cs +++ /dev/null @@ -1,101 +0,0 @@ -namespace Mapbox.Editor.Build -{ - using System; - using System.IO; - using System.Linq; - using System.Collections.Generic; - using UnityEngine; - using UnityEditor; - using System.Text; - using UnityEditor.Build; -#if UNITY_2018_1_OR_NEWER - using UnityEditor.Build.Reporting; -#endif - - /// - /// Simple pre-build script to check for duplicate Android libraries - /// - public class PreBuildChecksEditor : IPreprocessBuild - { - public int callbackOrder { get { return 0; } } -#if UNITY_2018_1_OR_NEWER - public void OnPreprocessBuild(BuildReport report) - { - BuildTarget target = report.summary.platform; -#else - public void OnPreprocessBuild(BuildTarget target, string path) - { -#endif - if (BuildTarget.Android != target) - { - return; - } - - Debug.Log("Mapbox prebuild checks for target '" + target); - - List libInfo = new List(); - foreach (var file in Directory.GetFiles(Application.dataPath, "*.jar", SearchOption.AllDirectories)) - { - try - { - libInfo.Add(new AndroidLibInfo(file)); - } - catch - { - Debug.LogWarningFormat("could not extract version from file name: [{0}]", file); - } - } - foreach (var file in Directory.GetFiles(Application.dataPath, "*.aar", SearchOption.AllDirectories)) - { - try - { - libInfo.Add(new AndroidLibInfo(file)); - } - catch - { - Debug.LogWarningFormat("could not extract version from file name: [{0}]", file); - } - } - - var stats = libInfo.GroupBy(li => li.BaseFileName).OrderBy(g => g.Key); - - StringBuilder sb = new StringBuilder(); - foreach (var s in stats) - { - if (s.Count() > 1) - { - sb.AppendLine(string.Format( - "{0}:{1}{2}" - , s.Key - , Environment.NewLine - , string.Join(Environment.NewLine, s.Select(li => "\t" + li.AssetPath).ToArray()) - )); - } - } - if (sb.Length > 0) - { - Debug.LogErrorFormat("DUPLICATE ANDROID PLUGINS FOUND - BUILD WILL MOST LIKELY FAIL!!!{0}Resolve to continue.{0}{1}", Environment.NewLine, sb); - } - } - } - - public class AndroidLibInfo - { - public AndroidLibInfo(string fullPath) - { - FullPath = fullPath; - FullFileName = Path.GetFileName(fullPath); - // TODO: find a better way to extract base file name - // Mapbox telemetry lib uses different naming that other android libs - // -.. vs. --- - // okio-1.13.0, support-v4-25.1.0 vs. mapbox-android-telemetry-2-1-0 - BaseFileName = FullFileName.Substring(0, FullFileName.LastIndexOf("-")); - AssetPath = fullPath.Replace(Application.dataPath.Replace("Assets", ""), ""); - } - - public string FullPath { get; private set; } - public string FullFileName { get; private set; } - public string BaseFileName { get; private set; } - public string AssetPath { get; private set; } - } -} \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/Build/Mapbox_Android_prebuild_checks.cs.meta b/sdkproject/Assets/Mapbox/Unity/Editor/Build/Mapbox_Android_prebuild_checks.cs.meta deleted file mode 100644 index 8a31dc765..000000000 --- a/sdkproject/Assets/Mapbox/Unity/Editor/Build/Mapbox_Android_prebuild_checks.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: a28e608cf91114cb49d5761affb1ca3e -timeCreated: 1501520862 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/Tests/DuplicateAndroidLibraries.cs.cs b/sdkproject/Assets/Mapbox/Unity/Editor/Tests/DuplicateAndroidLibraries.cs.cs deleted file mode 100644 index 1630437af..000000000 --- a/sdkproject/Assets/Mapbox/Unity/Editor/Tests/DuplicateAndroidLibraries.cs.cs +++ /dev/null @@ -1,42 +0,0 @@ -namespace Mapbox.Editor.Tests -{ - using NUnit.Framework; - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using UnityEngine; - using Mapbox.Editor.Build; - - [TestFixture] - internal class AndroidLibraries - { - [Test] - public void Duplicates() - { - List libInfo = new List(); - foreach (var file in Directory.GetFiles(Application.dataPath, "*.jar", SearchOption.AllDirectories)) - { - libInfo.Add(new AndroidLibInfo(file)); - } - foreach (var file in Directory.GetFiles(Application.dataPath, "*.aar", SearchOption.AllDirectories)) - { - libInfo.Add(new AndroidLibInfo(file)); - } - - var stats = libInfo.GroupBy(li => li.BaseFileName).OrderBy(g => g.Key); - var max = stats.Select(s => s.Count()).Max(); - - string msg = string.Empty; - if (max > 1) - { - var x = stats - .Where(s => s.Count() > 1) - .SelectMany(a => a.Select(l => l.AssetPath)).ToArray(); - msg = "Duplicate Android libraries found: " + string.Join(Environment.NewLine, x); - } - - Assert.AreEqual(1, max, msg); - } - } -} \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Unity/Editor/Tests/DuplicateAndroidLibraries.cs.cs.meta b/sdkproject/Assets/Mapbox/Unity/Editor/Tests/DuplicateAndroidLibraries.cs.cs.meta deleted file mode 100644 index a873c2887..000000000 --- a/sdkproject/Assets/Mapbox/Unity/Editor/Tests/DuplicateAndroidLibraries.cs.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 9bc17f374e692459688710f0f2f654cf -timeCreated: 1501520862 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: