Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ brew install maven
target 的 `mainClass`、编译结果里唯一的主类(Spring Boot 优先带注解的类);有多个时报错并列出候选。
类路径超过 24 000 个字符时写进 `target/lithe-run/` 下只含清单的 jar,避开 Windows 命令行长度限制。
4. 清单为 Spring Boot 运行声明了按配置类型连接的调试(`debug.configurationType: java`):宿主带着调试端口请求时,
提供者加 `-agentlib:jdwp=…,suspend=y`,服务停在启动处等 Java 调试器连上。Lithe 桌面端还没有实现这段宿主流程
([1lck/Lithe-IDEA#2107](https://github.com/1lck/Lithe-IDEA/issues/2107)),目前点调试会提示这个配置不能调试。
提供者加 `-agentlib:jdwp=…,suspend=y`,服务停在启动处等 Java 调试器连上。点调试时,Lithe 选出已启用的、能连接 `java` 类型的调试适配器
(安装 [Java Support](https://github.com/Lithe-IDEA/lithe-plugin-java) 即可),分配端口、启动服务并连上调试器;
在调试窗口停止会一起结束服务。需要 Lithe 桌面端包含 [1lck/Lithe-IDEA#2113](https://github.com/1lck/Lithe-IDEA/pull/2113)。

不经过 `spring-boot:run`,Lithe 停止的就是应用进程本身。运行配置里的 JVM 参数、程序参数、环境变量和工作目录
原样带到启动命令。
Expand Down
15 changes: 10 additions & 5 deletions docs/feature-matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ CI 在 Windows x64 上用 `mvn.cmd` 运行声明的模型、依赖和测试命
| `java-maven-toolbar-tooltips` | 构建窗口里的 Maven 图标、工具栏开关和提示 | implemented / pending | implemented / pending | 没有自动化覆盖 |
| `maven-user-settings-editing` | 编辑用户级 `~/.m2/settings.xml` 的本地仓库 | missing / not-applicable | missing / not-applicable | — |
| `maven-project-generators` | 新建项目:Maven 和 Maven Archetype | implemented / pending | implemented / pending | 2026-11-14 宿主端到端测试通过(macOS) |
| `maven-run-applications` | 运行配置:Spring Boot 服务和 Java 应用的运行(调试待宿主支持) | implemented / pending | implemented / pending | 2026-11-17 宿主端到端测试和 `scripts/test.mjs` 通过(macOS);`scripts/test.mjs` 在 Windows CI 通过 |
| `maven-run-applications` | 运行配置:Spring Boot 服务和 Java 应用的运行与调试 | implemented / pending | implemented / pending | 2026-11-17 宿主端到端测试(运行与断点调试)和 `scripts/test.mjs` 通过(macOS);`scripts/test.mjs` 在 Windows CI 通过 |

前六条从主仓库迁移;`maven-project-generators` 是本仓库新增,用来记录随测试一起迁来的新建项目测试;`maven-run-applications` 随运行配置一起新增([1lck/Lithe-IDEA#2074](https://github.com/1lck/Lithe-IDEA/issues/2074))。

Expand Down Expand Up @@ -202,15 +202,19 @@ ArtifactId);Maven Archetype 用内置或自定义原型,由 `mvn archetype
**能力**:读取项目时把 Spring Boot 应用(`@SpringBootApplication` 类或 `spring-boot-maven-plugin`)和写明主类的
Java 应用(`exec-maven-plugin`、jar 清单)列为 target,`run` 声明把它们变成运行配置;构建提供者
`lib/lithe-maven-provider.jar` 准备运行:编译模块及其反应堆依赖,导出运行时类路径和主类,返回 `java -cp … 主类`。
Spring Boot 运行声明了按配置类型连接的调试:宿主带调试端口请求时,提供者加 `-agentlib:jdwp` 挂起到调试器连上;Lithe 桌面端尚未实现这段宿主流程([1lck/Lithe-IDEA#2107](https://github.com/1lck/Lithe-IDEA/issues/2107)),所以调试目前不可用。
Spring Boot 运行声明了按配置类型连接的调试:宿主带调试端口请求时,提供者加 `-agentlib:jdwp` 挂起到调试器连上,宿主再用已启用的 `java` 类型适配器(Java Support)连接(宿主流程见 [1lck/Lithe-IDEA#2113](https://github.com/1lck/Lithe-IDEA/pull/2113))。

**证据**:`plugin.json` 的 `buildSystems[0].provider` 和 `buildSystems[0].run`、`extension/.../Applications.java`、
`extension/.../RunExport.java`、`provider/`、`scripts/test.mjs` 的运行准备检查、`test/fixtures/reactor/service/`。

**依赖的宿主能力**:`buildProviders`(独立提供者进程和 `lithe/build/prepareRun`)、运行配置解析(`fromTargets`)、
注册表连接调试(`debug.configurationType: java`,需要启用一个提供 `java` 类型 `attach` 的调试适配器)。

**最近验证**:2026-11-17,macOS arm64,插件 1.0.0 打包产物,宿主 `75edb9674`(合入 1lck/Lithe-IDEA#2102 的 main),`node scripts/e2e-host.mjs`:
**最近验证**:2026-11-17,macOS arm64,插件 1.0.0 打包产物,宿主 `1ce4085e7`(合入 1lck/Lithe-IDEA#2113 的 main),`node scripts/e2e-host.mjs`:

- `TestOfficialMavenPluginDebugsASpringBootApplication` PASS(约 16s):和 Java Support 4.0.1 发布包一起安装,在
`ShopApplication.java` 设断点后从标题栏点调试;服务以挂起方式启动,`java` 适配器连上;`GET /hello` 停在断点,
请求在断点处阻塞,继续后返回 `Hello, Lithe from eu-west`;在调试窗口停止后服务结束、端口释放;插件安装目录不变。

- `TestOfficialMavenPluginRunsASpringBootApplication` PASS(6.2s):和 Java Support 4.0.1 发布包一起安装,打开真实的两模块
Spring Boot 3.5.13 项目;运行配置下拉只列出服务 `ShopApplication`;编辑器保存的 JVM 参数、程序参数和环境变量传到了进程
Expand All @@ -219,14 +223,15 @@ Spring Boot 运行声明了按配置类型连接的调试:宿主带调试端
- `node scripts/test.mjs`:提供者的运行准备、类路径、主类选择、调试参数和编译失败。

这次实测发现并在 #2102 修好了四个宿主问题:声明了提供者进程的构建系统读取写文件的依赖命令时缺少输出文件、设置页按提供者读取模型、
未命名的运行配置带上了运行 ID 前缀、准备运行时的构建输出没有显示。调试没有验收(宿主尚未支持,见上)。Windows 没有运行。
未命名的运行配置带上了运行 ID 前缀、准备运行时的构建输出没有显示。调试的实测又发现并在 #2113 修好了三个宿主问题:
调试适配器列表在插件变化后不刷新、运行进程 30 分钟后被准备时限结束、JDT LS 就绪后才注册命令时请求调试端口被拒。Windows 没有运行。

**验证方法**(macOS):

1. 安装插件包,打开含 Spring Boot 模块和 `exec-maven-plugin` 模块的多模块项目,信任工作区。
2. 标题栏运行配置菜单列出每个应用;选中 Spring Boot 应用点运行,运行窗口先显示 Maven 编译输出,再显示应用输出;
停止后应用进程退出。
3. 在运行配置编辑器里改 JVM 参数、程序参数、环境变量和入口,再次运行时生效。
4. 宿主支持后(1lck/Lithe-IDEA#2107):启用 Java 调试适配器,调试 Spring Boot 应用,断点命中。
4. 同时安装 Java Support,在 Spring Boot 应用里设断点后点调试:断点命中,继续后请求完成,停止后服务结束。
5. 制造编译错误后运行,看到“Maven 编译失败”的提示,没有启动残缺的应用。
6. 整个过程中插件安装目录不被写入。
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
package workbench

import (
"io"
"net"
"net/http"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
"testing"
"time"

"github.com/1lck/Lithe-IDEA/desktop/internal/core"
)

// TestOfficialMavenPluginDebugsASpringBootApplication covers Debug on the Maven archive's
// Spring Boot run configuration with the released Java Support archive, whose java adapter the
// run's debug type selects: the service starts suspended on a host-chosen port, the Java
// debugger attaches, a request to the endpoint stops on a breakpoint in the application's
// source, Continue lets the request finish, and Stop in the Debug window ends the service. It
// uses the user's mvn and local repository.
func TestOfficialMavenPluginDebugsASpringBootApplication(t *testing.T) {
archive := os.Getenv("LITHE_TEST_MAVEN_PLUGIN_ARCHIVE")
if archive == "" {
t.Skip("set LITHE_TEST_MAVEN_PLUGIN_ARCHIVE to a maven-build-<version>-darwin.zip")
}
javaArchive := os.Getenv("LITHE_TEST_JAVA_PLUGIN_ARCHIVE")
if javaArchive == "" {
t.Fatal("set LITHE_TEST_JAVA_PLUGIN_ARCHIVE to a Lithe-Java-Support-<version>-darwin-<arch>.zip: its java adapter debugs the run")
}
if _, err := exec.LookPath("mvn"); err != nil {
t.Fatalf("mvn is not on PATH: %v", err)
}
h := newHarness(t, &testKernel{Client: core.NewClient()})
// Java Support starts its language server, which runs the java adapter, with ${logDir}: the
// client always has a log store, which the harness replaces with one that gives a directory.
h.app.logSink = &pluginFilesLog{directory: t.TempDir()}
installed := installOfficialPluginArchive(t, h, archive, "io.github.lithe-idea.maven-build")
installPluginArchiveInto(t, h.app.plugins, javaArchive, "io.github.lithe-idea.java-support")
before := packageDigest(t, installed)
root := t.TempDir()
springBootReactor(t, root)
source := filepath.Join(root, "web", "src", "main", "java", "demo", "web", "ShopApplication.java")
line := sourceLine(t, source, "return Greeting.of(")
h.open(root)
p := h.app.project
if p == nil {
t.Fatal("the reactor did not open")
}
var console func() string
t.Cleanup(func() {
if t.Failed() {
text := ""
if console != nil {
text = console()
}
t.Logf("build status %q, debug state %q status %q failure %q, notice %q, debug output:\n%s\nrun console:\n%s",
p.build.status, p.debug.state, p.debug.status, p.debug.failure, lastNotice(h), strings.Join(p.debug.output, ""), text)
}
})

h.app.post(func(a *App) { a.loadTitleRunConfigs(p) })
awaitBuildModel(t, h, p, "maven", 5*time.Minute)
awaitStateWithin(t, h, time.Minute, "the run configurations", func() bool {
return p.runConfigsSettled() && p.runConfigs.generation > 0
})
if len(p.runConfigs.list) != 1 || p.runConfigs.list[0].Name != "ShopApplication" {
t.Fatalf("the run configurations are %+v, want only ShopApplication", p.runConfigs.list)
}
id := p.runConfigs.list[0].ID
if facts := p.titleConfigurationFacts(p.buildInstanceIndex(mustBuildReference(t, p, id)), mustBuildReference(t, p, id)); facts.Debuggable == nil || !*facts.Debuggable {
t.Fatal("ShopApplication is not debuggable")
}

port := freePort(t)
h.app.post(func(a *App) { a.openRunConfigEditor(p, id) })
awaitStateWithin(t, h, 30*time.Second, "the run configuration editor", func() bool {
return p.runConfigs.editor.open && !p.runConfigs.editor.loading
})
h.app.post(func(a *App) {
e := &p.runConfigs.editor
e.runtimeArguments = "-Dshop.name=Lithe"
e.arguments = "--server.port=" + strconv.Itoa(port) + " --server.address=127.0.0.1"
e.environment = "SHOP_REGION=eu-west"
a.saveRunConfigEditor(p)
})
awaitStateWithin(t, h, 30*time.Second, "the saved run configuration", func() bool {
return !p.runConfigs.editor.open && !p.runConfigs.loading && p.runConfigs.configuration(id) != nil
})

h.app.post(func(a *App) {
a.toggleBreakpointAt(p, source, line)
a.chooseTitleConfiguration(p, id)
a.titleDebug(p)
})
awaitStateWithin(t, h, 30*time.Second, "the debugged run", func() bool { return p.build.operation != nil })
op := p.build.operation
console = func() string { return op.session.output.all() }
awaitStateWithin(t, h, 5*time.Minute, "the attached debugger", func() bool {
session := p.debug.activeSession()
return session != nil && session.adapter.Declaration.ID == "java" && p.debug.state == "running"
})

// The request runs on the server's thread and stops on the breakpoint until Continue.
url := "http://127.0.0.1:" + strconv.Itoa(port) + "/hello"
type answer struct {
body string
err error
}
answers := make(chan answer, 1)
go func() {
deadline := time.Now().Add(5 * time.Minute)
client := &http.Client{Timeout: 5 * time.Minute}
for {
response, err := client.Get(url)
if err != nil {
if time.Now().After(deadline) {
answers <- answer{err: err}
return
}
time.Sleep(500 * time.Millisecond)
continue
}
data, err := io.ReadAll(io.LimitReader(response.Body, 4096))
_ = response.Body.Close()
answers <- answer{body: string(data), err: err}
return
}
}()
awaitStateWithin(t, h, 5*time.Minute, "the stop on the breakpoint", func() bool {
return p.debug.pausedThread != nil && len(p.debug.frames) > 0
})
top := p.debug.frames[0]
if filepath.Base(top.SourcePath) != "ShopApplication.java" || top.Line != line {
t.Fatalf("stopped at %s:%d in %s, want ShopApplication.java:%d", top.SourcePath, top.Line, top.Name, line)
}
select {
case got := <-answers:
t.Fatalf("the request finished while the server was stopped on the breakpoint: %+v", got)
default:
}

h.app.post(func(a *App) { a.continueDebug(p) })
got := awaitValueWithin(t, h, time.Minute, answers, "the request after Continue")
if got.err != nil || got.body != "Hello, Lithe from eu-west" {
t.Fatalf("GET /hello after Continue = %q, %v", got.body, got.err)
}

// Stop in the Debug window ends the service it attached to.
h.app.post(func(a *App) { a.stopDebugByUser(p) })
awaitStateWithin(t, h, time.Minute, "the stopped service", func() bool {
return p.build.operation == nil && p.debug.activeSession() == nil
})
listener, err := net.Listen("tcp", "127.0.0.1:"+strconv.Itoa(port))
if err != nil {
t.Fatalf("the application's port is still taken after Stop: %v", err)
}
_ = listener.Close()

h.app.closeProject()
awaitStateWithin(t, h, 30*time.Second, "the closed project", func() bool { return h.app.project == nil })
h.settle()
assertPackageUnchanged(t, installed, before)
}

// sourceLine is the one-based line of path that contains text.
func sourceLine(t *testing.T, path, text string) int64 {
t.Helper()
data, err := os.ReadFile(path)
if err != nil {
t.Fatal(err)
}
for index, line := range strings.Split(string(data), "\n") {
if strings.Contains(line, text) {
return int64(index + 1)
}
}
t.Fatalf("%s has no line with %q", path, text)
return 0
}

// mustBuildReference is the build provider reference of configuration id.
func mustBuildReference(t *testing.T, p *project, id string) core.RunProviderReference {
t.Helper()
configuration := p.runConfigs.configuration(id)
if configuration == nil {
t.Fatalf("no configuration %q", id)
}
reference, ok := configuration.BuildReference()
if !ok {
t.Fatalf("configuration %q does not start through a build provider", id)
}
return reference
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ func installOfficialPluginArchive(t *testing.T, h *harness, archive, id string)
t.Fatal(err)
}
// The app gives its service these resolvers when it opens it (app.go); a provider or backend
// that runs on a tool, such as a jar on java, cannot start without them.
// that runs on a tool, such as a jar on java, cannot start without them, and a language
// server whose launch uses ${logDir} cannot start without the log directory.
service.Backend.SetToolResolver(h.app.resolveBackendTool)
service.Backend.SetToolEntryResolver(h.app.resolveBackendToolEntry)
service.LanguageTool = h.app.resolveLanguageTool
service.LogDirectory = h.app.pluginLogDirectory
h.app.plugins = service
return installPluginArchiveInto(t, service, archive, id)
}
Expand Down
6 changes: 3 additions & 3 deletions e2e/host/lithe-host.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"repository": "https://github.com/1lck/Lithe-IDEA.git",
"revision": "75edb9674b655eb151b35ed34518731cec9e9b8b",
"revision": "1ce4085e7012a8b9e887c5bab734ef3fd561a7f8",
"packages": {
"./internal/workbench": "^TestOfficialMavenPlugin(BuildsAReactor|RunsASpringBootApplication)$",
"./internal/workbench": "^TestOfficialMavenPlugin(BuildsAReactor|RunsASpringBootApplication|DebugsASpringBootApplication)$",
"./internal/projectgen": "^TestMavenPlugin"
},
"requiredEnvironment": {
"LITHE_TEST_MAVEN_PLUGIN_ARCHIVE": "maven-build-<version>-darwin.zip to install, for example dist/maven-build-0.0.1-darwin.zip",
"LITHE_PLUGIN_MAVEN_DIR": "directory holding the plugin.json and templates; defaults to this repository's",
"LITHE_TEST_JAVA_PLUGIN_ARCHIVE": "Lithe-Java-Support-<version>-darwin-<arch>.zip from Lithe-IDEA/lithe-plugin-java releases; its java tool launches the run"
"LITHE_TEST_JAVA_PLUGIN_ARCHIVE": "Lithe-Java-Support-<version>-darwin-<arch>.zip from Lithe-IDEA/lithe-plugin-java releases; its java tool launches the run and its java adapter debugs it"
},
"repositoryEnvironment": {
"LITHE_PLUGIN_MAVEN_DIR": "io.github.lithe-idea.maven-build"
Expand Down
Loading