Skip to content

Commit 06dc439

Browse files
committed
Upgrade Bazel example
1 parent ffec410 commit 06dc439

File tree

11 files changed

+467
-41
lines changed

11 files changed

+467
-41
lines changed

.bazelignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
mapstruct-on-bazel/bazel-bin
2+
mapstruct-on-bazel/bazel-out
3+
mapstruct-on-bazel/bazel-testlogs
4+
mapstruct-on-bazel/bazel-mapstruct-on-bazel

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
strategy:
7171
fail-fast: false
7272
matrix:
73-
java: [8, 11, 17, 21]
73+
java: [11, 17, 21]
7474
name: 'Linux JDK ${{ matrix.java }} Bazel'
7575
runs-on: ubuntu-latest
7676
steps:
@@ -82,7 +82,7 @@ jobs:
8282
distribution: 'zulu'
8383
java-version: ${{ matrix.java }}
8484
- name: Setup Bazel
85-
uses: bazel-contrib/setup-bazel@0.8.5
85+
uses: bazel-contrib/setup-bazel@0.18.0
8686
with:
8787
# Avoid downloading Bazel every time.
8888
bazelisk-cache: true

BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Root BUILD file for mapstruct-examples
2+
# The actual Bazel build is in the mapstruct-on-bazel subdirectory

MODULE.bazel

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module(
2+
name = "mapstruct-examples",
3+
version = "1.0.0",
4+
)
5+
6+
bazel_dep(name = "rules_java", version = "8.14.0")
7+
bazel_dep(name = "rules_jvm_external", version = "6.6")
8+
9+
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
10+
11+
maven.install(
12+
artifacts = [
13+
"org.mapstruct:mapstruct:1.6.3",
14+
"org.mapstruct:mapstruct-processor:1.6.3",
15+
"junit:junit:4.13.2",
16+
"org.assertj:assertj-core:3.27.7",
17+
],
18+
)
19+
use_repo(maven, "maven")

MODULE.bazel.lock

Lines changed: 207 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WORKSPACE

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,2 @@
1-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
2-
3-
RULES_JVM_EXTERNAL_TAG = "3.3"
4-
5-
RULES_JVM_EXTERNAL_SHA = "d85951a92c0908c80bd8551002d66cb23c3434409c814179c0ff026b53544dab"
6-
7-
http_archive(
8-
name = "rules_jvm_external",
9-
sha256 = RULES_JVM_EXTERNAL_SHA,
10-
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
11-
url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
12-
)
13-
14-
load("@rules_jvm_external//:defs.bzl", "maven_install")
15-
16-
maven_install(
17-
artifacts = [
18-
"junit:junit:4.13.1",
19-
"org.easytesting:fest-assert:1.4",
20-
"org.mapstruct:mapstruct:1.3.1.Final",
21-
"org.mapstruct:mapstruct-processor:1.3.1.Final",
22-
],
23-
repositories = [
24-
"https://jcenter.bintray.com/",
25-
"https://maven.google.com",
26-
"https://repo1.maven.org/maven2",
27-
],
28-
)
1+
# This project has been migrated to Bzlmod (MODULE.bazel)
2+
# The WORKSPACE file is kept for compatibility but is no longer actively used

mapstruct-on-bazel/.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.0
1+
8.5.1

mapstruct-on-bazel/BUILD.bazel

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ load("@rules_java//java:defs.bzl", "java_library", "java_plugin", "java_test")
33
java_library(
44
name = "mapstruct-on-bazel",
55
srcs = glob(["src/main/java/**/*.java"]),
6-
resources = glob(["src/main/resources/**"]),
6+
resources = glob(["src/main/resources/**"], allow_empty = True),
77
deps = [
88
":mapstruct",
99
],
@@ -12,11 +12,11 @@ java_library(
1212
java_library(
1313
name = "tests",
1414
srcs = glob(["src/test/java/**/*.java"]),
15-
resources = glob(["src/test/resources/**"]),
15+
resources = glob(["src/test/resources/**"], allow_empty = True),
1616
deps = [
1717
":mapstruct-on-bazel",
1818
"@maven//:junit_junit",
19-
"@maven//:org_easytesting_fest_assert",
19+
"@maven//:org_assertj_assertj_core",
2020
],
2121
)
2222

@@ -33,15 +33,9 @@ java_library(
3333
exported_plugins = [
3434
":mapstruct_plugin",
3535
],
36-
neverlink = True,
3736
visibility = ["//visibility:public"],
3837
exports = [
3938
"@maven//:org_mapstruct_mapstruct",
40-
"@maven//:org_mapstruct_mapstruct_processor",
41-
],
42-
runtime_deps = [
43-
# add to runtime, as we need
44-
"@maven//:org_mapstruct_mapstruct",
4539
],
4640
)
4741

mapstruct-on-bazel/MODULE.bazel

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module(
2+
name = "mapstruct-on-bazel",
3+
version = "1.0.0",
4+
)
5+
6+
bazel_dep(name = "rules_java", version = "8.14.0")
7+
8+
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
9+
bazel_dep(name = "rules_jvm_external", version = "6.6")
10+
11+
maven.install(
12+
artifacts = [
13+
"org.mapstruct:mapstruct:1.6.3",
14+
"org.mapstruct:mapstruct-processor:1.6.3",
15+
"junit:junit:4.13.2",
16+
"org.assertj:assertj-core:3.27.7",
17+
],
18+
)
19+
use_repo(maven, "maven")

mapstruct-on-bazel/MODULE.bazel.lock

Lines changed: 207 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)