Skip to content

Commit

Permalink
Merge pull request #166 from MaaAssistantArknights/dev
Browse files Browse the repository at this point in the history
release: 上线 kt 版本
  • Loading branch information
dragove authored Mar 2, 2024
2 parents 476402f + 745605b commit aa45cb9
Show file tree
Hide file tree
Showing 319 changed files with 8,456 additions and 8,260 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }} # checkout the correct branch name
fetch-depth: 0 # fetch the whole repo history
Expand All @@ -39,10 +39,10 @@ jobs:
major-identifier: "breaking:"
minor-identifier: "feature:"

- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17
distribution: temurin
java-version: 21

# - name: Startup Mongodb
# uses: supercharge/[email protected]
Expand All @@ -52,11 +52,11 @@ jobs:

- name: Remove aliyun maven mirror
run: |
sed -i '/maven {/,+2d' build.gradle
sed -i '/maven(url/d' build.gradle.kts
- name: Set versions
run: |
sed -i "s/^version.*$/version '${{ steps.version.outputs.version }}'/g" build.gradle
sed -i "s/^version.*$/version = \"${{ steps.version.outputs.version }}\"/g" build.gradle.kts
sed -i 's/"packageVersion.*,/"packageVersion": "${{ steps.version.outputs.version }}",/g' client-config/cpp.json
sed -i 's/"packageVersion.*,/"packageVersion": "${{ steps.version.outputs.version }}",/g' client-config/csharp-netcore.json
sed -i 's/"packageVersion.*,/"packageVersion": "${{ steps.version.outputs.version }}",/g' client-config/rust.json
Expand All @@ -71,31 +71,31 @@ jobs:
run: ./gradlew generateSwaggerCode

- name: upload openapi
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: openapi-${{ steps.version.outputs.version }}
path: ./build/docs/swagger.json

