Skip to content

Commit

Permalink
Add rules_license support
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Aug 29, 2023
1 parent 49a7642 commit d4f5304
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 2 deletions.
23 changes: 23 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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__"],
)
2 changes: 2 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
)
3 changes: 3 additions & 0 deletions REPO.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
repo(
default_applicable_licenses = ["//:rules_jni_license"],
)
1 change: 1 addition & 0 deletions docs/workspace_macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
1 change: 1 addition & 0 deletions jni/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports_files(glob(["*.bzl"]))
alias(
name = "jni",
actual = "//jni/internal:jni",
applicable_licenses = ["//:jdk_license"],
visibility = ["//visibility:public"],
)

Expand Down
10 changes: 8 additions & 2 deletions jni/internal/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
"""
Expand All @@ -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",
Expand Down

0 comments on commit d4f5304

Please sign in to comment.