From d4f53044727e80729886b53eedd5c90fb73e6e11 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Tue, 29 Aug 2023 08:18:30 +0200 Subject: [PATCH] Add rules_license support --- BUILD.bazel | 23 +++++++++++++++++++++++ MODULE.bazel | 2 ++ REPO.bazel | 3 +++ docs/workspace_macros.md | 1 + jni/BUILD.bazel | 1 + jni/internal/repositories.bzl | 10 ++++++++-- 6 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 REPO.bazel diff --git a/BUILD.bazel b/BUILD.bazel index e69de29..a1cb9b7 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -0,0 +1,23 @@ +load("@rules_license//rules:license.bzl", "license") + +exports_files(["LICENSE"]) + +license( + name = "jdk_license", + copyright_notice = """ +Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved. +""", + license_kinds = ["@rules_license//licenses/spdx:GPL-2.0-with-classpath-exception"], + license_text = "@com_github_openjdk_jdk_license//file", + visibility = ["//:__subpackages__"], +) + +license( + name = "rules_jni_license", + copyright_notice = """ +Copyright (c) 2021 Fabian Meumertzheim +""", + license_kinds = ["@rules_license//licenses/spdx:Apache-2.0"], + license_text = "//:LICENSE", + visibility = ["//:__subpackages__"], +) diff --git a/MODULE.bazel b/MODULE.bazel index f811deb..9bf414d 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -6,6 +6,7 @@ module( bazel_dep(name = "bazel_skylib", version = "1.3.0") bazel_dep(name = "platforms", version = "0.0.5") +bazel_dep(name = "rules_license", version = "0.0.7") download_jdk_deps = use_extension( "@rules_jni//bzlmod:extensions.bzl", @@ -14,6 +15,7 @@ download_jdk_deps = use_extension( use_repo( download_jdk_deps, "com_github_openjdk_jdk_jni_h", + "com_github_openjdk_jdk_license", "com_github_openjdk_jdk_unix_jni_md_h", "com_github_openjdk_jdk_windows_jni_md_h", ) diff --git a/REPO.bazel b/REPO.bazel new file mode 100644 index 0000000..d813897 --- /dev/null +++ b/REPO.bazel @@ -0,0 +1,3 @@ +repo( + default_applicable_licenses = ["//:rules_jni_license"], +) diff --git a/docs/workspace_macros.md b/docs/workspace_macros.md index 30b8962..6e96ea1 100755 --- a/docs/workspace_macros.md +++ b/docs/workspace_macros.md @@ -18,6 +18,7 @@ Currently, rules_jni depends on: * [bazel_skylib](https://github.com/bazelbuild/bazel-skylib) * [platforms](https://github.com/bazelbuild/platforms) +* [rules_license](https://github.com/bazelbuild/rules_license) * individual files of the [OpenJDK](https://github.com/openjdk/jdk) diff --git a/jni/BUILD.bazel b/jni/BUILD.bazel index aa26e44..fde3ca0 100644 --- a/jni/BUILD.bazel +++ b/jni/BUILD.bazel @@ -5,6 +5,7 @@ exports_files(glob(["*.bzl"])) alias( name = "jni", actual = "//jni/internal:jni", + applicable_licenses = ["//:jdk_license"], visibility = ["//visibility:public"], ) diff --git a/jni/internal/repositories.bzl b/jni/internal/repositories.bzl index 62f5826..8b9d7d1 100644 --- a/jni/internal/repositories.bzl +++ b/jni/internal/repositories.bzl @@ -37,6 +37,13 @@ def jdk_deps(): sha256 = "3cacac1e4802ec246ea7c0c6772d4ac40c9f7255d4df095cfffe601137689771", urls = ["https://raw.githubusercontent.com/openjdk/jdk/jdk-22%2B12/src/java.base/windows/native/include/jni_md.h"], ) + maybe( + http_file, + name = "com_github_openjdk_jdk_license", + downloaded_file_path = "LICENSE", + sha256 = "4b9abebc4338048a7c2dc184e9f800deb349366bdf28eb23c2677a77b4c87726", + urls = ["https://raw.githubusercontent.com/openjdk/jdk/jdk-22%2B12/LICENSE"], + ) def rules_jni_dependencies(): """Adds all external repositories required for rules_jni. @@ -47,6 +54,7 @@ Currently, rules_jni depends on: * [bazel_skylib](https://github.com/bazelbuild/bazel-skylib) * [platforms](https://github.com/bazelbuild/platforms) +* [rules_license](https://github.com/bazelbuild/rules_license) * individual files of the [OpenJDK](https://github.com/openjdk/jdk) """ @@ -68,8 +76,6 @@ Currently, rules_jni depends on: "https://github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz", ], ) - - # https://github.com/bazelbuild/platforms/issues/66 maybe( http_archive, name = "rules_license",