Skip to content

feat(maven): 当前文件运行——按文件回答 main 类入口(buildProviders 1) - #31

Merged
1lck merged 1 commit into
mainfrom
feat/2104-run-entrypoints
Nov 18, 2026
Merged

1lck merged 1 commit into
mainfrom
feat/2104-run-entrypoints

Conversation

@1lck

@1lck 1lck commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

关联 Issue

改动

  • plugin.json:新增入口运行 {"id": "main", "source": "provider", "entrypoints": true},requires.buildProviders 升到 1。
  • provider/.../RunEntrypoints.java(新增):回答 lithe/build/runEntrypoints。只读这一个文件,不编译:
    • 模块是文件上方最近一个有 pom.xml 的目录(在构建根目录内);项目名取模块 POM 自己的 artifactId(去掉 <parent> 和注释),没有时用目录名。
    • 去掉注释并清空字符串字面量后,要求有 static void main(String[] …) / String… / String x[],并且文件名对应的类、record、enum 或接口存在。
    • 类名是包名加文件名;测试源码(src/test/)不算,因为运行用的运行时类路径不含测试类。
    • 返回 {run: "main", name: <类名>, entrypoint: <全限定名>, project: {name, path}}。
  • RunProvider.java:注册 onRunEntrypoints;读取工作区目录的代码抽成 workspace(),两个请求共用。
  • RunPreparation.java:入口运行的 prepareRun 不带 target,进度和错误提示改用入口的类名。主类本来就优先取 launchOptions.entrypoint。
  • Java SDK 重新 vendoring 到 Core d833d6a(Backend.onRunEntrypoints、Protocol.BUILD_RUN_ENTRYPOINTS、按宿主提供的版本协商 litheBuild),更新 sdk.lock.json。
  • 测试:scripts/compiler/backend-client.mjs 像宿主一样提供 litheBuild [0, 1];scripts/test.mjs 新增入口查找(有 main 的类、没有 main 的类、测试源码)和不带 target 的入口运行(真实 Maven 编译后启动 demo.app.Main),并检查清单声明。
  • README:「运行应用」表格加 main 一行和当前文件入口的说明。

兼容性

需要支持 buildProviders 1 的 Lithe 桌面端(1lck/Lithe-IDEA#2104 的宿主 PR)。旧桌面端不声明 1,不会安装这个版本,所以本插件的下一次发布要和包含该宿主改动的桌面版一起发。

验证

  • node scripts/sdk/verify-sdk.mjs
  • node scripts/package.mjs
  • node scripts/test.mjs(JDK 21、本机 Maven):新增的 6 个入口检查全部通过。“profiles become choices of the Profiles option”在本机失败,是因为本机 ~/.m2/settings.xml 额外定义了 ali、nexus 两个 profile,与本改动无关,CI 环境不受影响。
  • 宿主侧用合成构建提供者跑通 TestRunOnCurrentFileStartsTheEntrypointAndSavesItsConfiguration。

🤖 Generated with Claude Code

@1lck
1lck marked this pull request as ready for review November 18, 2026 03:17
@1lck
1lck merged commit 55919f5 into main Nov 18, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant