@@ -11,47 +11,41 @@ libraries included in the Unity project.
11
11
With this library, a plugin declares the dependencies needed and these are
12
12
resolved by using the play-services and support repositories that are part of
13
13
the Android SDK. These repositories are used to store .aar files in a Maven
14
- (Gradle) compatible repository.
14
+ (Gradle) compatible repository.
15
15
16
16
This library implements a subset of the resolution logic used by these build
17
17
tools so the same functionality is available in Unity.
18
18
19
19
# Requirements
20
20
21
- This library only works with Unity version 5.0 or better .
21
+ This library only works with Unity version 4.6.8 or higher .
22
22
23
23
The library relies on the installation of the Android Support Repository and
24
24
the Google Repository SDK components. These are found in the "extras" section.
25
25
26
26
# Packaging
27
27
28
- The library is packaged as a DLL which implements a Unity editor extension.
29
- The library contains no runtime components.
28
+ The plugin consists of a C# DLL that contains the logic to resolve the dependencies
29
+ and the logic to resolve dependencies and copy them into Unity projects.
30
+ This includes removing older versions of the client libraries.
30
31
31
- There is sample code demonstrating how to declare dependencies and trigger
32
- resolution both from the menu, and as a background process when assets change.
32
+ There also are 2 C# files. The first, PlayServicesResolver.cs,
33
+ creates an AssetPostprocessor instance that is used to trigger background
34
+ resolution of the dependencies. It also adds a menu item
35
+ (Assets/Google Play Services/Resolve Client Jars). In order to support
36
+ Unity version 4.x, this class also converts the aar file
37
+ to a java plugin project. The second C# file is SampleDependencies.cs
38
+ which is the model for plugin developers to copy and add the specific
39
+ dependencies needed.
33
40
34
- # Usage
35
-
36
- 1 . Copy the file [ JarResolverLib.dll] ( Assets/Editor/JarResolver.dll ) to the Assets/Editor folder in your Unity
37
- project.
38
-
39
- The dependency information is stored statically, so all plugins register their
40
- dependency in a common location. In the worse case, this results in multiple calls to
41
- resolve the dependencies, but they all get the same resolution outcome.
41
+ During resolution, all the dependencies from all the plugins are merged and resolved.
42
42
43
- 2 . Create an instance of PlayServicesSupport. Pass in a name for the
44
- client (needs to use valid filename characters), the path to the Android SDK,
45
- and the path to the settings directory. For Unity, this is "ProjectSettings".
46
-
47
- ```
48
- PlayServicesSupport instance = PlayServicesSupport.CreateInstance("myPlugin",
49
- EditorPrefs.GetString("AndroidSdkRoot"),
50
- "ProjectSettings");
51
- ```
43
+ # Usage
44
+ 1 . Add the unitypackage to your plugin project (assuming you are developing a
45
+ plugin).
52
46
53
- 3 . Specify the dependencies for your plugin. In your editor script, add a line
54
- for each direct dependency:
47
+ 2 . Copy the SampleDependencies.cs file to another name specific to your plugin
48
+ and add the dependencies your plugin needs.
55
49
56
50
```
57
51
instance.DependOn(group, artifact, version);
@@ -71,69 +65,16 @@ the portion of the number preceding the period. For example 8.1.+ would match
71
65
equal to 8.0. The meta version 'LATEST' is also supported meaning the greatest
72
66
version available, and "0+" indicates any version.
73
67
68
+ # How it works
69
+
74
70
When the dependency is added, the maven-metadata.xml file is read for this
75
71
dependency. If there are no versions available (or the dependency is not
76
72
found), there is an exception thrown. When the metadata is read, the list of
77
73
known versions is filtered based on the version constraint. The remaining list
78
- of version is known as <em >possible versions</em >.
79
-
80
- The greatest value of the possible versions is known as the <em >best version</em >. The best version is what is used to perform resolution.
81
-
82
- 2 . Call Resolve. In your editor script call:
83
-
84
- ```
85
- PlayServicesSupport.ResolveDependencies(useLatest);
86
- ```
87
-
88
- Performs resolution of the dependencies. The parameter useLatest, if true,
89
- causes the latest version of any dependency to be used in the case of a
90
- conflict. If this flag is false, the resolution will fail by throwing an
91
- exception indicating the dependencies cannot be resolved.
92
-
93
- The return value is a dictionary of dependencies needed. The key is the
94
- "versionless" key of the dependency, and the value is the Dependency object.
95
-
96
- 3 . Copy/Update the dependencies in your project. Once ResolveDependencies
97
- returns, you need to copy and update the dependencies in your project. To do
98
- this, call
99
-
100
- ```
101
- PlayServicesSupport.CopyDependencies(
102
-
103
- deps, "Assets/Plugins/Android", confirm);
104
- ```
105
-
106
- Where:
74
+ of version is known as <em >possible versions</em >.
107
75
108
- * <strong >deps</strong > is the dictionary returned from ResolveDependencies
109
- * <strong >"Assets/Plugins/Android" </strong >is the project relative path of where to copy the client libraries.
110
- * <strong >confirm</strong > is a delegate of type PlayServicesSupport.OverwriteConfirmation which is
111
- called when an a dependency already exists in the project. The delegate should
112
- return true to have the old dependency be overwritten by the new.
113
-
114
- The signature of PlayServicesSupport.OverwriteConfirmation is
115
-
116
- ```
117
- bool OverwriteConfirmation (Dependency oldDep, Dependency newDep)
118
- ```
119
-
120
- # Calling resolution from the menu
121
-
122
- If you want to make the resolution process manually started from the menu, you
123
- can use this class as a starter. It declares the dependencies statically (so
124
- other library clients will resolve them as well), and adds a menu item to
125
- perform resolution and copy the results. See
126
- [ ManualResolution] ( Assets/Editor/ManualResolution.cs )
127
-
128
- # Calling resolution in the background
129
-
130
- If you want to make the resolution process automatically started when there is
131
- a change to the assets, you can kick off the process by implementing an
132
- AssetPostprocessor. See
133
-
134
- [ BackgroundResolution] ( Assets/Editor/BackgroundResolution.cs )
135
-
136
- # How Resolution works
76
+ The greatest value of the possible versions is known as the <em >best version</em >.
77
+ The best version is what is used to perform resolution.
137
78
138
79
Resolution is done by following the steps:
139
80
@@ -154,18 +95,11 @@ of the unresolved list for re-processing with a new version candidate.
154
95
unresolved dependencies, then either fail resolution with an exception, or use
155
96
the greatest version value (depending on the useLatest flag passed to resolve).
156
97
3. When a candidate version is selected, the pom file is read for that version and
157
- the
98
+ the
158
99
159
100
4. If there is a candidate version, add it to the candidate list and remove from
160
101
the unresolved.
161
102
3 . Process transitive dependencies
162
103
5 . for each candidate artifact, read the pom file for dependencies and add them to
163
104
the unresolved list.
164
105
165
- # Code location and building instructions
166
-
167
- There are 3 assemblies that are part of the solution.
168
-
169
- 1 . The Unity Editor UI components
170
- 2 . The Jar resolver library
171
- 3 . The unit tests.
0 commit comments