Skip to content

Commit a544b31

Browse files
author
Stewart Miles
committed
Removed legacy Android Resolution method.
The legacy Android resolution method (logic in JarResolverLib) is removed by this commit. The Android Resolver now entirely relies upon Gradle to resolve Android dependencies. Change-Id: I4cffe295dc81cccdb895f9c0f87b0a1ea50de15d
1 parent 9553fea commit a544b31

File tree

10 files changed

+34
-1664
lines changed

10 files changed

+34
-1664
lines changed

README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,8 @@ By default the Android Resolver will use Gradle to download dependencies prior
219219
to integrating them into a Unity project. This works with Unity's internal
220220
build system and Gradle / Android Studio project export.
221221

222-
In addition, the Android Resolver supports a legacy mode that only fetches
223-
dependencies from a user's local Android SDK. This mode has limited support
224-
for conflict resolution and doesn't support online maven repositories,
225-
therefore may be removed in the future.
226-
227-
Finally, the Android Resolver supports a Gradle prebuild mode to provide
228-
minification without exporting to a Gradle / Android Studio project.
222+
Also, the Android Resolver supports an *experimental* Gradle prebuild mode to
223+
provide minification without exporting to a Gradle / Android Studio project.
229224
For more information about this mode see
230225
[gradle_prebuild.md](gralde_prebuild.md).
231226

source/JarResolverLib/src/Google.JarResolver/PlayServicesSupport.cs

Lines changed: 0 additions & 1064 deletions
Large diffs are not rendered by default.

source/JarResolverTests/src/Google.JarResolver.Tests/PlayServicesSupportTests.cs

