@Test public void twoResolversMatch() throws Exception { ManifestProvider provider = mock(ManifestProvider.class); when(provider.tryGetManifest(ADMOB_COORDINATE, new URL(ADMOB_URL))).thenReturn(ADMOB_MANIFEST); CoordinateResolver resolvers[] = new CoordinateResolver[]{new GithubReleasesCoordinateResolver(), new GithubReleasesCoordinateResolver()}; Resolver resolver = new Resolver(provider, resolvers); try { assert ADMOB_COORDINATE != null; resolver.resolveAny(new SoftNameDependency(ADMOB_COORDINATE.toString())); fail("Expected exception"); } catch (RuntimeException e) { assertThat(e).hasMessage("Multiple resolvers matched coordinate: com.github.jomof:firebase/admob:2.1.3-rev7"); } }
@Nullable public ResolvedManifest resolveAny(@NotNull SoftNameDependency dependency) throws IOException, NoSuchAlgorithmException { ResolvedManifest resolved = null; for (CoordinateResolver resolver : resolvers) { ResolvedManifest attempt = resolver.resolve(manifestProvider, dependency); if (attempt != null) { require(resolved == null, "Multiple resolvers matched coordinate: " + dependency.compile); resolved = attempt; } } if (resolved != null) { CDepManifestYmlUtils.checkManifestSanity(resolved.cdepManifestYml); } return resolved; }
Resolver { @Nullable public ResolvedManifest resolveAny(@NotNull SoftNameDependency dependency) throws IOException, NoSuchAlgorithmException { ResolvedManifest resolved = null; for (CoordinateResolver resolver : resolvers) { ResolvedManifest attempt = resolver.resolve(manifestProvider, dependency); if (attempt != null) { require(resolved == null, "Multiple resolvers matched coordinate: " + dependency.compile); resolved = attempt; } } if (resolved != null) { CDepManifestYmlUtils.checkManifestSanity(resolved.cdepManifestYml); } return resolved; } }
Resolver { @Nullable public ResolvedManifest resolveAny(@NotNull SoftNameDependency dependency) throws IOException, NoSuchAlgorithmException { ResolvedManifest resolved = null; for (CoordinateResolver resolver : resolvers) { ResolvedManifest attempt = resolver.resolve(manifestProvider, dependency); if (attempt != null) { require(resolved == null, "Multiple resolvers matched coordinate: " + dependency.compile); resolved = attempt; } } if (resolved != null) { CDepManifestYmlUtils.checkManifestSanity(resolved.cdepManifestYml); } return resolved; } Resolver(ManifestProvider manifestProvider);   Resolver(ManifestProvider manifestProvider, CoordinateResolver resolvers[]); }
Resolver { @Nullable public ResolvedManifest resolveAny(@NotNull SoftNameDependency dependency) throws IOException, NoSuchAlgorithmException { ResolvedManifest resolved = null; for (CoordinateResolver resolver : resolvers) { ResolvedManifest attempt = resolver.resolve(manifestProvider, dependency); if (attempt != null) { require(resolved == null, "Multiple resolvers matched coordinate: " + dependency.compile); resolved = attempt; } } if (resolved != null) { CDepManifestYmlUtils.checkManifestSanity(resolved.cdepManifestYml); } return resolved; } Resolver(ManifestProvider manifestProvider);   Resolver(ManifestProvider manifestProvider, CoordinateResolver resolvers[]); @NotNull ResolutionScope resolveAll(@NotNull SoftNameDependency[] roots); void resolveAll(@NotNull ResolutionScope scope); @Nullable ResolvedManifest resolveAny(@NotNull SoftNameDependency dependency); }
Resolver { @Nullable public ResolvedManifest resolveAny(@NotNull SoftNameDependency dependency) throws IOException, NoSuchAlgorithmException { ResolvedManifest resolved = null; for (CoordinateResolver resolver : resolvers) { ResolvedManifest attempt = resolver.resolve(manifestProvider, dependency); if (attempt != null) { require(resolved == null, "Multiple resolvers matched coordinate: " + dependency.compile); resolved = attempt; } } if (resolved != null) { CDepManifestYmlUtils.checkManifestSanity(resolved.cdepManifestYml); } return resolved; } Resolver(ManifestProvider manifestProvider);   Resolver(ManifestProvider manifestProvider, CoordinateResolver resolvers[]); @NotNull ResolutionScope resolveAll(@NotNull SoftNameDependency[] roots); void resolveAll(@NotNull ResolutionScope scope); @Nullable ResolvedManifest resolveAny(@NotNull SoftNameDependency dependency);  }