Repository navigation
feat(maven): Spring Boot 和 Java 应用出现在运行配置里,可运行、可调试 - #28
Merged
Merged
Conversation
The model now lists Spring Boot applications (@SpringBootApplication classes, or spring-boot-maven-plugin) and applications whose main class exec-maven-plugin or the jar manifest names as targets tagged spring-boot / java-application with a mainClass property. Reading stays compile-free: only source heads and POM configuration are read, within fixed bounds. With -Dlithe.runOutput and -Dlithe.runProject the extension writes, after the build, the project's runtime classpath (output folder plus compile, runtime and system dependencies, reactor siblings from their output folders) and the compiled classes with a main method, marking the @SpringBootApplication ones. A failed build writes nothing. Refs 1lck/Lithe-IDEA#2074 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
plugin.json declares a build provider process (lib/lithe-maven-provider.jar, built with the vendored Java SDK for Java 8) and two provider runs: spring-boot (service, debuggable through a registry java adapter) and application. prepareRun compiles the project with -pl -am process-classes using the Maven Lithe resolved (or mvnw, MAVEN_HOME, PATH), reads the run document the extension wrote and returns java -cp <classpath> <main class> on the project's JDK. Long classpaths go into a manifest-only jar under target/lithe-run/. A debug request adds a suspending JDWP agent on the host's port. Refs 1lck/Lithe-IDEA#2074 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… runs The fixture gains a Spring Boot service module (a local stand-in for the annotation, no download) and a jar-manifest main class in app. The integration lane checks the targets, then starts the packaged provider, prepares runs and launches the returned commands, and checks the reactor classpath, main class discovery, debug arguments and a failed build. README and the feature matrix describe the new maven-run-applications capability. Refs 1lck/Lithe-IDEA#2074 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 17, 2026
…ost that supports it - TestOfficialMavenPluginRunsASpringBootApplication installs the Maven and Java Support archives, saves JVM/program arguments and an environment variable in the run configuration editor, runs ShopApplication, checks /hello and the console, then stops it. - The archive helper wires the tool resolvers like the app and can install several plugins into one service; run console output is read from the operation's session. - lithe-host.json pins 75edb9674 (1lck/Lithe-IDEA#2102) and requires LITHE_TEST_JAVA_PLUGIN_ARCHIVE. - README and feature matrix: debugging waits for host support (1lck/Lithe-IDEA#2107). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dows Java starts a command without a directory through the operating system, which on Windows finds only .exe files, so `mvn` (mvn.cmd there) failed to start and the preparation ended as "The plugin backend failed unexpectedly". The provider now resolves such a name on the PATH of the build environment, trying each PATHEXT extension on Windows, and reports maven.run.noMaven when nothing matches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1lck
marked this pull request as ready for review
November 17, 2026 13:03
1 task done
This was referenced Nov 18, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue / Linked issue
Refs 1lck/Lithe-IDEA#2074(Maven / Spring Boot 项目的标题栏下拉里没有运行配置)。宿主配套 1lck/Lithe-IDEA#2102:没有运行配置时说明原因,把宿主解析出的 Maven 路径作为
tool.executable发给本插件的提供者,并修好真实端到端测试暴露的 4 个宿主缺陷(依赖树按dependencies.source读取、命令模型的设置页、未命名运行项的名称、运行准备期间的编译输出)。PR 类型 / Type
改动说明 / What changes
根因:插件以前只声明了模型、任务、测试和依赖,没有
buildSystems[].run,模型里也没有 target,所以 Core 生成不出任何运行配置,下拉一直是“没有运行配置”。本 PR 只用 Core 现有契约(buildProviders0、providerrun、lithe/build/prepareRun、注册表连接调试),不改宿主或 Core。1. 模型里导出可运行的应用(
extension/.../Applications.java、ModelExport)mainClass@SpringBootApplication的顶层 Java 类(每个一条,和 IDEA 一样)spring-bootspring-boot-maven-plugin的模块(Kotlin、生成代码)spring-bootmainClass或start-class,都没有就留空exec-maven-plugin的mainClass或maven-jar-plugin的archive/manifest/mainClassjava-application只读源码开头 64 KiB(去掉注释后匹配注解)和 POM 配置,每个项目最多 20 000 个文件,不编译,读取模型仍然不生成
target/。${…}没解析出来的值不当作类名。2. 运行准备导出(
extension/.../RunExport.java、LitheLifecycleParticipant.afterSessionEnd)带
-Dlithe.runOutput/-Dlithe.runProject时,扩展在构建结束后写出:运行时类路径(模块输出目录 + compile/runtime/system 依赖,用ProjectDependenciesResolver解析;反应堆兄弟模块用各自的target/classes,不需要install)和编译出的主类(读 class 文件常量池和方法表,找public static void main(String[]),标出带@SpringBootApplication的类,最多读 50 000 个 class 文件)。构建失败时不写。project(session, path)从DependencyExport移到ModelExport共用。3. 构建提供者(
provider/,打包为lib/lithe-maven-provider.jar)用随仓库的 Java SDK、按 Java 8 编译,只处理
lithe/build/prepareRun:tool.executable(即用户设置的 Maven executable),没有时按mvnw→MAVEN_HOME→mvn查找。没有目录的命令名在启动前按PATH解析,Windows 上按PATHEXT补扩展名:Java 在 Windows 上直接启动裸命令名时只认.exe,mvn(实为mvn.cmd)会启动失败并被报成“插件后端意外失败”——这是本 PR 先前 Windows CI(runner Maven 那一格)失败的原因。找不到时报maven.run.noMaven,提示安装或填写完整路径。mvn -B -ntp <构建选项参数> -Dmaven.ext.class.path=<包内扩展> -Dlithe.runOutput=<临时文件> -Dlithe.runProject=./<模块> -pl ./<模块> -am process-classes;环境变量是进程环境加构建选项(如JAVA_HOME)。输出按 64 KiB 分块作为进度流到运行窗口,取消时由 SDK 结束整个进程树。launchOptions.entrypoint)→ target 的mainClass→ 编译结果里唯一的主类(Spring Boot target 优先带注解的类)。没有或有多个时报错,错误里列出候选,并提示在运行配置的“入口”里填。{executable: toolchain java, arguments: JVM 参数 + -cp <类路径> + 主类 + 程序参数 + 用户参数, workingDirectory: 配置的目录或模块路径, environment: 配置的环境变量},由 Lithe 用项目的 JDK 启动并管理进程。不经过spring-boot:run,Lithe 停止的就是应用本身。target/lithe-run/classpath-<哈希>.jar(只含清单,和 IDEA 的 “JAR manifest” 缩短方式一样),避开 Windows 32 767 字符的命令行上限;这是构建输出,mvn clean会删,相同类路径复用同一个 jar,先写临时文件再原子改名。launchOptions.debug的连接目标时,在-cp前加-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=<host>:<port>,服务停在启动处,等宿主选中的 Java 调试器连上;目标不是合法的本地端口时拒绝。initialize的locale选中文或英文(Messages)。4.
plugin.jsonrequires加buildProviders: 0,权限加languageServer.launch(契约要求提供者进程持有这项权限)。buildSystems[0].provider:runtime/java≥ 8 /lib/lithe-maven-provider.jar/-Xms16m -Xmx96m,executesProjectCode、mayUseNetwork都为 true(编译会执行 POM 里的插件、可能下载依赖),Lithe 会先确认工作区可信。buildSystems[0].run:spring-boot(fromTargets.tags: [spring-boot],execution: service,debug.configurationType: java)和application(fromTargets.tags: [java-application],execution: application)。5. 打包:
scripts/package.mjs把两个 javac 构建的进程合成同一个backendJar(),产出lib/lithe-maven-settings.jar和lib/lithe-maven-provider.jar;.gitignore加provider/target/。6. 测试夹具与集成测试
service模块:依赖core,带一个本地的SpringBootApplication替身注解(不联网下载 Spring),ServiceApplication输出 JVM 属性、参数和环境变量。app的 jar 清单写明demo.app.Main。scripts/test.mjs新增:target 列表与run声明一致;启动打包后的提供者,对service准备运行并真正执行返回的命令,检查输出里的-Dgreeting=hi there、--port=0,typed和LITHE_FIXTURE=set,类路径首项是service/target/classes、含反应堆兄弟模块core/target/classes、不含 junit;app不给mainClass时用编译出的唯一主类并运行;调试参数在-cp之前;制造编译错误后准备失败且报出提供者的错误;Maven 命令不在PATH上时报maven.run.noMaven。maven-run-applications(运行 implemented;调试标为待宿主支持 #2107,验证 pending)。7. 宿主端到端测试(
e2e/host/)official_maven_plugin_run_e2e_test.go的TestOfficialMavenPluginRunsASpringBootApplication:在真实 Spring Boot 3.5.13 双模块工程(common库 +web应用)里装上本插件和 Java Support 发行包,检查下拉只有ShopApplication、执行方式是service;在运行配置编辑器里保存 JVM 参数-Dshop.name=Lithe、程序参数(端口、地址)和环境变量SHOP_REGION=eu-west;启动后请求/hello必须返回Hello, Lithe from eu-west,控制台有BUILD SUCCESS、common模块编译、Tomcat started on port N、Started ShopApplication;停止后端口释放、接口不再应答,插件包内容不变。official_maven_plugin_e2e_test.go:安装辅助函数像app.go一样接上工具解析器,支持把多个插件装进同一个服务;读取运行控制台改用op.session.output.all()。lithe-host.json的宿主版本升到包含 #2102 的 main 提交,用例正则加上新用例,requiredEnvironment加LITHE_TEST_JAVA_PLUGIN_ARCHIVE(Java Support 提供启动计划要用的java工具);README 写明取得发行包的gh release download命令。版本:本 PR 不改版本号。插件新增了
requires.buildProviders,按 #27 的做法发版时升主版本(2.0.0)。现在的正式桌面版 desktop-v0.8.3 已声明buildProviders0。范围检查 / Scope checks
tool.executable)是通用的,在 fix(desktop): 没有运行配置时说明原因,“编辑运行配置…”不再无反应 1lck/Lithe-IDEA#2102。ProjectDependenciesResolver解析,主类来自真实编译结果。target/下。CallContext.run),测试里每次等待都有上限,失败时结束提供者进程组。maven.run.buildFailed、noMaven、noRunDocument、noMainClass、ambiguousMainClass、invalidDebug、invalidProject、noWorkspace。验证 / Verification
node scripts/package.mjsMAVEN_ARGS="-s <去掉 profiles 的 settings 副本>" node scripts/test.mjs(含 PATH 解析修复之后重跑)node scripts/test.mjsali、nexus来自本机~/.m2/settings.xml,与本改动无关;运行准备相关检查全部通过plugin.json(pluginhost.Validate+ 宿主Declared()能力,临时测试)|
node scripts/e2e-host.mjs(宿主固定到75edb9674,即合入 #2102 的 main;本 PR 的dist/maven-build-1.0.0-darwin.zip+ Java Support 4.0.1 darwin-arm64,真实 mvn) | macOS arm64 |TestOfficialMavenPluginBuildsAReactorPASS(47.8s)、TestOfficialMavenPluginRunsASpringBootApplicationPASS(6.0s,PATH 解析修复后重新打包再跑)、TestMavenPluginProjectGeneratesABuildableMavenProjectPASS;TestMavenPluginArchetypeRunsRealMaven按设计在未设LITHE_INTEGRATION_NETWORK时跳过。结束后没有 java / 测试进程残留 || GitHub Actions:Linux(runner / 3.6.3 × x64 / arm64)和 Windows(runner / 3.6.3) | Linux、Windows | 4e565b6 全部通过(run 44088348161);06e8732 上
windows (runner)的“prepare ServiceApplication”失败由 PATH 解析修复 |未能执行的检查:调试要等宿主 #2107;Windows 只有 CI 的
scripts/test.mjs,没有在 Windows 上跑宿主端到端;功能矩阵的验证状态都是 pending,手工验收步骤写在docs/feature-matrix.md。🤖 Generated with Claude Code