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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ jobs:
17
- name: Check script process deadlines and cleanup
run: node scripts/test-process.mjs
- name: Verify vendored Java SDK sources
run: node scripts/sdk/verify-sdk.mjs
- name: Check manifest and build the archive
run: node scripts/package.mjs
- name: Test the build provider's snapshot with a fake Maven (Java 17)
Expand Down
5 changes: 5 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ Version 2.0, at revision 158b854d47ac9af2bbd99c0d7c354a5875cb6f81:
skipTests.svg platform/icons/src/expui/run/showIgnored.svg

Copyright 2000-2024 JetBrains s.r.o. and contributors.

The backend includes the Apache-2.0 licensed official Lithe Java plugin SDK
from Lithe-IDEA/lithe-plugin-docs. Its production sources and LICENSE are
vendored in vendor/, with upstream base revision, local structured logging
changes and exact SHA-256 per input recorded in sdk.lock.json.
35 changes: 26 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,33 @@ Lithe 已预置 Lithe Store 社区插件源;如果你之前移除了它,先

一个包同时支持 Apple Silicon 和 Intel Mac;Lithe for Windows 支持插件市场后会增加 Windows 包。

## 诊断日志

本分支要求宿主提供 `litheLogging: 1`。SDK 通过类型化的 `lithe/log` 通知,把 Maven provider
操作交给宿主 v2 目录和统一 writer,写入当前会话的 `plugins/io.github.lithe-idea.maven-build/host` 通道。
关键成功终态为 INFO、失败终态为 ERROR,包含单调耗时和稳定分类;取消不记失败。
缓存保存失败或读取中项目变化属于可恢复降级,使用 WARN `degraded`,不记录异常正文、路径或环境值。
模型快照继续属于 `${workspaceStateDir}`,不会搬到会话日志目录。

Maven 失败由 SDK 的请求边界记录一次,provider 不再重复打印构建输出。
完整构建输出仍属于 Build Output,模型/依赖树 JSON 属于工作流数据。
后端从 `vendor/` 直接编译官方 Java SDK 的结构化日志实现,使用 `lithe/log` 发送稳定分类、
单调耗时和操作身份;原始异常与构建 tail 不进入日志。`sdk.lock.json` 记录真实上游基线、
本轮尚未发布的源代码改动及每个文件的 SHA-256,没有沿用或伪造旧发版 JAR 的校验值。

排障时使用 Lithe 的独立日志窗口和诊断导出;不要开启输出源码、凭据、环境变量或协议正文的日志。
Windows 的日志实现仍为 v1,未声明 Windows v2 已完成验收。

## 开发

```text
io.github.lithe-idea.maven-build/plugin.json # 插件描述,目录名必须等于插件 id
io.github.lithe-idea.maven-build/icons/ # 工具窗口和工具栏图标(来源见 NOTICE)
extension/ # Maven 核心扩展,导出模型和依赖树
backend/ # 构建后端(Java 8,Lithe 插件 SDK),快照和 Maven 运行
sdk.lock.json # 打进后端的 Lithe Java 插件 SDK:版本、下载地址、SHA-256
vendor/ # 官方 Java SDK 生产源码和许可证(不带测试、JAR、target)
sdk.lock.json # SDK 上游基线、本轮改动身份、逐文件 SHA-256
scripts/sdk/verify-sdk.mjs # 编译前拒绝漂移、遗漏或额外 SDK 文件
test/fixtures/reactor/ # 三个模块的示例反应堆,供集成测试使用
scripts/package.mjs # 构建扩展并打包成 dist/maven-build-<版本>-darwin.zip
scripts/test.mjs # 用真实 Maven 经后端读取项目、运行清单里的命令并检查输出
Expand All @@ -87,13 +106,11 @@ scripts/test-backend.mjs # 用假 Maven 计数,检查快

本地需要 Node.js 22+、JDK(CI 用 17;扩展和后端都按 Java 8 编译,后端运行只需 Java 8)和 Maven(还需要 `zip`)。

后端打进 Lithe 的 Java 插件 SDK。打包脚本按 `sdk.lock.json` 下载正式发布的 SDK JAR 到 `.cache/sdk/`,SHA-256 不符就拒绝。

如需本地调试,可用 `LITHE_SDK_JAR` 指向一个 JAR;正式锁定的 SHA-256 仍会校验该文件,发布(`--expect-tag`)不接受这个覆盖变量:

```bash
LITHE_SDK_JAR=/path/to/lithe-plugin-sdk-java-0.1.0.jar node scripts/package.mjs
```
后端把固定在 `vendor/lithe-plugin-sdk-java/src/main/java/` 的 SDK 生产源码一同按 Java 8 编译。
打包前先校验 `sdk.lock.json`,缺失、改动或额外未登记文件都会拒绝;只读源码不共享可变构建状态。
不再从网络下载 SDK JAR,也不接受 `LITHE_SDK_JAR` 替换构建输入。
SDK 以 Apache-2.0 分发,源码许可证位于 `vendor/LICENSE`,安装包附带 `SDK-LICENSE`。
如需更新,先从官方 SDK 仓库取真实生产源码,审查变更并更新基线和逐文件摘要,再执行验证。

开发或发布时直接运行:

Expand Down Expand Up @@ -144,7 +161,7 @@ node scripts/verify-scripts.mjs --host-bundle /Applications/Lithe.app
## 发布新版本

1. 同时修改 `plugin.json`、`extension/pom.xml` 和 `backend/pom.xml` 的版本(例如 `0.2.0`;打包脚本会检查三者一致),
确认 `sdk.lock.json` 已填入正式发布的 SDK 地址和 SHA-256,合入 `main`。
确认 `sdk.lock.json` 已登记所用 SDK 源码、上游基线与全部 SHA-256,合入 `main`。
2. 推送同名标签:

```bash
Expand Down
74 changes: 17 additions & 57 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
persistent snapshot, and runs Maven (with the extension in ../extension)
only when the snapshot is missing, stale or a refresh was asked for.

