Skip to content
This repository was archived by the owner on Mar 22, 2026. It is now read-only.

Commit ed47782

Browse files
committed
添加 bazel 构建脚本
1 parent f4b9187 commit ed47782

File tree

64 files changed

+14349
-28
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+14349
-28
lines changed

.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
common --java_runtime_version=21
2+
common --java_language_version=21

.github/workflows/build.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name: build
77
on: [pull_request, push]
88

99
jobs:
10-
build:
10+
build-with-gradle:
1111
runs-on: ubuntu-24.04
1212
steps:
1313
- name: checkout repository
@@ -26,5 +26,24 @@ jobs:
2626
- name: capture build artifacts
2727
uses: actions/upload-artifact@v4
2828
with:
29-
name: Artifacts
30-
path: mod/build/libs/
29+
name: artifacts-gradle
30+
path: mod/build/libs/
31+
build-with-bazel:
32+
runs-on: ubuntu-24.04
33+
steps:
34+
- name: checkout repository
35+
uses: actions/checkout@v4
36+
- uses: bazel-contrib/setup-bazel@0.14.0
37+
with:
38+
bazelisk-cache: true
39+
disk-cache: ${{ github.workflow }}
40+
repository-cache: true
41+
- name: build
42+
run: bazel build @//mod --verbose_failures
43+
- name: test
44+
run: bazel test @//... --verbose_failures
45+
- name: capture build artifacts
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: artifacts-bazel
49+
path: bazel-bin/mod/mod.jar

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,7 @@ replay_*.log
4343
# kotlin
4444

4545
.kotlin
46+
47+
# bazel
48+
.bazelbsp
49+
bazel-*

BUILD.bazel

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
load("@rules_kotlin//kotlin:core.bzl", "define_kt_toolchain", "kt_compiler_plugin")
2+
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")
3+
4+
kt_compiler_plugin(
5+
name = "serialization_plugin",
6+
compile_phase = True,
7+
id = "org.jetbrains.kotlin.serialization",
8+
stubs_phase = True,
9+
deps = [
10+
"@rules_kotlin//kotlin/compiler:kotlinx-serialization-compiler-plugin",
11+
],
12+
)
13+
14+
kt_jvm_library(
15+
name = "kotlin_serialization",
16+
srcs = [],
17+
visibility = ["//visibility:public"],
18+
exported_compiler_plugins = [":serialization_plugin"],
19+
exports = [
20+
"@maven//:org_jetbrains_kotlinx_kotlinx_serialization_core_jvm",
21+
],
22+
)
23+
24+
define_kt_toolchain(
25+
name = "kotlin_toolchain",
26+
jvm_target = "21",
27+
)

MODULE.bazel

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
"ArmorStand module file"
2+
3+
module(
4+
name = "armorstand",
5+
version = "0.0.1+dev",
6+
)
7+
8+
bazel_dep(name = "rules_java", version = "8.12.0")
9+
bazel_dep(name = "rules_kotlin", version = "2.1.4")
10+
bazel_dep(name = "rules_jvm_external", version = "6.7")
11+
bazel_dep(name = "bazel_skylib", version = "1.7.1")
12+
13+
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
14+
maven.install(
15+
artifacts = [
16+
# mapping
17+
"net.fabricmc:yarn:1.21.5+build.1:v2",
18+
"net.fabricmc:intermediary:1.21.5:v2",
19+
20+
# build dependencies
21+
"net.fabricmc:tiny-remapper:0.11.1",
22+
"net.fabricmc:mapping-io:0.7.1",
23+
"net.fabricmc:mapping-io-extras:0.7.1",
24+
"net.fabricmc:access-widener:2.1.0",
25+
"org.ow2.asm:asm:9.8",
26+
"org.ow2.asm:asm-commons:9.8",
27+
28+
# mod dependencies
29+
"net.fabricmc:fabric-loader:0.16.14",
30+
"com.terraformersmc:modmenu:14.0.0-rc.2",
31+
"net.fabricmc.fabric-api:fabric-api:0.124.2+1.21.5",
32+
"net.fabricmc:fabric-language-kotlin:1.13.1+kotlin.2.1.10",
33+
"net.fabricmc:sponge-mixin:0.15.4+mixin.0.8.7",
34+
"io.github.llamalad7:mixinextras-fabric:0.4.1",
35+
"eu.pb4:placeholder-api:2.6.3+1.21.5",
36+
37+
# regular dependencies
38+
"org.joml:joml:1.10.8",
39+
"org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.1",
40+
"it.unimi.dsi:fastutil:8.5.15",
41+
42+
# test dependencies
43+
"org.jetbrains.kotlin:kotlin-test-junit5:2.1.10",
44+
"org.junit.jupiter:junit-jupiter-api:5.12.2",
45+
"org.junit.jupiter:junit-jupiter-engine:5.12.2",
46+
"org.junit.platform:junit-platform-suite-api:1.12.2",
47+
"org.junit.platform:junit-platform-suite-engine:1.12.2",
48+
"org.junit.platform:junit-platform-console:1.12.2",
49+
],
50+
repositories = [
51+
"https://repo1.maven.org/maven2",
52+
"https://maven.fabricmc.net/",
53+
"https://maven.terraformersmc.com/",
54+
"https://maven.nucleoid.xyz/",
55+
],
56+
lock_file = "//:maven_install.json",
57+
)
58+
use_repo(maven, "maven")
59+
60+
minecraft = use_extension("//repo:minecraft_jar.bzl", "minecraft")
61+
minecraft.minecraft_jar(
62+
version = "1.21.5",
63+
type = "client",
64+
assets = True,
65+
mapping = False,
66+
)
67+
minecraft.minecraft_jar(
68+
version = "1.21.5",
69+
type = "server",
70+
mapping = False,
71+
)
72+
minecraft.exclude_library(names = ["org.ow2.asm:asm:9.6"])
73+
use_repo(minecraft, "minecraft")
74+
use_repo(minecraft, "minecraft_assets")
75+
76+
register_toolchains("//:kotlin_toolchain")

0 commit comments

Comments
 (0)