Skip to content

Commit

Permalink
Initial changes to support bzlmod registration
Browse files Browse the repository at this point in the history
  • Loading branch information
BradHolmes committed Dec 30, 2024
1 parent 5ea617b commit 5e712d4
Show file tree
Hide file tree
Showing 6 changed files with 576 additions and 39 deletions.
11 changes: 11 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module(
name = "openapi_tools_generator_bazel",
version = "0.1.7",
compatibility_level = 0,
)

bazel_dep(name = "rules_pkg", version = "1.0.1")
openapi_gen = use_extension("@openapi_tools_generator_bazel//:extension.bzl", "openapi_gen")
openapi_gen.client()
use_repo(openapi_gen, "openapi_tools_generator_bazel_cli")

535 changes: 535 additions & 0 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

16 changes: 0 additions & 16 deletions WORKSPACE

This file was deleted.

2 changes: 0 additions & 2 deletions defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
load(
"//internal:openapi_generator.bzl",
_openapi_generator = "openapi_generator",
_openapi_tools_generator_bazel_repositories = "openapi_tools_generator_bazel_repositories",
)

openapi_generator = _openapi_generator

openapi_tools_generator_bazel_repositories = _openapi_tools_generator_bazel_repositories
29 changes: 29 additions & 0 deletions extension.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"modules extension to use with openapi-generator-bazel"
load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external")

def _openapi_generator_impl(module_ctx):
for mod in module_ctx.modules:
for install in mod.tags.client:
jvm_maven_import_external(
name = "openapi_tools_generator_bazel_cli",
artifact_sha256 = install.sha256,
artifact = "org.openapitools:openapi-generator-cli:" + install.version,
server_urls = install.server_urls,
)

_cli = tag_class(attrs = {
"version": attr.string(
default = "7.2.0",
),
"sha256": attr.string(
default = "1cf0c80de12c0fdc8594289c19e414b402108ef10b8dd0bfda1953151341ab5d",
),
"server_urls": attr.string_list(
default = ["https://repo1.maven.org/maven2"],
),
})
openapi_gen = module_extension(
implementation = _openapi_generator_impl,
tag_classes = {"client": _cli},
)

22 changes: 1 addition & 21 deletions internal/openapi_generator.bzl
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
# Copyright 2019 OpenAPI-Generator-Bazel Contributors

load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external")

def openapi_tools_generator_bazel_repositories(
openapi_generator_cli_version = "6.5.0",
sha256 = "f18d771e98f2c5bb169d1d1961de4f94866d2901abc1e16177dd7e9299834721",
prefix = "openapi_tools_generator_bazel",
server_urls = [
"https://repo1.maven.org/maven2"
]):
jvm_maven_import_external(
name = "openapi_tools_generator_bazel_cli",
artifact_sha256 = sha256,
artifact = "org.openapitools:openapi-generator-cli:" + openapi_generator_cli_version,
server_urls = server_urls,
)
native.bind(
name = prefix + "/dependency/openapi-generator-cli",
actual = "@" + prefix + "_cli//jar",
)

def _comma_separated_pairs(pairs):
return ",".join([
"{}={}".format(k, v)
Expand Down Expand Up @@ -193,7 +173,7 @@ _openapi_generator = rule(
),
"openapi_generator_cli": attr.label(
cfg = "exec",
default = Label("//external:openapi_tools_generator_bazel/dependency/openapi-generator-cli"),
default = Label("@openapi_tools_generator_bazel_cli//:openapi_tools_generator_bazel_cli"),
allow_single_file = True,
),
},
Expand Down

0 comments on commit 5e712d4

Please sign in to comment.