LAOP-admin/mvn17
2026-09-18 16:45:38 +08:00

31 lines
1.1 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# ============================================================
# 翼云Hub 构建包装器
# 使用 Homebrew OpenJDK 17 运行 Maven,不影响系统默认 Java 8 环境
#
# 常用命令:
# ./mvn17 compile 编译
# ./mvn17 clean package 打包
# ./mvn17 spring-boot:run 启动服务(开发模式)
# ./mvn17 test 运行测试
# ./mvn17 run 运行已打包的 jar
# ============================================================
JAVA17_HOME="/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
export JAVA_HOME="$JAVA17_HOME"
# run 子命令:直接用 Java 17 运行已打包的 jar
if [[ "$1" == "run" ]]; then
JAR=$(find "$SCRIPT_DIR/target" -name "laop-admin-*.jar" ! -name "*.original" 2>/dev/null | head -1)
if [[ -z "$JAR" ]]; then
echo "未找到 jar,请先执行:./mvn17 clean package" >&2
exit 1
fi
exec "$JAVA17_HOME/bin/java" -jar "$JAR"
fi
# 其他命令透传给 Maven Wrapper
exec "$SCRIPT_DIR/mvnw" "$@"