Skip to content

Commit 5a00e69

Browse files
author
Stewart Miles
committed
Support for project level settings.
Allows storage of project level settings for all components of the Play Services Resolver plugin. * Moved common logging logic into a common module. * Moved xml utilities module into VersionHandlerImpl so that it can be shared by other components. * Added ProjectSettings class which stores settings with a project and allows a user to switch between project vs. application level settings. By default all settings are now per-project rather than application wide. Application settings are applied where project settings are currently not available to enable the transition of user's existing application level settings to project level settings. Bug: 36280202 Change-Id: I5340068a1da5b642cb9288fc566970a2bd5d6bd7
1 parent 63c966c commit 5a00e69

25 files changed

+642
-164
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# Version 1.2.48 - Sep 12, 2017
2+
## New Features
3+
* Changed settings to be per-project by default.
4+
5+
## Bug Fixes
6+
* Added Google maven repository to fix GradlePrebuild resolution with Google
7+
components.
8+
* Fixed Android Resolution failure with spaces in paths.
9+
110
# Version 1.2.47 - Aug 29, 2017
211
## New Features
312
* Android and iOS dependencies can now be specified using *Dependencies.xml

exploded/Assets/PlayServicesResolver/Editor.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

exploded/Assets/PlayServicesResolver/Editor/Google.IOSResolver_v1.2.48.0.dll.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

exploded/Assets/PlayServicesResolver/Editor/Google.JarResolver_v1.2.48.0.dll.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

exploded/Assets/PlayServicesResolver/Editor/Google.VersionHandler.dll.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exploded/Assets/PlayServicesResolver/Editor/Google.VersionHandlerImpl_v1.2.48.0.dll.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exploded/Assets/PlayServicesResolver/Editor/play-services-resolver_v1.2.48.0.txt.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
-60 Bytes
Binary file not shown.

source/IOSResolver/src/IOSResolver.cs

