build: add shadow plugin and fat-jar build script
This commit is contained in:
1 parent
aade7a8d1f
commit
b78d5866a5
3 files changed
+30
-1
No files matched your search
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
独立后端项目(Ktor),仅提供商品列表接口。
|
独立后端项目(Ktor),仅提供商品列表接口。
|
||||||
|
|
||||||
## 运行
|
## 本地运行
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./gradlew run
|
./gradlew run
|
||||||
@@ -10,6 +10,24 @@
|
|||||||
|
|
||||||
默认监听:`http://localhost:8080`
|
默认监听:`http://localhost:8080`
|
||||||
|
|
||||||
|
## 打包成可执行 Fat Jar(推荐部署方式)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./scripts/build-fat-jar.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
产物示例:
|
||||||
|
|
||||||
|
```text
|
||||||
|
build/libs/kmp-mini-shopping-backend-1.0.0-all.jar
|
||||||
|
```
|
||||||
|
|
||||||
|
运行:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
java -jar build/libs/kmp-mini-shopping-backend-1.0.0-all.jar
|
||||||
|
```
|
||||||
|
|
||||||
## 接口
|
## 接口
|
||||||
|
|
||||||
- `GET /` 服务状态
|
- `GET /` 服务状态
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ plugins {
|
|||||||
kotlin("jvm") version "2.2.20"
|
kotlin("jvm") version "2.2.20"
|
||||||
application
|
application
|
||||||
kotlin("plugin.serialization") version "2.2.20"
|
kotlin("plugin.serialization") version "2.2.20"
|
||||||
|
id("com.gradleup.shadow") version "8.3.5"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "com.example.minishop"
|
group = "com.example.minishop"
|
||||||
|
|||||||
Executable
+10
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
./gradlew clean shadowJar
|
||||||
|
|
||||||
|
echo "\n✅ Build done"
|
||||||
|
ls -lh build/libs/*-all.jar
|
||||||
|
|
||||||
|
echo "\nRun with:"
|
||||||
|
echo "java -jar build/libs/$(basename $(ls build/libs/*-all.jar | head -n1))"
|
||||||
Reference in new issue
Block a user