public void TestMultiClient() { PlayServicesSupport client1 = PlayServicesSupport.CreateInstance( "client1", "../../testData", Path.GetTempPath()); PlayServicesSupport client2 = PlayServicesSupport.CreateInstance( "client2", "../../testData", Path.GetTempPath()); client1.ResetDependencies(); client2.ResetDependencies(); client1.DependOn("test", "artifact", "1+"); client2.DependOn("test", "subdep", "1.1.0"); Dictionary <string, Dependency> deps = client1.ResolveDependencies(true); Assert.NotNull(deps); Dependency d = deps["test:artifact"]; Assert.True(d.BestVersion == "8.1.0"); // client 1 needs to see client 2 deps d = deps["test:subdep"]; Assert.True(d.BestVersion == "1.1.0"); // now check that client 2 sees them also deps = client2.ResolveDependencies(true); Assert.NotNull(deps); d = deps["test:artifact"]; Assert.True(d.BestVersion == "8.1.0"); d = deps["test:subdep"]; Assert.True(d.BestVersion == "1.1.0"); // Now clear client2's deps, and client1 should not see subdep client2.ClearDependencies(); deps = client1.ResolveDependencies(true); Assert.NotNull(deps); d = deps["test:artifact"]; Assert.True(d.BestVersion == "8.1.0"); Assert.False(deps.ContainsKey("test:subdep")); }
public static void Resolve() { svcSupport.ClearDependencies(); AddDependencies(); Dictionary <string, Dependency> deps = svcSupport.ResolveDependencies(true); svcSupport.CopyDependencies(deps, "Assets/Plugins/Android", HandleOverwriteConfirmation); AssetDatabase.Refresh(); EditorUtility.DisplayDialog("Android Jar Dependencies", "Resolution Complete", "OK"); }
/// <summary> /// Perform the resolution and the exploding/cleanup as needed. /// </summary> static void DoResolution() { // Get the collection of dependencies that need to be copied. Dictionary <string, Dependency> deps = svcSupport.ResolveDependencies(true); // Copy the list svcSupport.CopyDependencies(deps, "Assets/Plugins/Android", HandleOverwriteConfirmation); // If aar files are not supported, explode them into directories. // otherwise clean up any exploded directories in favor of the aar files. if (!SupportsAarFiles) { Debug.Log("Exploding"); // need to explode the .aar file in place. ExplodeAarFiles("Assets/Plugins/Android"); } else { Debug.Log("Cleaning up exploded aars..."); CleanupExploded("Assets/Plugins/Android"); } }
public void TestCustomRepoPath() { string[] repos = { "../../testData/extras/google/m2repository" }; PlayServicesSupport support = PlayServicesSupport.CreateInstance( "testInstance", "..", repos, Path.GetTempPath()); Assert.True(Directory.Exists(support.SDK)); // happy path support.ResetDependencies(); support.DependOn("test", "artifact", "LATEST"); Dictionary <string, Dependency> deps = support.ResolveDependencies(false); Assert.NotNull(deps); // should be only 1 and version 8.1 Assert.True(deps.Count == 1); IEnumerator <Dependency> iter = deps.Values.GetEnumerator(); iter.MoveNext(); Assert.True(iter.Current.BestVersion == "8.2.0-alpha"); }
/// <summary> /// Perform resolution with no Android package dependency checks. /// </summary> private void DoResolutionNoAndroidPackageChecks( PlayServicesSupport svcSupport, string destinationDirectory, PlayServicesSupport.OverwriteConfirmation handleOverwriteConfirmation) { try { // Get the collection of dependencies that need to be copied. Dictionary <string, Dependency> deps = svcSupport.ResolveDependencies(true); // Copy the list svcSupport.CopyDependencies(deps, destinationDirectory, handleOverwriteConfirmation); } catch (Google.JarResolver.ResolutionException e) { Debug.LogError(e.ToString()); return; } // we want to look at all the .aars to decide to explode or not. // Some aars have variables in their AndroidManifest.xml file, // e.g. ${applicationId}. Unity does not understand how to process // these, so we handle it here. ProcessAars(destinationDirectory); SaveAarExplodeCache(); }
public void TestMultiClient() { PlayServicesSupport client1 = TestData.CreateInstance(instanceName: "client1"); PlayServicesSupport client2 = TestData.CreateInstance(instanceName: "client2"); client1.DependOn(TestData.PackageId.Artifact, "1+"); client2.DependOn(TestData.PackageId.SubDep, "1.1.0"); Dictionary <string, Dependency> deps = client1.ResolveDependencies(true); Assert.NotNull(deps); Dependency d = deps[TestData.PackageId.Artifact.VersionlessKey()]; Assert.AreEqual(TestData.PackageId.Artifact.Info().bestVersion, d.BestVersion); // client 1 needs to see client 2 deps d = deps[TestData.PackageId.SubDep.VersionlessKey()]; Assert.AreEqual("1.1.0", d.BestVersion); // now check that client 2 sees them also deps = client2.ResolveDependencies(true); Assert.NotNull(deps); d = deps[TestData.PackageId.Artifact.VersionlessKey()]; Assert.AreEqual(TestData.PackageId.Artifact.Info().bestVersion, d.BestVersion); d = deps[TestData.PackageId.SubDep.VersionlessKey()]; Assert.AreEqual("1.1.0", d.BestVersion); // Now clear client2's deps, and client1 should not see subdep client2.ClearDependencies(); deps = client1.ResolveDependencies(true); Assert.NotNull(deps); d = deps[TestData.PackageId.Artifact.VersionlessKey()]; Assert.AreEqual(TestData.PackageId.Artifact.Info().bestVersion, d.BestVersion); Assert.False(deps.ContainsKey(TestData.PackageId.SubDep.VersionlessKey())); }
/// <summary> /// Perform the resolution and the exploding/cleanup as needed. /// </summary> public override void DoResolution(PlayServicesSupport svcSupport, string destinationDirectory, PlayServicesSupport.OverwriteConfirmation handleOverwriteConfirmation) { // Get the collection of dependencies that need to be copied. Dictionary <string, Dependency> deps = svcSupport.ResolveDependencies(true); // Copy the list svcSupport.CopyDependencies(deps, destinationDirectory, handleOverwriteConfirmation); // we want to look at all the .aars to decide to explode or not. // Some aars have variables in their AndroidManifest.xml file, // e.g. ${applicationId}. Unity does not understand how to process // these, so we handle it here. ProcessAars(destinationDirectory); }
public void TestSimpleResolveDependencies() { PlayServicesSupport support = TestData.CreateInstance(); Assert.True(Directory.Exists(support.SDK)); support.DependOn(TestData.PackageId.Artifact, "LATEST"); Dictionary <string, Dependency> deps = support.ResolveDependencies(false); Assert.NotNull(deps); // Verify one single dependency is returned at the expected version. Assert.AreEqual(1, deps.Count); IEnumerator <Dependency> iter = deps.Values.GetEnumerator(); iter.MoveNext(); Assert.AreEqual(TestData.PackageId.Artifact.Info().bestVersion, iter.Current.BestVersion); }
public void TestUseLatest() { PlayServicesSupport support = TestData.CreateInstance(); Assert.True(Directory.Exists(support.SDK)); support.DependOn(TestData.PackageId.Artifact, "1+"); support.DependOn(TestData.PackageId.SubDep, "1.1.0"); support.DependOn(TestData.PackageId.TransDep, "LATEST"); Dictionary <string, Dependency> deps = support.ResolveDependencies(true); Assert.NotNull(deps); Dependency d = deps[TestData.PackageId.Artifact.VersionlessKey()]; Assert.AreEqual(TestData.PackageId.Artifact.Info().bestVersion, d.BestVersion); d = deps[TestData.PackageId.SubDep.VersionlessKey()]; Assert.AreEqual("1.1.0", d.BestVersion); }
public void TestNonActiveClient() { PlayServicesSupport client1 = TestData.CreateInstance(instanceName: "client1"); PlayServicesSupport client2 = TestData.CreateInstance(instanceName: "client2"); client1.DependOn(TestData.PackageId.Artifact, "1+"); client2.DependOn(TestData.PackageId.SubDep, "1.1.0"); // now make a third client with no dependencies and make sure it // sees client1 & 2 PlayServicesSupport client3 = TestData.CreateInstance(instanceName: "client3"); // now check that client 2 sees them also Dictionary <string, Dependency> deps = client3.ResolveDependencies(true); Assert.NotNull(deps); Dependency d = deps[TestData.PackageId.Artifact.VersionlessKey()]; Assert.AreEqual(TestData.PackageId.Artifact.Info().bestVersion, d.BestVersion); d = deps[TestData.PackageId.SubDep.VersionlessKey()]; Assert.AreEqual("1.1.0", d.BestVersion); }
public void TestUseLatest() { PlayServicesSupport support = PlayServicesSupport.CreateInstance( "testInstance", "../../testData", Path.GetTempPath()); Assert.True(Directory.Exists(support.SDK)); support.DependOn("test", "artifact", "1+"); support.DependOn("test", "subdep", "1.1.0"); support.DependOn("test", "transdep", "LATEST"); Dictionary <string, Dependency> deps = support.ResolveDependencies(true); Assert.NotNull(deps); Dependency d = deps["test:artifact"]; Assert.True(d.BestVersion == "8.1.0"); d = deps["test:subdep"]; Assert.True(d.BestVersion == "1.1.0"); }
public void TestCustomRepoPath() { string[] repos = { Path.Combine(TestData.PATH, "extras/google/m2repository") }; PlayServicesSupport support = TestData.CreateInstance( sdkPath: "..", additionalRepositories: repos); Assert.True(Directory.Exists(support.SDK)); support.ClearDependencies(); support.DependOn(TestData.PackageId.Artifact, "LATEST"); Dictionary <string, Dependency> deps = support.ResolveDependencies(false); Assert.NotNull(deps); // Verify one dependency is returned at the expected version. Assert.AreEqual(1, deps.Count); IEnumerator <Dependency> iter = deps.Values.GetEnumerator(); iter.MoveNext(); Assert.AreEqual(TestData.PackageId.Artifact.Info().bestVersion, iter.Current.BestVersion); }
public void TestNonActiveClient() { PlayServicesSupport client1 = PlayServicesSupport.CreateInstance( "client1", "../../testData", Path.GetTempPath()); PlayServicesSupport client2 = PlayServicesSupport.CreateInstance( "client2", "../../testData", Path.GetTempPath()); client1.ResetDependencies(); client2.ResetDependencies(); client1.DependOn("test", "artifact", "1+"); client2.DependOn("test", "subdep", "1.1.0"); // now make a third client with no dependencies and make sure it // sees client1 & 2 PlayServicesSupport client3 = PlayServicesSupport.CreateInstance( "client3", "../../testData", Path.GetTempPath()); // now check that client 2 sees them also Dictionary <string, Dependency> deps = client3.ResolveDependencies(true); Assert.NotNull(deps); Dependency d = deps["test:artifact"]; Assert.True(d.BestVersion == "8.1.0"); d = deps["test:subdep"]; Assert.True(d.BestVersion == "1.1.0"); }
public void TestResolveDependencies() { PlayServicesSupport support = PlayServicesSupport.CreateInstance( "testInstance", "../../testData", Path.GetTempPath()); Assert.True(Directory.Exists(support.SDK)); support.ResetDependencies(); // happy path support.DependOn("test", "artifact", "LATEST"); Dictionary <string, Dependency> deps = support.ResolveDependencies(false); Assert.NotNull(deps); // should be only 1 and version 8.1 Assert.True(deps.Count == 1); IEnumerator <Dependency> iter = deps.Values.GetEnumerator(); iter.MoveNext(); Assert.True(iter.Current.BestVersion == "8.1.0"); // check dependency that has transitive dependencies support.DependOn("test", "transdep", "1.0"); deps = support.ResolveDependencies(false); Assert.NotNull(deps); // 1 is the previous test, then 2 for transdep and subdep. Assert.True(deps.Count == 3); Dependency d = deps["test:artifact"]; Assert.True(d.BestVersion == "8.1.0"); d = deps["test:transdep"]; Assert.AreEqual(d.BestVersion, "1.0.0"); d = deps["test:subdep"]; Assert.True(d.BestVersion == "0.9"); // check constraining down to a later version - the LATEST // will make this fail. support.DependOn("test", "artifact", "7.0.0"); ResolutionException ex = null; try { deps = support.ResolveDependencies(false); } catch (ResolutionException e) { ex = e; } Assert.NotNull(ex); // Now add it as 7+ and LATEST and it will work. support.ResetDependencies(); support.DependOn("test", "artifact", "LATEST"); support.DependOn("test", "artifact", "7+"); deps = support.ResolveDependencies(false); Assert.NotNull(deps); d = deps["test:artifact"]; Assert.True(d.BestVersion == "8.1.0"); // Test downversioning. support.ResetDependencies(); support.DependOn("test", "artifact", "1+"); support.DependOn("test", "artifact", "2+"); support.DependOn("test", "artifact", "7.0.0"); deps = support.ResolveDependencies(false); Assert.NotNull(deps); d = deps["test:artifact"]; Assert.True(d.BestVersion == "7.0.0"); // test the transitive dep influencing a top level support.ResetDependencies(); support.DependOn("test", "artifact", "1+"); support.DependOn("test", "subdep", "0+"); support.DependOn("test", "transdep", "LATEST"); deps = support.ResolveDependencies(false); Assert.NotNull(deps); d = deps["test:artifact"]; Assert.True(d.BestVersion == "8.1.0"); d = deps["test:subdep"]; Assert.True(d.BestVersion == "0.9"); }
public void TestLatestResolution() { PlayServicesSupport client1 = PlayServicesSupport.CreateInstance( "client1", "../../testData", Path.GetTempPath()); client1.ResetDependencies(); //trans dep needs subdep 0.9 client1.DependOn("test", "transdep", "1.0.0"); // so top level require subdep 1.0 or greater client1.DependOn("test", "subdep", "1.0+"); Dictionary <string, Dependency> deps = null; // this should fail since we need 0.9 and 1.1.0 ResolutionException ex = null; try { deps = client1.ResolveDependencies(false); } catch (ResolutionException e) { ex = e; } Assert.NotNull(ex, "Expected exception, but got none"); // now try with useLatest == true, should have no exception ex = null; try { deps = client1.ResolveDependencies(true); } catch (ResolutionException e) { ex = e; } Assert.Null(ex, "unexpected exception"); Assert.NotNull(deps); Assert.IsTrue(deps.Count == 2, "Expected 2 dependencies, got " + deps.Count); // now check that that all the dependencies have the correct // best version Dependency d = deps["test:transdep"]; Assert.NotNull(d, "could not find transdep"); Assert.IsTrue(d.BestVersion == "1.0.0", "Expected version 1.0.0, got " + d.BestVersion); d = deps["test:subdep"]; Assert.NotNull(d, "could not find subdep"); Assert.IsTrue(d.BestVersion == "1.1.0", "Expected version 1.1.0, got " + d.BestVersion); // try without wildcard client1.ResetDependencies(); //trans dep needs subdep 0.9 client1.DependOn("test", "transdep", "1.0.0"); // so top level requires exactly subdep 1.1.0. client1.DependOn("test", "subdep", "1.1.0"); ex = null; try { deps = client1.ResolveDependencies(false); } catch (ResolutionException e) { ex = e; } Assert.NotNull(ex, "Expected exception, but got none"); ex = null; try { deps = client1.ResolveDependencies(true); } catch (ResolutionException e) { ex = e; } Assert.Null(ex, "unexpected exception"); Assert.NotNull(deps); Assert.IsTrue(deps.Count == 2, "Expected 2 dependencies, got " + deps.Count); // now check that that all the dependencies have the correct // best version d = deps["test:transdep"]; Assert.NotNull(d, "could not find transdep"); Assert.IsTrue(d.BestVersion == "1.0.0", "Expected version 1.0.0, got " + d.BestVersion); d = deps["test:subdep"]; Assert.NotNull(d, "could not find subdep"); Assert.IsTrue(d.BestVersion == "1.1.0", "Expected version 1.1.0, got " + d.BestVersion); }
public void TestLatestResolution() { PlayServicesSupport client1 = TestData.CreateInstance(); // TransDep needs SubDep 0.9. client1.DependOn(TestData.PackageId.TransDep, "1.0.0"); // We'll set the top level dependency to require SubDep 1.0 or greater. client1.DependOn(TestData.PackageId.SubDep, "1.0+"); Dictionary <string, Dependency> deps = null; // The following should fail since we need SubDep 0.9 and SubDep 1.1.0. ResolutionException ex = null; try { deps = client1.ResolveDependencies(false); } catch (ResolutionException e) { ex = e; } Assert.NotNull(ex, "Expected exception, but got none"); // now try with useLatest == true, should have no exception ex = null; try { deps = client1.ResolveDependencies(true); } catch (ResolutionException e) { ex = e; } Assert.Null(ex, "unexpected exception"); Assert.NotNull(deps); // Should have TransDep and SubDep. Assert.AreEqual(2, deps.Count, String.Join(", ", new List <string>(deps.Keys).ToArray())); // Now check that that all the dependencies have the correct best version. Dependency d = deps[TestData.PackageId.TransDep.VersionlessKey()]; Assert.NotNull(d, "could not find transdep"); Assert.AreEqual(TestData.PackageId.TransDep.Info().bestVersion, d.BestVersion); d = deps[TestData.PackageId.SubDep.VersionlessKey()]; Assert.NotNull(d, "could not find subdep"); Assert.AreEqual("1.1.0", d.BestVersion); // Try without version wildcard. client1.ClearDependencies(); // TransDep needs subdep 0.9. client1.DependOn(TestData.PackageId.TransDep, "1.0.0"); // Configure top level dependency to require exactly subdep 1.1.0. client1.DependOn(TestData.PackageId.SubDep, "1.1.0"); ex = null; try { deps = client1.ResolveDependencies(false); } catch (ResolutionException e) { ex = e; } Assert.NotNull(ex, "Expected exception, but got none"); ex = null; try { deps = client1.ResolveDependencies(true); } catch (ResolutionException e) { ex = e; } Assert.Null(ex, "unexpected exception"); Assert.NotNull(deps); // Should contain TransDep and SubDep. Assert.AreEqual(2, deps.Count); // now check that that all the dependencies have the correct // best version d = deps[TestData.PackageId.TransDep.VersionlessKey()]; Assert.NotNull(d, "could not find transdep"); Assert.AreEqual(TestData.PackageId.TransDep.Info().bestVersion, d.BestVersion); d = deps[TestData.PackageId.SubDep.VersionlessKey()]; Assert.NotNull(d, "could not find subdep"); Assert.AreEqual("1.1.0", d.BestVersion); }
public void TestResolveDependencies() { PlayServicesSupport support = TestData.CreateInstance(); Assert.True(Directory.Exists(support.SDK)); support.DependOn(TestData.PackageId.Artifact, "LATEST"); Dictionary <string, Dependency> deps = support.ResolveDependencies(false); Assert.NotNull(deps); // Verify one dependency is returned at the expected version. Assert.AreEqual(1, deps.Count); IEnumerator <Dependency> iter = deps.Values.GetEnumerator(); iter.MoveNext(); Assert.AreEqual(TestData.PackageId.Artifact.Info().bestVersion, iter.Current.BestVersion); // Check dependency with has transitive dependencies. support.DependOn(TestData.PackageId.TransDep, "1.0"); deps = support.ResolveDependencies(false); Assert.NotNull(deps); // One dependency should be present from the previous test and an additional two // for the transdep and subdep. Assert.AreEqual(3, deps.Count); Dependency d = deps[TestData.PackageId.Artifact.VersionlessKey()]; Assert.AreEqual(TestData.PackageId.Artifact.Info().bestVersion, d.BestVersion); d = deps[TestData.PackageId.TransDep.VersionlessKey()]; Assert.AreEqual(TestData.PackageId.TransDep.Info().bestVersion, d.BestVersion); d = deps[TestData.PackageId.SubDep.VersionlessKey()]; Assert.AreEqual(TestData.PackageId.SubDep.Info().bestVersion, d.BestVersion); // check constraining down to a later version - the LATEST // will make this fail. support.DependOn(TestData.PackageId.Artifact, "7.0.0"); ResolutionException ex = null; try { deps = support.ResolveDependencies(false); } catch (ResolutionException e) { ex = e; } Assert.NotNull(ex); // Now add it as 7+ and LATEST and it will work. support.ClearDependencies(); support.DependOn(TestData.PackageId.Artifact, "LATEST"); support.DependOn(TestData.PackageId.Artifact, "7+"); deps = support.ResolveDependencies(false); Assert.NotNull(deps); d = deps[TestData.PackageId.Artifact.VersionlessKey()]; Assert.AreEqual(TestData.PackageId.Artifact.Info().bestVersion, d.BestVersion); // Test downversioning. support.ClearDependencies(); support.DependOn(TestData.PackageId.Artifact, "1+"); support.DependOn(TestData.PackageId.Artifact, "2+"); support.DependOn(TestData.PackageId.Artifact, "7.0.0"); deps = support.ResolveDependencies(false); Assert.NotNull(deps); d = deps[TestData.PackageId.Artifact.VersionlessKey()]; Assert.AreEqual("7.0.0", d.BestVersion); // test the transitive dep influencing a top level support.ClearDependencies(); support.DependOn(TestData.PackageId.Artifact, "1+"); support.DependOn(TestData.PackageId.SubDep, "0+"); support.DependOn(TestData.PackageId.TransDep, "LATEST"); deps = support.ResolveDependencies(false); Assert.NotNull(deps); d = deps[TestData.PackageId.Artifact.VersionlessKey()]; Assert.AreEqual(TestData.PackageId.Artifact.Info().bestVersion, d.BestVersion); d = deps[TestData.PackageId.SubDep.VersionlessKey()]; Assert.AreEqual(TestData.PackageId.SubDep.Info().bestVersion, d.BestVersion); }