• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2024 The Bazel Authors. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#    http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14"""Checks for keeping repository_util.bzl and repositories.bzl in sync"""
15
16load("//java:repositories.bzl", "REMOTE_JDK_CONFIGS")
17load("//java/bazel:repositories_util.bzl", "FLAT_CONFIGS")
18
19def validate_configs():
20    """Ensures repository_util.bzl and repositories.bzl are in sync"""
21    for expected in FLAT_CONFIGS:
22        actual = [cfg for cfg in REMOTE_JDK_CONFIGS[expected.version] if cfg.name == expected.name]
23        if len(actual) != 1:
24            fail("Expected to find exactly one configuration for:", expected.name, "found: ", actual)
25        actual = actual[0]
26        if expected.urls != actual.urls or expected.strip_prefix != actual.strip_prefix:
27            fail("config mismatch! wanted:", expected, "got:", actual)
28