Lines changed: 0 additions & 352 deletions
Original file line numberDiff line numberDiff line change
@@ -126,358 +126,6 @@ internal static void DependOn(this PlayServicesSupport instance, PackageId artif
126126
[TestFixture]
127127
public class PlayServicesSupportTests
128128
{
129-
/// <summary>
130-
/// Clear all PlayServicesSupport instances.
131-
/// </summary>
132-
[SetUp]
133-
public void SetUp()
134-
{
135-
PlayServicesSupport.ResetDependencies();
136-
}
137-
138-
/// <summary>
139-
/// Simple, "happy path" tests.
140-
/// </summary>
141-
[Test]
142-
public void TestSimpleResolveDependencies()
143-
{
144-
PlayServicesSupport support = TestData.CreateInstance();
145-
146-
Assert.True(Directory.Exists(support.SDK));
147-
148-
support.DependOn(TestData.PackageId.Artifact, "LATEST");
149-
150-
Dictionary<string, Dependency> deps = support.ResolveDependencies(false);
151-
Assert.NotNull(deps);
152-
153-
// Verify one single dependency is returned at the expected version.
154-
Assert.AreEqual(1, deps.Count);
155-
IEnumerator<Dependency> iter = deps.Values.GetEnumerator();
156-
iter.MoveNext();
157-
Assert.AreEqual(TestData.PackageId.Artifact.Info().bestVersion,
158-
iter.Current.BestVersion);
159-
}
160-
161-
/// <summary>
162-
/// Tests adding another repo path. This is simulated by giving
163-
/// the incorrect SDK path, and adding the correct repo path as
164-
/// an additional one.
165-
/// </summary>
166-
[Test]
167-
public void TestCustomRepoPath()
168-
{
169-
string[] repos = {Path.Combine(TestData.PATH, "extras/google/m2repository")};
170-
PlayServicesSupport support = TestData.CreateInstance(
171-
sdkPath: "..", additionalRepositories: repos);
172-
173-
Assert.True(Directory.Exists(support.SDK));
174-
175-
support.ClearDependencies();
176-
support.DependOn(TestData.PackageId.Artifact, "LATEST");
177-
178-
Dictionary<string, Dependency> deps = support.ResolveDependencies(false);
179-
Assert.NotNull(deps);
180-
181-
// Verify one dependency is returned at the expected version.
182-
Assert.AreEqual(1, deps.Count);
183-
IEnumerator<Dependency> iter = deps.Values.GetEnumerator();
184-
iter.MoveNext();
185-
Assert.AreEqual(TestData.PackageId.Artifact.Info().bestVersion,
186-
iter.Current.BestVersion);
187-
}
188-
189-
/// <summary>
190-
/// Tests resolving transitive dependencies.
191-
/// </summary>
192-
[Test]
193-
public void TestResolveDependencies()
194-
{
195-
PlayServicesSupport support = TestData.CreateInstance();
196-
197-
Assert.True(Directory.Exists(support.SDK));
198-
199-
support.DependOn(TestData.PackageId.Artifact, "LATEST");
200-
201-
Dictionary<string, Dependency> deps =
202-
support.ResolveDependencies(false);
203-
Assert.NotNull(deps);
204-
205-
// Verify one dependency is returned at the expected version.
206-
Assert.AreEqual(1, deps.Count);
207-
IEnumerator<Dependency> iter = deps.Values.GetEnumerator();
208-
iter.MoveNext();
209-
Assert.AreEqual(TestData.PackageId.Artifact.Info().bestVersion,
210-
iter.Current.BestVersion);
211-
212-
// Check dependency with has transitive dependencies.
213-
support.DependOn(TestData.PackageId.TransDep, "1.0");
214-
215-
deps = support.ResolveDependencies(false);
216-
Assert.NotNull(deps);
217-
218-
// One dependency should be present from the previous test and an additional two
219-
// for the transdep and subdep.
220-
Assert.AreEqual(3, deps.Count);
221-
Dependency d = deps[TestData.PackageId.Artifact.VersionlessKey()];
222-
Assert.AreEqual(TestData.PackageId.Artifact.Info().bestVersion, d.BestVersion);
223-
d = deps[TestData.PackageId.TransDep.VersionlessKey()];
224-
Assert.AreEqual(TestData.PackageId.TransDep.Info().bestVersion, d.BestVersion);
225-
d = deps[TestData.PackageId.SubDep.VersionlessKey()];
226-
Assert.AreEqual(TestData.PackageId.SubDep.Info().bestVersion, d.BestVersion);
227-
228-
// check constraining down to a later version - the LATEST
229-
// will make this fail.
230-
support.DependOn(TestData.PackageId.Artifact, "7.0.0");
231-
232-
ResolutionException ex = null;
233-
try
234-
{
235-
deps = support.ResolveDependencies(false);
236-
}
237-
catch (ResolutionException e)
238-
{
239-
ex = e;
240-
}
241-
242-
Assert.NotNull(ex);
243-
244-
// Now add it as 7+ and LATEST and it will work.
245-
support.ClearDependencies();
246-
247-
support.DependOn(TestData.PackageId.Artifact, "LATEST");
248-
support.DependOn(TestData.PackageId.Artifact, "7+");
249-
deps = support.ResolveDependencies(false);
250-
Assert.NotNull(deps);
251-
d = deps[TestData.PackageId.Artifact.VersionlessKey()];
252-
Assert.AreEqual(TestData.PackageId.Artifact.Info().bestVersion, d.BestVersion);
253-
254-
// Test downversioning.
255-
support.ClearDependencies();
256-
257-
support.DependOn(TestData.PackageId.Artifact, "1+");
258-
support.DependOn(TestData.PackageId.Artifact, "2+");
259-
support.DependOn(TestData.PackageId.Artifact, "7.0.0");
260-
261-
deps = support.ResolveDependencies(false);
262-
Assert.NotNull(deps);
263-
d = deps[TestData.PackageId.Artifact.VersionlessKey()];
264-
Assert.AreEqual("7.0.0", d.BestVersion);
265-
266-
// test the transitive dep influencing a top level
267-
support.ClearDependencies();
268-
269-
support.DependOn(TestData.PackageId.Artifact, "1+");
270-
support.DependOn(TestData.PackageId.SubDep, "0+");
271-
support.DependOn(TestData.PackageId.TransDep, "LATEST");
272-
273-
deps = support.ResolveDependencies(false);
274-
Assert.NotNull(deps);
275-
d = deps[TestData.PackageId.Artifact.VersionlessKey()];
276-
Assert.AreEqual(TestData.PackageId.Artifact.Info().bestVersion, d.BestVersion);
277-
d = deps[TestData.PackageId.SubDep.VersionlessKey()];
278-
Assert.AreEqual(TestData.PackageId.SubDep.Info().bestVersion, d.BestVersion);
279-
}
280-
281-
/// <summary>
282-
/// Tests the use latest version contraint.
283-
/// </summary>
284-
[Test]
285-
public void TestUseLatest()
286-
{
287-
PlayServicesSupport support = TestData.CreateInstance();
288-
289-
Assert.True(Directory.Exists(support.SDK));
290-
291-
support.DependOn(TestData.PackageId.Artifact, "1+");
292-
support.DependOn(TestData.PackageId.SubDep, "1.1.0");
293-
support.DependOn(TestData.PackageId.TransDep, "LATEST");
294-
295-
Dictionary<string, Dependency> deps =
296-
support.ResolveDependencies(true);
297-
Assert.NotNull(deps);
298-
Dependency d = deps[TestData.PackageId.Artifact.VersionlessKey()];
299-
Assert.AreEqual(TestData.PackageId.Artifact.Info().bestVersion, d.BestVersion);
300-
d = deps[TestData.PackageId.SubDep.VersionlessKey()];
301-
Assert.AreEqual("1.1.0", d.BestVersion);
302-
}
303-
304-
/// <summary>
305-
/// Tests the multi client scenario where 2 clients have different dependencies.
306-
/// </summary>
307-
[Test]
308-
public void TestMultiClient()
309-
{
310-
PlayServicesSupport client1 = TestData.CreateInstance(instanceName: "client1");
311-
PlayServicesSupport client2 = TestData.CreateInstance(instanceName: "client2");
312-
313-
client1.DependOn(TestData.PackageId.Artifact, "1+");
314-
client2.DependOn(TestData.PackageId.SubDep, "1.1.0");
315-
316-
Dictionary<string, Dependency> deps =
317-
client1.ResolveDependencies(true);
318-
Assert.NotNull(deps);
319-
Dependency d = deps[TestData.PackageId.Artifact.VersionlessKey()];
320-
Assert.AreEqual(TestData.PackageId.Artifact.Info().bestVersion, d.BestVersion);
321-
322-
// client 1 needs to see client 2 deps
323-
d = deps[TestData.PackageId.SubDep.VersionlessKey()];
324-
Assert.AreEqual("1.1.0", d.BestVersion);
325-
326-
// now check that client 2 sees them also
327-
deps =
328-
client2.ResolveDependencies(true);
329-
Assert.NotNull(deps);
330-
d = deps[TestData.PackageId.Artifact.VersionlessKey()];
331-
Assert.AreEqual(TestData.PackageId.Artifact.Info().bestVersion, d.BestVersion);
332-
333-
d = deps[TestData.PackageId.SubDep.VersionlessKey()];
334-
Assert.AreEqual("1.1.0", d.BestVersion);
335-
336-
// Now clear client2's deps, and client1 should not see subdep
337-
client2.ClearDependencies();
338-
339-
deps = client1.ResolveDependencies(true);
340-
Assert.NotNull(deps);
341-
d = deps[TestData.PackageId.Artifact.VersionlessKey()];
342-
Assert.AreEqual(TestData.PackageId.Artifact.Info().bestVersion, d.BestVersion);
343-
344-
Assert.False(deps.ContainsKey(TestData.PackageId.SubDep.VersionlessKey()));
345-
}
346-
347-
/// <summary>
348-
/// Tests the latest resolution strategy when one dependency has
349-
/// a transitive dependency that is old, and the caller is requiring
350-
/// a newer version, then the dependencies are resolved with the
351-
/// useLatest flag == true.
352-
/// </summary>
353-
[Test]
354-
public void TestLatestResolution()
355-
{
356-
PlayServicesSupport client1 = TestData.CreateInstance();
357-
358-
// TransDep needs SubDep 0.9.
359-
client1.DependOn(TestData.PackageId.TransDep, "1.0.0");
360-
361-
// We'll set the top level dependency to require SubDep 1.0 or greater.
362-
client1.DependOn(TestData.PackageId.SubDep, "1.0+");
363-
364-
Dictionary<string, Dependency> deps = null;
365-
366-
// The following should fail since we need SubDep 0.9 and SubDep 1.1.0.
367-
ResolutionException ex = null;
368-
try
369-
{
370-
deps = client1.ResolveDependencies(false);
371-
}
372-
catch (ResolutionException e)
373-
{
374-
ex = e;
375-
}
376-
377-
Assert.NotNull(ex, "Expected exception, but got none");
378-
379-
// now try with useLatest == true, should have no exception
380-
ex = null;
381-
try
382-
{
383-
deps = client1.ResolveDependencies(true);
384-
}
385-
catch (ResolutionException e)
386-
{
387-
ex = e;
388-
}
389-
Assert.Null(ex, "unexpected exception");
390-
391-
Assert.NotNull(deps);
392-
393-
// Should have TransDep and SubDep.
394-
Assert.AreEqual(2, deps.Count,
395-
String.Join(", ", new List<string>(deps.Keys).ToArray()));
396-
397-
// Now check that that all the dependencies have the correct best version.
398-
Dependency d = deps[TestData.PackageId.TransDep.VersionlessKey()];
399-
Assert.NotNull(d, "could not find transdep");
400-
Assert.AreEqual(TestData.PackageId.TransDep.Info().bestVersion, d.BestVersion);
401-
402-
d = deps[TestData.PackageId.SubDep.VersionlessKey()];
403-
Assert.NotNull(d, "could not find subdep");
404-
Assert.AreEqual("1.1.0", d.BestVersion);
405-
406-
// Try without version wildcard.
407-
client1.ClearDependencies();
408-
409-
// TransDep needs subdep 0.9.
410-
client1.DependOn(TestData.PackageId.TransDep, "1.0.0");
411-
412-
// Configure top level dependency to require exactly subdep 1.1.0.
413-
client1.DependOn(TestData.PackageId.SubDep, "1.1.0");
414-
415-
ex = null;
416-
try
417-
{
418-
deps = client1.ResolveDependencies(false);
419-
}
420-
catch (ResolutionException e)
421-
{
422-
ex = e;
423-
}
424-
425-
Assert.NotNull(ex, "Expected exception, but got none");
426-
427-
ex = null;
428-
try
429-
{
430-
deps = client1.ResolveDependencies(true);
431-
}
432-
catch (ResolutionException e)
433-
{
434-
ex = e;
435-
}
436-
Assert.Null(ex, "unexpected exception");
437-
438-
Assert.NotNull(deps);
439-
440-
// Should contain TransDep and SubDep.
441-
Assert.AreEqual(2, deps.Count);
442-
443-
// now check that that all the dependencies have the correct
444-
// best version
445-
d = deps[TestData.PackageId.TransDep.VersionlessKey()];
446-
Assert.NotNull(d, "could not find transdep");
447-
Assert.AreEqual(TestData.PackageId.TransDep.Info().bestVersion, d.BestVersion);
448-
449-
d = deps[TestData.PackageId.SubDep.VersionlessKey()];
450-
Assert.NotNull(d, "could not find subdep");
451-
Assert.AreEqual("1.1.0", d.BestVersion);
452-
}
453-
454-
/// <summary>
455-
/// Tests the non active client scenario where the current client has
456-
/// no dependencies, but it resolves all the clients in the project.
457-
/// </summary>
458-
[Test]
459-
public void TestNonActiveClient()
460-
{
461-
PlayServicesSupport client1 = TestData.CreateInstance(instanceName: "client1");
462-
PlayServicesSupport client2 = TestData.CreateInstance(instanceName: "client2");
463-
464-
client1.DependOn(TestData.PackageId.Artifact, "1+");
465-
client2.DependOn(TestData.PackageId.SubDep, "1.1.0");
466-
467-
// now make a third client with no dependencies and make sure it
468-
// sees client1 & 2
469-
PlayServicesSupport client3 = TestData.CreateInstance(instanceName: "client3");
470-
471-
// now check that client 2 sees them also
472-
Dictionary<string, Dependency> deps = client3.ResolveDependencies(true);
473-
Assert.NotNull(deps);
474-
Dependency d = deps[TestData.PackageId.Artifact.VersionlessKey()];
475-
Assert.AreEqual(TestData.PackageId.Artifact.Info().bestVersion, d.BestVersion);
476-
477-
d = deps[TestData.PackageId.SubDep.VersionlessKey()];
478-
Assert.AreEqual("1.1.0", d.BestVersion);
479-
}
480-
481129
/// <summary>
482130
/// Verify the logger delegate is called by the Log() method.
483131
/// </summary>

source/PackageManager/src/Controllers.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,8 +1223,6 @@ static void RefreshClient(ProjectClient client) {
12231223
repositories);
12241224
}
12251225

1226-
var dependencySet = support.ResolveDependencies(true);
1227-
client.depNames.AddRange(dependencySet.Keys);
12281226
WriteProjectPackages();
12291227
EnsurePluginsDirectory();
12301228

@@ -1233,7 +1231,6 @@ static void RefreshClient(ProjectClient client) {
12331231
string.Format("About to resolve for client: {0}", client.Name));
12341232
GooglePlayServices.PlayServicesResolver.Resolver.DoResolution(support,
12351233
"Assets/Plugins/Android",
1236-
GooglePlayServices.PlayServicesResolver.HandleOverwriteConfirmation,
12371234
() => {
12381235
AssetDatabase.Refresh();
12391236
LoggingController.Log(
@@ -1783,4 +1780,4 @@ static void ProcessDepModel(PackageDependencies depsModel, string[] importedAsse
17831780
projectDirty = true;
17841781
}
17851782
}
1786-
}
1783+
}

0 commit comments

Comments
 (0)