Lines changed: 39 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public IOSXmlDependencies() {
194194
/// Read XML declared dependencies.
195195
/// </summary>
196196
/// <param name="filename">File to read.</param>
197-
/// <param name="logger">Logging delegate.</param>
197+
/// <param name="logger">Logger to log with.</param>
198198
///
199199
/// Parses dependencies in the form:
200200
///
@@ -210,8 +210,7 @@ public IOSXmlDependencies() {
210210
/// </iosPod>
211211
/// </iosPods>
212212
/// </dependencies>
213-
protected override bool Read(string filename,
214-
PlayServicesSupport.LogMessageWithLevel logger) {
213+
protected override bool Read(string filename, Logger logger) {
215214
IOSResolver.Log(String.Format("Reading iOS dependency XML file {0}", filename),
216215
verbose: true);
217216
var sources = new List<string>();
@@ -242,10 +241,10 @@ protected override bool Read(string filename,
242241
minTargetSdk = reader.GetAttribute("minTargetSdk");
243242
sources = new List<string>();
244243
if (podName == null) {
245-
logger(
244+
logger.Log(
246245
String.Format("Pod name not specified while reading {0}:{1}\n",
247246
filename, reader.LineNumber),
248-
level: PlayServicesSupport.LogLevel.Warning);
247+
level: LogLevel.Warning);
249248
return false;
250249
}
251250
} else {
@@ -415,6 +414,9 @@ protected override bool Read(string filename,
415414
// Parses dependencies from XML dependency files.
416415
private static IOSXmlDependencies xmlDependencies = new IOSXmlDependencies();
417416

417+
// Project level settings for this module.
418+
private static ProjectSettings settings = new ProjectSettings(PREFERENCE_NAMESPACE);
419+
418420
// Search for a file up to a maximum search depth stopping the
419421
// depth first search each time the specified file is found.
420422
private static List<string> FindFile(
@@ -545,7 +547,7 @@ exception is TypeInitializationException ||
545547
// Prompt the user to use workspaces if they aren't at least using project level
546548
// integration.
547549
if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.iOS &&
548-
(CocoapodsIntegrationMethod)EditorPrefs.GetInt(PREFERENCE_COCOAPODS_INTEGRATION_METHOD,
550+
(CocoapodsIntegrationMethod)settings.GetInt(PREFERENCE_COCOAPODS_INTEGRATION_METHOD,
549551
CocoapodsIntegrationUpgradeDefault) == CocoapodsIntegrationMethod.None &&
550552
!InBatchMode && !UpgradeToWorkspaceWarningDisabled) {
551553

@@ -557,8 +559,8 @@ exception is TypeInitializationException ||
557559
"to integrating Cocoapods with the .xcodeproj file.\n",
558560
"Yes", "Not Now", "Silence Warning")) {
559561
case 0: // Yes
560-
EditorPrefs.SetInt(PREFERENCE_COCOAPODS_INTEGRATION_METHOD,
561-
(int)CocoapodsIntegrationMethod.Workspace);
562+
settings.SetInt(PREFERENCE_COCOAPODS_INTEGRATION_METHOD,
563+
(int)CocoapodsIntegrationMethod.Workspace);
562564
break;
563565
case 1: // Not now
564566
break;
@@ -602,7 +604,7 @@ public static void RemapXcodeExtension() {
602604
/// Reset settings of this plugin to default values.
603605
/// </summary>
604606
internal static void RestoreDefaultSettings() {
605-
VersionHandlerImpl.RestoreDefaultSettings(PREFERENCE_KEYS);
607+
settings.DeleteKeys(PREFERENCE_KEYS);
606608
}
607609

608610
/// <summary>
@@ -630,11 +632,11 @@ private static int CocoapodsIntegrationUpgradeDefault {
630632
/// </summary>
631633
public static CocoapodsIntegrationMethod CocoapodsIntegrationMethodPref {
632634
get {
633-
return (CocoapodsIntegrationMethod)EditorPrefs.GetInt(
635+
return (CocoapodsIntegrationMethod)settings.GetInt(
634636
PREFERENCE_COCOAPODS_INTEGRATION_METHOD,
635637
defaultValue: CocoapodsIntegrationUpgradeDefault);
636638
}
637-
set { EditorPrefs.SetInt(PREFERENCE_COCOAPODS_INTEGRATION_METHOD, (int)value); }
639+
set { settings.SetInt(PREFERENCE_COCOAPODS_INTEGRATION_METHOD, (int)value); }
638640
}
639641

640642
/// <summary>
@@ -654,57 +656,62 @@ public static bool CocoapodsInstallEnabled {
654656
/// CocoapodsIntegrationEnabled.
655657
/// </summary>
656658
private static bool LegacyCocoapodsInstallEnabled {
657-
get { return EditorPrefs.GetBool(PREFERENCE_COCOAPODS_INSTALL_ENABLED,
659+
get { return settings.GetBool(PREFERENCE_COCOAPODS_INSTALL_ENABLED,
658660
defaultValue: true); }
659-
set { EditorPrefs.SetBool(PREFERENCE_COCOAPODS_INSTALL_ENABLED, value); }
661+
set { settings.SetBool(PREFERENCE_COCOAPODS_INSTALL_ENABLED, value); }
660662
}
661663

662664
/// <summary>
663665
/// Enable / disable Podfile generation.
664666
/// </summary>
665667
public static bool PodfileGenerationEnabled {
666-
get { return EditorPrefs.GetBool(PREFERENCE_PODFILE_GENERATION_ENABLED,
668+
get { return settings.GetBool(PREFERENCE_PODFILE_GENERATION_ENABLED,
667669
defaultValue: true); }
668-
set { EditorPrefs.SetBool(PREFERENCE_PODFILE_GENERATION_ENABLED, value); }
670+
set { settings.SetBool(PREFERENCE_PODFILE_GENERATION_ENABLED, value); }
669671
}
670672

671673
/// <summary>
672674
/// Enable / disable execution of the pod tool via the shell.
673675
/// </summary>
674676
public static bool PodToolExecutionViaShellEnabled {
675-
get { return EditorPrefs.GetBool(PREFERENCE_POD_TOOL_EXECUTION_VIA_SHELL_ENABLED,
676-
defaultValue: false); }
677-
set { EditorPrefs.SetBool(PREFERENCE_POD_TOOL_EXECUTION_VIA_SHELL_ENABLED, value); }
677+
get { return settings.GetBool(PREFERENCE_POD_TOOL_EXECUTION_VIA_SHELL_ENABLED,
678+
defaultValue: false); }
679+
set { settings.SetBool(PREFERENCE_POD_TOOL_EXECUTION_VIA_SHELL_ENABLED, value); }
678680
}
679681

680682
/// <summary>
681683
/// Enable automated pod tool installation in the editor. This is only performed when the
682684
/// editor isn't launched in batch mode.
683685
/// </summary>
684686
public static bool AutoPodToolInstallInEditorEnabled {
685-
get { return EditorPrefs.GetBool(PREFERENCE_AUTO_POD_TOOL_INSTALL_IN_EDITOR,
686-
defaultValue: true); }
687-
set { EditorPrefs.SetBool(PREFERENCE_AUTO_POD_TOOL_INSTALL_IN_EDITOR, value); }
687+
get { return settings.GetBool(PREFERENCE_AUTO_POD_TOOL_INSTALL_IN_EDITOR,
688+
defaultValue: true); }
689+
set { settings.SetBool(PREFERENCE_AUTO_POD_TOOL_INSTALL_IN_EDITOR, value); }
688690
}
689691

690692
/// <summary>
691693
/// Get / set the nag prompt disabler setting for turning on workspace integration.
692694
/// </summary>
693695
public static bool UpgradeToWorkspaceWarningDisabled {
694-
get { return EditorPrefs.GetBool(PREFERENCE_WARN_UPGRADE_WORKSPACE,
695-
defaultValue: false); }
696-
set { EditorPrefs.SetBool(PREFERENCE_WARN_UPGRADE_WORKSPACE, value); }
696+
get { return settings.GetBool(PREFERENCE_WARN_UPGRADE_WORKSPACE, defaultValue: false); }
697+
set { settings.SetBool(PREFERENCE_WARN_UPGRADE_WORKSPACE, value); }
697698
}
698699

699700
/// <summary>
700701
/// Enable / disable verbose logging.
701702
/// </summary>
702703
public static bool VerboseLoggingEnabled {
703-
get { return EditorPrefs.GetBool(PREFERENCE_VERBOSE_LOGGING_ENABLED,
704-
defaultValue: false); }
705-
set { EditorPrefs.SetBool(PREFERENCE_VERBOSE_LOGGING_ENABLED, value); }
704+
get { return settings.GetBool(PREFERENCE_VERBOSE_LOGGING_ENABLED, defaultValue: false); }
705+
set { settings.SetBool(PREFERENCE_VERBOSE_LOGGING_ENABLED, value); }
706706
}
707707

708+
/// <summary>
709+
/// Whether to use project level settings.
710+
/// </summary>
711+
public static bool UseProjectSettings {
712+
get { return settings.UseProjectSettings; }
713+
set { settings.UseProjectSettings = value; }
714+
}
708715

709716
/// <summary>
710717
/// Determine whether it's possible to perform iOS dependency injection.
@@ -779,18 +786,11 @@ public static bool CocoapodsIntegrationEnabled {
779786
}
780787
}
781788

782-
/// <summary>
783-
/// Log severity.
784-
/// </summary>
785-
internal enum LogLevel {
786-
Info,
787-
Warning,
788-
Error,
789-
};
790-
791789
private delegate void LogMessageDelegate(string message, bool verbose = false,
792790
LogLevel level = LogLevel.Info);
793791

792+
private static Google.Logger logger = new Google.Logger();
793+
794794
/// <summary>
795795
/// Log a message.
796796
/// </summary>
@@ -800,19 +800,8 @@ private delegate void LogMessageDelegate(string message, bool verbose = false,
800800
/// <param name="level">Severity of the message.</param>
801801
internal static void Log(string message, bool verbose = false,
802802
LogLevel level = LogLevel.Info) {
803-
if (!verbose || VerboseLoggingEnabled || InBatchMode) {
804-
switch (level) {
805-
case LogLevel.Info:
806-
Debug.Log(message);
807-
break;
808-
case LogLevel.Warning:
809-
Debug.LogWarning(message);
810-
break;
811-
case LogLevel.Error:
812-
Debug.LogError(message);
813-
break;
814-
}
815-
}
803+
logger.Level = (VerboseLoggingEnabled || InBatchMode) ? LogLevel.Verbose : LogLevel.Info;
804+
logger.Log(message, level: verbose ? LogLevel.Verbose : level);
816805
}
817806

818807
/// <summary>
@@ -2432,7 +2421,7 @@ private static void RefreshXmlDependencies() {
24322421
pods.Remove(podName);
24332422
}
24342423
// Read pod specifications from XML dependencies.
2435-
xmlDependencies.ReadAll(IOSXmlDependencies.LogMessage);
2424+
xmlDependencies.ReadAll(logger);
24362425
}
24372426

24382427
/// <summary>

source/IOSResolver/src/IOSResolverSettingsDialog.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ private class Settings {
3535
internal bool autoPodToolInstallInEditorEnabled;
3636
internal bool verboseLoggingEnabled;
3737
internal int cocoapodsIntegrationMenuIndex;
38+
internal bool useProjectSettings;
3839

3940
/// <summary>
4041
/// Load settings into the dialog.
@@ -47,6 +48,7 @@ internal Settings() {
4748
verboseLoggingEnabled = IOSResolver.VerboseLoggingEnabled;
4849
cocoapodsIntegrationMenuIndex = FindIndexFromCocoapodsIntegrationMethod(
4950
IOSResolver.CocoapodsIntegrationMethodPref);
51+
useProjectSettings = IOSResolver.UseProjectSettings;
5052
}
5153

5254
/// <summary>
@@ -60,6 +62,7 @@ internal void Save() {
6062
IOSResolver.VerboseLoggingEnabled = verboseLoggingEnabled;
6163
IOSResolver.CocoapodsIntegrationMethodPref =
6264
integrationMapping[cocoapodsIntegrationMenuIndex];
65+
IOSResolver.UseProjectSettings = useProjectSettings;
6366
}
6467
}
6568

@@ -170,6 +173,11 @@ public void OnGUI() {
170173
settings.verboseLoggingEnabled = EditorGUILayout.Toggle(settings.verboseLoggingEnabled);
171174
GUILayout.EndHorizontal();
172175

176+
GUILayout.BeginHorizontal();
177+
GUILayout.Label("Use project settings", EditorStyles.boldLabel);
178+
settings.useProjectSettings = EditorGUILayout.Toggle(settings.useProjectSettings);
179+
GUILayout.EndHorizontal();
180+
173181
GUILayout.Space(10);
174182

175183
if (GUILayout.Button("Reset to Defaults")) {

source/PlayServicesResolver/PlayServicesResolver.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
<Compile Include="src\TextAreaDialog.cs" />
6868
<Compile Include="src\UnityCompat.cs" />
6969
<Compile Include="src\XmlDependencies.cs" />
70-
<Compile Include="src\XmlUtilities.cs" />
7170
<Compile Include="..\JarResolverLib\src\Google.JarResolver\Dependency.cs">
7271
<Link>Google.JarResolver\Dependency.cs</Link>
7372
</Compile>

source/PlayServicesResolver/src/AndroidXmlDependencies.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ namespace GooglePlayServices {
1919
using System;
2020
using System.Collections.Generic;
2121
using System.Xml;
22+
using Google;
2223
using Google.JarResolver;
2324
using UnityEditor;
2425

@@ -35,8 +36,8 @@ public AndroidXmlDependencies() {
3536
/// <summary>
3637
/// Read XML declared dependencies.
3738
/// </summary>
38-
/// <param name="svcSupport">Instance to add dependencies to.</param>
3939
/// <param name="filename">File to read.</param>
40+
/// <param name="logger">Logger instance to log with.</param>
4041
///
4142
/// Parses dependencies in the form:
4243
///
@@ -52,16 +53,15 @@ public AndroidXmlDependencies() {
5253
/// </androidPackage>
5354
/// </androidPackages>
5455
/// </dependencies>
55-
protected override bool Read(string filename,
56-
PlayServicesSupport.LogMessageWithLevel logger) {
56+
protected override bool Read(string filename, Logger logger) {
5757
List<string> androidSdkPackageIds = null;
5858
string group = null;
5959
string artifact = null;
6060
string versionSpec = null;
6161
List<string> repositories = null;
62-
PlayServicesSupport.Log(
62+
logger.Log(
6363
String.Format("Reading Android dependency XML file {0}", filename),
64-
verbose: true);
64+
level: LogLevel.Verbose);
6565

6666
if (!XmlUtilities.ParseXmlTextFileElements(
6767
filename, logger,
@@ -85,12 +85,12 @@ protected override bool Read(string filename,
8585
var spec = reader.GetAttribute("spec") ?? "";
8686
var specComponents = spec.Split(new [] { ':' });
8787
if (specComponents.Length != 3) {
88-
logger(
88+
logger.Log(
8989
String.Format(
9090
"Ignoring invalid package specification '{0}' " +
9191
"while reading {1}:{2}\n",
9292
spec, filename, reader.LineNumber),
93-
level: PlayServicesSupport.LogLevel.Warning);
93+
level: LogLevel.Warning);
9494
return false;
9595
}
9696
group = specComponents[0];
@@ -136,7 +136,8 @@ protected override bool Read(string filename,
136136
/// <summary>
137137
/// Find and read all XML declared dependencies.
138138
/// </summary>
139-
public override bool ReadAll(PlayServicesSupport.LogMessageWithLevel logger) {
139+
/// <param name="logger">Logger to log with.</param>
140+
public override bool ReadAll(Logger logger) {
140141
const string XML_DEPENDENCIES_INSTANCE = "InternalXmlDependencies";
141142
if (PlayServicesSupport.instances.TryGetValue(XML_DEPENDENCIES_INSTANCE,
142143
out svcSupport)) {

0 commit comments

Comments
 (0)