Skip to content

Commit

Permalink
build: add bazel support (#49)
Browse files Browse the repository at this point in the history
* build: add bazel support

* ci: typo fix

* build: remove useless deps

* build: add bazelrc file

* ci: bazel java language version 11

* feat: add bazel support
  • Loading branch information
damingerdai authored Oct 27, 2022
1 parent 7cdc01d commit fe45cc2
Show file tree
Hide file tree
Showing 70 changed files with 608 additions and 1 deletion.
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build --java_language_version=17
2 changes: 2 additions & 0 deletions .bazelrc.back
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build --define=ABSOLUTE_JAVABASE='C:\Program Files\Java\jdk-17'
server --server_javabase='C:\Program Files\Java\jdk-17'
25 changes: 25 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,28 @@ jobs:
run: cd ./src/main/react && yarn && yarn build
- name: Build with Gradle
run: ./gradlew build -x test
build-bazel:
needs: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
java-version: [ 17 ]
node-version: [ 16 ]
os: [ ubuntu-latest ]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: ${{ matrix.java-version }}
- name: Install yarn
run: npm install -g yarn
- name: Build with vite
run: cd ./src/main/react && yarn && yarn build
- name: Build with bazel
run: bazel build //:java-maven
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,10 @@ build/
### Others ###
out/
src/main/resources/static
logs
logs

### Bazel ###
bazel-bin
bazel-jobs
bazel-out
bazel-testlogs
78 changes: 78 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
load("@rules_java//java:defs.bzl", "java_binary", "java_library", "java_test")

package(default_visibility = ["//visibility:public"])

java_library(
name = "java-maven-lib",
srcs = glob([
"src/main/java/org/daming/jobs/api/advice/*.java",
"src/main/java/org/daming/jobs/api/controller/*.java",
"src/main/java/org/daming/jobs/api/interceptor/*.java",
"src/main/java/org/daming/jobs/base/*.java",
"src/main/java/org/daming/jobs/base/**/*.java",
"src/main/java/org/daming/jobs/config/**/*.java",
"src/main/java/org/daming/jobs/pojo/**/*.java",
"src/main/java/org/daming/jobs/security/**/*.java",
"src/main/java/org/daming/jobs/service/**/*.java",
"src/main/java/org/daming/jobs/task/**/*.java",
]),
resources = glob(["src/main/resources/**"]),
deps = [
"@maven//:org_springframework_boot_spring_boot_starter_web",
"@maven//:org_springframework_boot_spring_boot_starter_jdbc",
"@maven//:org_springframework_boot_spring_boot_starter_quartz",
"@maven//:org_springframework_boot_spring_boot_starter_aop",

"@maven//:io_springfox_springfox_boot_starter",
"@maven//:io_springfox_springfox_core",
"@maven//:io_springfox_springfox_spi",
"@maven//:io_springfox_springfox_spring_web",
"@maven//:io_swagger_swagger_annotations",

"@maven//:com_auth0_java_jwt",
"@maven//:org_postgresql_postgresql",
"@maven//:org_springframework_boot_spring_boot_devtools",

"@maven//:org_springframework_boot_spring_boot",
"@maven//:org_springframework_boot_spring_boot_autoconfigure",
"@maven//:org_springframework_spring_aop",
"@maven//:org_springframework_spring_beans",
"@maven//:org_springframework_spring_core",
"@maven//:org_springframework_spring_context",
"@maven//:org_springframework_spring_web",

"@maven//:org_apache_shiro_shiro_spring_boot_starter",
"@maven//:org_apache_shiro_shiro_core",
"@maven//:org_apache_shiro_shiro_spring",
"@maven//:org_apache_shiro_shiro_web",

"@maven//:org_slf4j_slf4j_api",

"@maven//:org_quartz_scheduler_quartz",

"@maven//:org_aspectj_aspectjweaver",

"@maven//:org_apache_tomcat_embed_tomcat_embed_core",
"@maven//:jakarta_annotation_jakarta_annotation_api",
"@maven//:jakarta_xml_bind_jakarta_xml_bind_api",
"@maven//:com_fasterxml_jackson_core_jackson_core",
"@maven//:com_fasterxml_jackson_core_jackson_databind"
],
)

java_binary(
name = "java-maven",
main_class = "org.daming.jobs.JobsApplication",
runtime_deps = [":java-maven-lib"],
)

# java_test(
# name = "tests",
# srcs = glob(["src/test/java/com/example/myproject/*.java"]),
# test_class = "com.example.myproject.TestApp",
# deps = [
# ":java-maven-lib",
# "@maven//:com_google_guava_guava",
# "@maven//:junit_junit",
# ],
# )
51 changes: 51 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

RULES_JVM_EXTERNAL_TAG = "4.2"
RULES_JVM_EXTERNAL_SHA = "cd1a77b7b02e8e008439ca76fd34f5b07aecb8c752961f9640dea15e9e5ba1ca"

http_archive(
name = "rules_jvm_external",
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
sha256 = RULES_JVM_EXTERNAL_SHA,
urls = [
"https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
"https://ghproxy.com/https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
]

)

load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")

rules_jvm_external_deps()

load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")

# rules_jvm_external_setup()

load("@rules_jvm_external//:defs.bzl", "maven_install")

maven_install(
artifacts = [
"org.springframework.boot:spring-boot-starter-web:2.7.2",
"org.springframework.boot:spring-boot-starter-jdbc:2.7.2",
"org.springframework.boot:spring-boot-starter-quartz:2.7.2",
"org.springframework.boot:spring-boot-starter-aop:2.7.2",

"io.springfox:springfox-boot-starter:3.0.0",
"org.apache.shiro:shiro-spring-boot-starter:1.9.1",
"com.auth0:java-jwt:3.18.2",
"org.postgresql:postgresql:42.4.0",

"org.springframework.boot:spring-boot-devtools:2.7.2",
"org.springframework.boot:spring-boot-starter-test:2.7.2"

],
fetch_sources = True,
repositories = [
"https://maven.aliyun.com/repository/public/",
"https://maven.aliyun.com/nexus/content/groups/public/",
"http://uk.maven.org/maven2",
"https://maven.google.com",
"https://repo1.maven.org/maven2",
],
)
48 changes: 48 additions & 0 deletions bin/main/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
server:
port: 8443


#application-description: @project.description@
#
#application-version: @project.version@

spring:
output:
ansi:
enabled: always
quartz:
properties:
org:
quartz:
scheduler:
instanceName: clusteredScheduler
instanceId: AUTO
jobStore:
class: org.springframework.scheduling.quartz.LocalDataSourceJobStore
driverDelegateClass: org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
tablePrefix: QRTZ_
isClustered: true
clusterCheckinInterval: 10000
useProperties: false
threadPool:
class: org.quartz.simpl.SimpleThreadPool
threadCount: 10
threadPriority: 5
threadsInheritContextClassLoaderOfInitializingThread: true
job-store-type: jdbc
datasource:
url: jdbc:postgresql://127.0.0.1:5432/postgres
username: postgres
password: 123456
driver-class-name: org.postgresql.Driver
flyway:
baseline-on-migrate: true
mvc:
pathmatch:
matching-strategy: ant_path_matcher

#TOKEN_TTL
token:
ttl:
accessTokenTTL: 7200000
refreshTokenTTL: 28800000
27 changes: 27 additions & 0 deletions bin/main/banner.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
${AnsiColor.BRIGHT_YELLOW}
////////////////////////////////////////////////////////////////////
// _ooOoo_ //
// o8888888o //
// 88" . "88 //
// (| ^_^ |) //
// O\ = /O //
// ____/`---'\____ //
// .' \\| |// `. //
// / \\||| : |||// \ //
// / _||||| -:- |||||- \ //
// | | \\\ - /// | | //
// | \_| ''\---/'' | | //
// \ .-\__ `-` ___/-. / //
// ___`. .' /--.--\ `. . ___ //
// ."" '< `.___\_<|>_/___.' >'"". //
// | | : `- \`.;`\ _ /`;.`/ - ` : | | //
// \ \ `-. \_ __\ /__ _/ .-` / / //
// ========`-.____`-.___\_____/___.-`____.-'======== //
// `=---=' //
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //
// 佛祖保佑 永不宕机 永无BUG //
////////////////////////////////////////////////////////////////////
${AnsiColor.BRIGHT_RED}
Application Name: ${application.title}
Application Version: ${application.version}${application.formatted-version}
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
Loading

0 comments on commit fe45cc2

Please sign in to comment.