Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fast jar build support #458

Merged
merged 4 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/ikaros_ci_build_fastjar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This is a basic workflow to help you get started with Actions

name: ikaros_ci_build_fastjar

# Controls when the workflow will run
on:
release:
types: [published]

jobs:

release:
if: github.repository == 'ikaros-dev/ikaros'
name: Build with java 17 and upload
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Git submodule init
uses: snickerbockers/submodules-init@v4
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'temurin'
cache: 'gradle'
java-version: 17
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Clean with gradle
run: |
./gradlew clean
- name: Build console with npm
run: |
./gradlew buildFrontend -x test
- name: Build server with gradle
run: |
./gradlew build -x test
- name: Build server fast jar
run: |
./gradlew bootJar -x test
- name: Upload fast jar to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.LI_GUOHAO_TOKEN }}
file: /home/runner/work/ikaros/ikaros/server/build/libs/*.jar
asset_name: ikaros-server.jar




36 changes: 35 additions & 1 deletion BUILD.MD
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
- Vue: 3
- IDE: IntelliJ IDEA

您可以通过`git`拉取代码库
```shell
git clone https://github.com/ikaros-dev/ikaros.git
cd ikaros
```

拉取代码后需要进行
git module 初始化

Expand Down Expand Up @@ -56,7 +62,7 @@ commit之前,用checkstyle检查下代码,确认没有问题后再commit。
编译打包,告警可以忽视

```text
.\gradlew.bat clean bootJar
.\gradlew.bat clean bootJar -x test
```

## 代码格式化
Expand All @@ -80,6 +86,34 @@ commit之前,用checkstyle检查下代码,确认没有问题后再commit。
4. 选择项目目录 `config/checkstyle` 下的 配置文件`checkstyle.xml` 保存导入
5. 保存设置

## Fast Jar
需要有`Java17`的运行环境

请先按照上放先进行`build`

打`Fast Jar`包,在项目根目录运行下方命令
```shell
# linux
./gradlew clean bootJar -x test
# windows
./gradlew.bat clean bootJar -x test
```
打包后的文件在`server/build/libs/`目录下

下方`version`代表当前打包的版本


在打包文件所在目录,`Linux` 运行
```shell
java -jar ./server-{version}.jar
```

在打包文件所在目录,`Windwos` 运行,
需要加上额外参数`--spring.profiles.active=win`
```shell
java -jar --spring.profiles.active=win ./server-{version}.jar
```

# 更多
WIP
<https://docs.ikaros.run>
6 changes: 6 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

更新日志文档,版本顺序从新到旧,最新版本在最前(上)面。

# 0.7.6

## 编译

- Fast Jar 打包支持 #454

# 0.7.5

## 新功能
Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./

ENV JVM_OPTS="-Xmx256m -Xms256m" \
IKAROS_WORK_DIR="/root/.ikaros" \
SPRING_CONFIG_LOCATION="optional:classpath:/;optional:file:/root/.ikaros/" \
TZ=Asia/Shanghai

Expand Down
29 changes: 15 additions & 14 deletions server/src/main/java/run/ikaros/server/config/WebFluxConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@
import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;

import java.io.File;
import java.io.FileNotFoundException;
import java.net.URI;
import java.time.Duration;
import java.util.List;
import java.util.Objects;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.CacheControl;
import org.springframework.http.codec.CodecConfigurer;
import org.springframework.http.codec.HttpMessageWriter;
import org.springframework.lang.NonNull;
import org.springframework.util.ResourceUtils;
import org.springframework.web.reactive.config.ResourceHandlerRegistry;
import org.springframework.web.reactive.config.WebFluxConfigurer;
import org.springframework.web.reactive.function.BodyInserters;
Expand Down Expand Up @@ -137,16 +133,21 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {

// Register theme static files path
// /theme/{name}/static => classpath:/templates/theme/{name}/static/
try {
File themeRootDir = ResourceUtils.getFile("classpath:templates/theme");
for (File themeDir : Objects.requireNonNull(themeRootDir.listFiles())) {
String theme = themeDir.getName();
registry.addResourceHandler("/theme/" + theme + "/static/**")
.addResourceLocations("classpath:/templates/theme/" + theme + "/static/");
}
} catch (FileNotFoundException e) {
throw new RuntimeException("Not exists theme dir in classpath.", e);
}
// try {
// InputStream resourceAsStream = Thread.currentThread().getContextClassLoader()
// .getResourceAsStream("classpath:templates/theme");
// File themeRootDir = ResourceUtils.getFile("classpath:templates/theme");
// for (File themeDir : Objects.requireNonNull(themeRootDir.listFiles())) {
// String theme = themeDir.getName();
// registry.addResourceHandler("/theme/" + theme + "/static/**")
// .addResourceLocations("classpath:/templates/theme/" + theme + "/static/");
// }
// } catch (FileNotFoundException e) {
// throw new RuntimeException("Not exists theme dir in classpath.", e);
// }
// /theme/simple/static => classpath:/templates/theme/simple/static/
registry.addResourceHandler("/theme/simple/static")
.addResourceLocations("classpath:/templates/theme/simple/static/");

}
}
Loading