- name: upload cpp client
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: cpp-client
path: ./build/clients/cpp-client/*

- name: upload csharp client
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: csharp-client
path: ./build/clients/csharp-client/*

- name: upload rust client
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: rust-client
path: ./build/clients/rust-client/*

- name: upload ts client
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ts-client
path: ./build/clients/ts-fetch-client/*
21 changes: 11 additions & 10 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }} # checkout the correct branch name
fetch-depth: 0 # fetch the whole repo history
Expand All @@ -42,48 +42,49 @@ jobs:
export TRUNCATED_GITHUB_SHA=$(echo ${{ github.sha }} | cut -c1-7);
echo "VERSION_TAG=${GITHUB_REF/refs\/heads\//}-${TRUNCATED_GITHUB_SHA}" >> $GITHUB_ENV
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17
distribution: temurin
java-version: 21

- name: Remove aliyun maven mirror
run: |
sed -i '/maven {/,+2d' build.gradle
sed -i '/maven(url/d' build.gradle.kts
- name: Set Java version
run: |
sed -i "s/^version.*$/version '${{ steps.version.outputs.version }}'/g" build.gradle
sed -i "s/^version.*$/version = \"${{ steps.version.outputs.version }}\"/g" build.gradle.kts
- name: Build jar
run: ./gradlew bootJar

- name: Upload jar
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: jar
path: ./build/libs/*

- name: Log in to the Container registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=dev,enable=${{ github.ref == format('refs/heads/{0}', 'dev') }}
type=raw,value={{branch}}-{{sha}}
- name: Build and push Docker image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
push: true
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,33 @@ jobs:
runs-on: ubuntu-latest
steps:
#checkout代码
- uses: actions/checkout@v3
- uses: actions/checkout@v4
#安装graalvm
- name: 安装graalvm
uses: graalvm/setup-graalvm@v1
with:
version: 'latest'
java-version: '17'
components: 'native-image'
java-version: '21'
#查看版本信息
- name: 查看版本信息
run: |
echo "GRAALVM_HOME: $GRAALVM_HOME"
echo "JAVA_HOME: $JAVA_HOME"
java --version
gu --version
native-image --version
#校验Gradle wrapper
- name: 校验Gradle wrapper
uses: gradle/wrapper-validation-action@v1
uses: gradle/wrapper-validation-action@v2
#使用Gradle编译项目
- name: 使用Gradle编译项目
uses: gradle/gradle-build-action@v2
uses: gradle/gradle-build-action@v3
with:
arguments: bootBuildImage

# 登录docker仓库
- name: 登录docker仓库 ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM amazoncorretto:17-alpine as runner
FROM amazoncorretto:21-alpine as runner
WORKDIR /app
COPY ./build/libs/MaaBackendCenter*.jar /MaaBackendCenter.jar
COPY ./build/libs/MaaBackendCenter*.jar /app/app.jar
EXPOSE 7000-9000
ENTRYPOINT ["java", "-jar", "/MaaBackendCenter.jar"]
ENTRYPOINT ["java", "-jar", "app.jar", "${JAVA_OPTS}"]
39 changes: 19 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,41 @@
# MaaBackendCenter

使用 Java 重写的 MAA 作业服务器后端
使用 Kotlin(Java) 重写的 MAA 作业服务器后端

## 开发技术栈

- Java 17
- kotlin 1.9 (Java 21)
- SpringBoot 3
- spring-security
- springdoc-openapi
- MongoDB
- Redis

## 本地开发指南

1. 下载安装 jdk 17 或者以上版本的 jdk,可以考虑从 [zuluJDK](https://www.azul.com/downloads/?version=java-17-lts&package=jdk) 或者 [libreicaJDK](https://bell-sw.com/pages/downloads/#/java-17-lts) 下载安装
2. 你需要一个有redis和mongoDB的环境,如果你是windows用户,可以从 https://github.com/tporadowski/redis 中下载版本较旧的 redis 使用
3. 使用你喜欢的 IDE 导入此项目,修改 /src/main/resources/application-template.yml 中的数据库配置以符合你自己配置的环境
4. 运行 MainApplication 类里的 main 方法
5. 首次运行建议修改 ArkLevelSyncTask 类的scheduled注解的参数,这样可以将明日方舟中的关卡数据同步到你本地的 mongodb 中,为了防止反复调用造成调试的麻烦,建议首次运行同步成功后再将代码修改回去
1. 使用你喜欢的 IDE 导入此项目,修改 /src/main/resources/application-template.yml 中的数据库配置以符合你自己配置的环境
2. 下载安装 JDK 21 或者以上版本的 jdk,可以考虑从 [zuluJDK](https://www.azul.com/downloads/?version=java-17-lts&package=jdk) 或者 [libreicaJDK](https://bell-sw.com/pages/downloads/#/java-17-lts) 下载安装。 Jetbrains Idea 可以使用自带的 JDK 管理器进行下载。
3. 你需要一个有redis和mongoDB的环境,如果你是windows用户,可以从 https://github.com/tporadowski/redis 中下载版本较旧的 redis 使用。 您也可以直接使用 `./dev-docker/docker-compose.yml` 来启动 docker 服务。
4. 运行 `./gradlew bootRun`, windows 环境为 `./gradlew.bat bootRun`
5. 首次运行建议修改 ArkLevelSyncTask 类的 scheduled 注解的参数,这样可以将明日方舟中的关卡数据同步到你本地的 mongodb 中,为了防止反复调用造成调试的麻烦,建议首次运行同步成功后再将代码修改回去

## 项目结构

- config 存放spring配置
- controller 交互层
- request 入参类型
- response 响应类型
- repository 数据仓库层,用于和数据库交互
- entity 与数据库字段对应的类型
- service 业务处理层,复杂或者公用逻辑放在这里(注:您无需为每个类型都提供对应接口,只有当接口在可见未来有多个实现的时候才考虑建立接口)
- model 应用内传输用类型放这里
- utils 工具类
- config # 存放 spring 配置
- common # 共享的逻辑
- controller # 交互层
- request # 入参类型
- response # 响应类型
- repository # 数据仓库层,用于和数据库交互
- entity # 与数据库字段对应的类型
- service # 业务处理层,复杂或者公用逻辑放在这里(注:您无需为每个类型都提供对应接口,只有当接口在可见未来有多个实现的时候才考虑建立接口)
- model # 应用内传输用类型放这里

## 编译与部署

1. 安装 jdk17,可以考虑从 [zuluJDK](https://www.azul.com/downloads/?version=java-17-lts&package=jdk) 或者 [libreicaJDK](https://bell-sw.com/pages/downloads/#/java-17-lts) 下载
1. 安装 JDK 21,可以考虑从 [zuluJDK](https://www.azul.com/downloads/?version=java-17-lts&package=jdk) 或者 [libreicaJDK](https://bell-sw.com/pages/downloads/#/java-17-lts) 下载
2. clone 此项目 `git clone https://github.com/MaaAssistantArknights/MaaBackendCenter.git`
3. 进入此项目目录 `cd MaaBackendCenter`
4. 编译项目 `./gradlew bootJar -x processAot`windows环境下请使用 `gradlew.bat bootJar -x processAot`
4. 编译项目 `./gradlew bootJar -x processAot`windows 环境下请使用 `gradlew.bat bootJar -x processAot`
5. 获得编译后的 jar 文件 `cp ./build/libs/MaaBackendCenter-1.0-SNAPSHOT.jar .`
6. 复制一份配置文件 `cp ./build/resources/main/application-template.yml ./application-prod.yml`
7. 修改配置文件 `application-prod.yml`
Expand All @@ -45,7 +44,7 @@
## native 编译(暂时废弃,如果希望协助维护,请查看native分支)

1. 安装 [GraalVM](https://github.com/graalvm/graalvm-ce-builds/releases)
Java17,并配置好环境变量,部分功能需要正确配置 `JAVA_HOME` 变量为 GraalVM 安装目录才能正常使用
Java21,并配置好环境变量,部分功能需要正确配置 `JAVA_HOME` 变量为 GraalVM 安装目录才能正常使用
2. 如果您处于 Windows 环境下,需要安装 `Visual Studio` 并且安装 C++ 组件,Linux 环境下则需要安装 `gcc` 工具链,Mac
下需要安装 `xcode`
工具链,详情查看 [native-image#prerequisites](https://www.graalvm.org/22.3/reference-manual/native-image/#prerequisites)
Expand Down
129 changes: 0 additions & 129 deletions build.gradle

This file was deleted.

Loading

0 comments on commit aa45cb9

Please sign in to comment.