Lithe's Java plugin SDK is not published to a Maven repository.
scripts/package.mjs downloads the JAR pinned in sdk.lock.json, checks its
SHA-256 and passes it as -Dlithe.sdk.jar. It compiles against that file and
shade's extraJars merges it into lithe-maven-backend.jar, so the package
carries one self-contained JAR and nothing is installed into ~/.m2.
The official SDK production sources are vendored with per-file hashes in
sdk.lock.json, verified by scripts/package.mjs, and compiled into this JAR.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand All @@ -29,69 +26,37 @@
<maven.compiler.release>8</maven.compiler.release>
<!-- A fixed timestamp makes the jar byte-for-byte reproducible. -->
<project.build.outputTimestamp>2026-10-20T00:00:00Z</project.build.outputTimestamp>
<!-- Absolute path of the checked SDK JAR; set by scripts/package.mjs. -->
<lithe.sdk.jar>${project.basedir}/missing-lithe-sdk.jar</lithe.sdk.jar>
</properties>

<dependencies>
<dependency>
<groupId>io.github.lithe-idea</groupId>
<artifactId>lithe-plugin-sdk-java</artifactId>
<version>0.1.0</version>
<scope>system</scope>
<systemPath>${lithe.sdk.jar}</systemPath>
</dependency>
</dependencies>

<build>
<sourceDirectory>${project.basedir}/..</sourceDirectory>
<finalName>lithe-maven-backend</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
<configuration>
<includes>
<include>backend/src/main/java/**/*.java</include>
<include>vendor/lithe-plugin-sdk-java/src/main/java/**/*.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>io.github.litheidea.maven.backend.MavenBackend</mainClass>
</manifest>
<manifestEntries>
<Implementation-Version>${project.version}</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<!-- Shade leaves system-scoped artifacts out; this merges the SDK in. -->
<extraJars>
<extraJar>${lithe.sdk.jar}</extraJar>
</extraJars>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/MANIFEST.MF</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>io.github.litheidea.maven.backend.MavenBackend</mainClass>
<manifestEntries>
<Implementation-Version>${project.version}</Implementation-Version>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
Expand Down Expand Up @@ -120,11 +85,6 @@
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private void serve() {
snapshots = new Snapshots(store, backend);
state = store.directory();
} else {
backend.log("No --state directory: Maven results are not kept across restarts.");
backend.diagnostics().degraded("initialize", "maven.stateUnavailable");
}
runs = new MavenRuns(snapshots, backend, state);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private void fly(Flight flight, Inputs inputs, String before) {
if (before.equals(Fingerprint.of(inputs))) {
snapshots.write(inputs.root, before, loaded);
} else {
backend.log("The Maven project changed while it was read; the result is not saved.");
backend.diagnostics().degraded("lithe/build/model", "maven.inputsChanged");
}
}
flight.result.complete(loaded);
Expand Down Expand Up @@ -192,7 +192,8 @@ private Loaded run(Inputs inputs, Cancellation cancellation) throws IOException
.onStderr(tail));
if (result.exitCode() != 0) {
String output = tail.errors();
backend.log("Maven exited with status " + result.exitCode() + ":\n" + output);
// The SDK records this failed request once. Build output belongs
// to the response, never to the diagnostic stderr stream.
throw new PluginError("maven.loadFailed", "Maven could not read the project (exit status "
+ result.exitCode() + ")." + (output.isEmpty() ? "" : "\n" + output));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ synchronized void write(Path root, String fingerprint, MavenRuns.Loaded loaded)
store.write(KEY, snapshot);
} catch (IOException | RuntimeException error) {
// The result is still answered; only the next start runs Maven again.
backend.log("Could not save the Maven snapshot: " + error.getMessage());
backend.diagnostics().degraded("lithe/build/model", "maven.snapshotSaveFailed");
}
}

Expand Down
7 changes: 5 additions & 2 deletions scripts/backend-client.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class BackendClient {
#pending = new Map();
#nextId = 1;
stderr = "";
diagnostics = [];

/** Starts `java -jar <jar> --state <state>`; `javaOptions` go before `-jar`. */
constructor({ java = "java", jar, state, env = process.env, javaOptions = [], timeoutMs = WAIT_MS }) {
Expand Down Expand Up @@ -70,7 +71,7 @@ export class BackendClient {
const result = await this.request("initialize", {
processId: process.pid,
rootUri: pathToFileURL(root).href,
capabilities: { experimental: { litheBuild: { versions: [1] } } },
capabilities: { experimental: { litheBuild: { versions: [1] }, litheLogging: { versions: [1] } } },
});
this.notify("initialized", {});
return result;
Expand Down Expand Up @@ -118,7 +119,9 @@ export class BackendClient {
try { message = JSON.parse(this.#buffer.subarray(headerEnd + 4, headerEnd + 4 + length).toString("utf8")); }
catch { return this.#broken("a frame that is not JSON"); }
this.#buffer = this.#buffer.subarray(headerEnd + 4 + length);
if (message.id !== undefined && message.method === undefined) {
if (message.method === "lithe/log") {
this.diagnostics.push(message.params);
} else if (message.id !== undefined && message.method === undefined) {
this.#pending.get(message.id)?.(message);
this.#pending.delete(message.id);
}
Expand Down
Loading
Loading