Add SSM deployment and reliable Maven setup
This commit is contained in:
@@ -8,13 +8,21 @@ from tkinter import filedialog, messagebox, ttk
|
||||
|
||||
from .deployer import DeploymentConfig, build_deployment_plan, run_steps
|
||||
from .environment import EnvironmentCheck, check_environment, load_tool_paths, save_tool_paths
|
||||
from .installer import build_install_command, recommend_jdk_version, run_install_command
|
||||
from .installer import (
|
||||
MAVEN_VERSION,
|
||||
TOMCAT_VERSION,
|
||||
build_install_command,
|
||||
install_maven,
|
||||
install_tomcat,
|
||||
recommend_jdk_version,
|
||||
run_install_command,
|
||||
)
|
||||
from .path_manager import apply_user_environment, build_environment_update
|
||||
from .scanner import ScanResult, scan_project
|
||||
|
||||
|
||||
TEXT = {
|
||||
"title": "\u0053\u0070\u0072\u0069\u006e\u0067\u0020\u0042\u006f\u006f\u0074\u0020\u002b\u0020\u0056\u0075\u0065\u0020\u81ea\u52a8\u5316\u90e8\u7f72\u5de5\u5177",
|
||||
"title": "Spring Boot / SSM + Vue 自动化部署工具",
|
||||
"workbench": "\u90e8\u7f72\u5de5\u4f5c\u53f0",
|
||||
"select_dir": "\u9009\u62e9\u76ee\u5f55",
|
||||
"scan": "\u626b\u63cf\u9879\u76ee",
|
||||
@@ -54,7 +62,7 @@ class DeployWorkbench(tk.Tk):
|
||||
self.tool_paths = load_tool_paths()
|
||||
self.tool_path_vars: dict[str, tk.StringVar] = {
|
||||
name: tk.StringVar(value=str(self.tool_paths.get(name, "")))
|
||||
for name in ("MySQL", "JDK", "Maven", "Gradle", "Node.js", "npm", "Git")
|
||||
for name in ("MySQL", "JDK", "Maven", "Tomcat", "Gradle", "Node.js", "npm", "Git")
|
||||
}
|
||||
|
||||
self.scan_result: ScanResult | None = None
|
||||
@@ -124,7 +132,7 @@ class DeployWorkbench(tk.Tk):
|
||||
self._build_logs(content)
|
||||
|
||||
def _build_header(self, parent: ttk.Frame) -> None:
|
||||
ttk.Label(parent, text="Spring Boot + Vue 自动化部署", style="Title.TLabel").pack(anchor=tk.W)
|
||||
ttk.Label(parent, text="Spring Boot / SSM + Vue 自动化部署", style="Title.TLabel").pack(anchor=tk.W)
|
||||
action_bar = ttk.Frame(parent)
|
||||
action_bar.pack(fill=tk.X, pady=(14, 16))
|
||||
self.project_dir_entry = ttk.Entry(action_bar, textvariable=self.project_dir)
|
||||
@@ -237,7 +245,7 @@ class DeployWorkbench(tk.Tk):
|
||||
ttk.Button(jdk_row, text="\u52a0\u5165 PATH", command=lambda: self.add_tool_to_path("JDK")).pack(side=tk.LEFT, padx=(8, 0))
|
||||
ttk.Label(jdk_row, textvariable=self.jdk_reason, style="Muted.TLabel").pack(side=tk.LEFT, fill=tk.X, expand=True, padx=(10, 0))
|
||||
|
||||
for name in ("Maven", "Gradle", "Node.js", "Git", "MySQL"):
|
||||
for name in ("Maven", "Tomcat", "Gradle", "Node.js", "Git", "MySQL"):
|
||||
row = ttk.Frame(panel, style="Panel.TFrame")
|
||||
row.pack(fill=tk.X, pady=5)
|
||||
ttk.Label(row, text=name, width=12, style="CardTitle.TLabel").pack(side=tk.LEFT)
|
||||
@@ -347,6 +355,12 @@ class DeployWorkbench(tk.Tk):
|
||||
threading.Thread(target=lambda: self.ui_queue.put(("install_done", ("JDK", run_install_command(command, self._thread_log)))), daemon=True).start()
|
||||
|
||||
def install_tool_async(self, tool_name: str) -> None:
|
||||
if tool_name == "Maven":
|
||||
self.install_maven_async()
|
||||
return
|
||||
if tool_name == "Tomcat":
|
||||
self.install_tomcat_async()
|
||||
return
|
||||
try:
|
||||
command = build_install_command(tool_name)
|
||||
except ValueError as exc:
|
||||
@@ -365,6 +379,42 @@ class DeployWorkbench(tk.Tk):
|
||||
daemon=True,
|
||||
).start()
|
||||
|
||||
def install_maven_async(self) -> None:
|
||||
if not messagebox.askyesno(
|
||||
"确认安装 Maven",
|
||||
f"将从 Apache 官方地址下载 Maven {MAVEN_VERSION},校验安装包后解压到当前用户目录。\n\n"
|
||||
"安装完成后会自动保存 mvn.cmd 路径。是否继续?",
|
||||
):
|
||||
return
|
||||
self._append_log(f"开始安装 Maven {MAVEN_VERSION}...")
|
||||
threading.Thread(target=self._install_maven_worker, daemon=True).start()
|
||||
|
||||
def _install_maven_worker(self) -> None:
|
||||
try:
|
||||
executable = install_maven(self._thread_log)
|
||||
except Exception as exc:
|
||||
self.ui_queue.put(("maven_install_done", (None, str(exc))))
|
||||
return
|
||||
self.ui_queue.put(("maven_install_done", (executable, "")))
|
||||
|
||||
def install_tomcat_async(self) -> None:
|
||||
if not messagebox.askyesno(
|
||||
"确认安装 Tomcat",
|
||||
f"将从 Apache 官方地址下载 Tomcat {TOMCAT_VERSION},校验安装包后解压到当前用户目录。\n\n"
|
||||
"Tomcat 9 适用于常见的 Java 8 / javax.servlet SSM 项目。是否继续?",
|
||||
):
|
||||
return
|
||||
self._append_log(f"开始安装 Tomcat {TOMCAT_VERSION}...")
|
||||
threading.Thread(target=self._install_tomcat_worker, daemon=True).start()
|
||||
|
||||
def _install_tomcat_worker(self) -> None:
|
||||
try:
|
||||
executable = install_tomcat(self._thread_log)
|
||||
except Exception as exc:
|
||||
self.ui_queue.put(("tomcat_install_done", (None, str(exc))))
|
||||
return
|
||||
self.ui_queue.put(("tomcat_install_done", (executable, "")))
|
||||
|
||||
def add_tool_to_path(self, tool_name: str) -> None:
|
||||
result = self._find_environment_result(tool_name)
|
||||
executable = Path(result.command[0]) if result and Path(result.command[0]).exists() else None
|
||||
@@ -539,6 +589,28 @@ class DeployWorkbench(tk.Tk):
|
||||
self._append_log(f"{tool_name} 安装命令结束,退出码: {exit_code}")
|
||||
self.check_environment_async()
|
||||
self.after(1800, lambda name=tool_name: self._prompt_add_tool_after_install(name))
|
||||
elif event == "maven_install_done":
|
||||
executable, error = payload # type: ignore[misc]
|
||||
if error:
|
||||
self._append_log(f"Maven 安装失败: {error}")
|
||||
messagebox.showerror("Maven 安装失败", str(error))
|
||||
continue
|
||||
self.tool_path_vars["Maven"].set(str(executable))
|
||||
self.save_tool_path_settings(silent=True)
|
||||
self._append_log(f"Maven 路径已保存: {executable}")
|
||||
self.check_environment_async()
|
||||
self.after(1800, lambda: self._prompt_add_tool_after_install("Maven"))
|
||||
elif event == "tomcat_install_done":
|
||||
executable, error = payload # type: ignore[misc]
|
||||
if error:
|
||||
self._append_log(f"Tomcat 安装失败: {error}")
|
||||
messagebox.showerror("Tomcat 安装失败", str(error))
|
||||
continue
|
||||
self.tool_path_vars["Tomcat"].set(str(executable))
|
||||
self.save_tool_path_settings(silent=True)
|
||||
self._append_log(f"Tomcat 路径已保存: {executable}")
|
||||
self.check_environment_async()
|
||||
self.after(1800, lambda: self._prompt_add_tool_after_install("Tomcat"))
|
||||
self.after(120, self._drain_queue)
|
||||
|
||||
def _prompt_add_tool_after_install(self, tool_name: str) -> None:
|
||||
|
||||
Reference in New Issue
Block a user