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
57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: CI

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
push:
branches: [main]

Expand Down Expand Up @@ -50,6 +51,18 @@ jobs:
# The oldest Maven also runs on the oldest Java.
JAVA_HOME: ${{ matrix.maven == 'runner' && env.JAVA_HOME || env[format('JAVA_HOME_8_{0}', runner.arch)] }}
run: node scripts/test.mjs
- name: Verify native compiler targets and local JARs
if: matrix.maven == 'runner'
run: |
node --test --test-timeout=15000 scripts/compiler/process.test.mjs
node scripts/compiler/test.mjs
- name: Upload native compiler projections
if: matrix.os == 'ubuntu-latest' && matrix.maven == 'runner'
uses: actions/upload-artifact@v4
with:
name: native-compiler-projection
path: .artifacts/compiler/visual-*.json
if-no-files-found: error
- name: Verify Linux and Windows release archives
run: node --test --test-timeout=60000 scripts/package/*.test.mjs
- name: Hand the Windows archive to the Windows job
Expand Down Expand Up @@ -84,6 +97,45 @@ jobs:
path: .artifacts/test-stability/
if-no-files-found: warn

native-settings-visual:
name: Native compiler settings screenshots
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
needs: package
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: native-compiler-projection
path: .artifacts/compiler
- name: Read pinned host revision
id: host
run: echo "revision=$(node -p 'JSON.parse(require("fs").readFileSync("compiler-host.json")).revision')" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v4
with:
repository: 1lck/Lithe-IDEA
ref: ${{ steps.host.outputs.revision }}
path: .artifacts/host
- uses: actions/setup-go@v5
with:
go-version-file: .artifacts/host/desktop/go.mod
cache: false
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.100.0
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Render actual compiler projections through the native host
run: node scripts/compiler/visual.mjs .artifacts/host
- uses: actions/upload-artifact@v4
with:
name: native-compiler-settings-screenshots
path: .artifacts/compiler/visual/
if-no-files-found: error
retention-days: 14

# The Windows archive built above, unpacked the way Lithe installs it (under
# a path with a space), runs the declared commands through mvn.cmd.
windows:
Expand Down Expand Up @@ -138,6 +190,11 @@ jobs:
run: |
if ($env:MVN) { & $env:MVN --version } else { mvn --version }
node scripts/test.mjs
- name: Verify native compiler settings and JARs in the installed Windows archive
if: matrix.maven == 'runner'
run: |
node --test --test-timeout=15000 scripts/compiler/process.test.mjs
node scripts/compiler/test.mjs
- name: Upload script timing reports
if: always()
uses: actions/upload-artifact@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
if [[ "$tag" == "$GITHUB_REF_NAME" ]]; then prerelease=true; fi
done
{
echo "兼容性:按插件契约 v0(schemaVersion 0、pluginAPIVersion 0)编写,需要新版 Lithe 桌面端(desktop-v* 预发布)。旧版 macOS Lithe 无法安装。"
echo "兼容性:按插件契约 v0(schemaVersion 0、pluginAPIVersion 0)编写,需要支持 sourceSettings 0 的 Lithe 桌面端。请先升级宿主;旧版宿主继续使用原有兼容插件版本。"
echo
if [[ -s "docs/releases/$GITHUB_REF_NAME.md" ]]; then
cat "docs/releases/$GITHUB_REF_NAME.md"
Expand All @@ -72,4 +72,4 @@ jobs:
if [[ "$prerelease" == true ]]; then
release_flags+=(--prerelease)
fi
gh release create "$GITHUB_REF_NAME" dist/*.zip --title "Maven $GITHUB_REF_NAME" --notes-file "$RUNNER_TEMP/notes.md" "${release_flags[@]}"
gh release create "$GITHUB_REF_NAME" dist/*.zip --draft --title "Maven $GITHUB_REF_NAME" --notes-file "$RUNNER_TEMP/notes.md" "${release_flags[@]}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ dist/
extension/target/
.DS_Store
.cache/
settings-backend/target/
6 changes: 6 additions & 0 deletions compiler-host.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"repository": "https://github.com/1lck/Lithe-IDEA",
"revision": "e9ce7781f1a9635ced8a090b45a159af4f5ce959",
"coreRevision": "5802c42b5766df7375bd427c54203db415ff72d7",
"package": "io.github.lithe-idea.maven-build"
}
9 changes: 9 additions & 0 deletions docs/feature-matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,15 @@ ArtifactId);Maven Archetype 用内置或自定义原型,由 `mvn archetype

跨架构本地包检查通过不等于原生工作流验收。既有平台验证记录保持不变。

## 原生编译设置与本地 JAR

| 能力 | macOS | Windows | 证据 |
| --- | --- | --- | --- |
| 项目默认目标、按模块字节码、继承与显式保存 | implemented / pending | implemented / pending | `scripts/compiler/` 真实引擎回归,检查 class major 52/55;原生完整 UI 验收仍 pending |
| 原生 JAR 引用与编译运行 | implemented / pending | implemented / pending | `scripts/compiler/` 编译外部 JAR 并运行引用它的程序;配置与包的只读边界见 native-settings.md |

2026-11-15:本地 macOS 自动化已通过,不将脚本通过等同于所有交互场景验收。Windows 的实机结果另随 PR 补充。

## Windows 安装包

| 能力 | Windows ARM64 | Windows x64 | 验证入口 |
Expand Down
15 changes: 15 additions & 0 deletions docs/native-settings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Maven 编译设置与本地 JAR

在设置的“构建、执行、部署”中打开插件提供的编译器页,点击“读取编译设置”(构建工具会显示“使用项目工具读取编译设置”)。读取会使用项目工具,可能执行项目脚本或下载依赖。项目默认目标与模块覆盖分别显示;移除模块覆盖后继承项目配置。只有点击“保存”才写入 所选模块的 `pom.xml`,外部修改会要求重新读取。

管理 JDK:在“构建、执行、部署”的工具链区使用“全局默认”,选择自动识别结果,或从磁盘添加多个 JDK,核对版本后保存;无需先打开项目。个别项目可切换到“当前项目”单独覆盖。已启动的进程需重启后采用新版本。JDK 是运行编译器的程序;目标字节码决定生成的 class 版本,两者分别设置。构建工具自己的显式 Java 环境或工具链配置仍按该工具的规则生效。

本地 JAR 入口在插件的语言/构建工具设置页,点击“读取本地 JAR 依赖”,选择目标模块并浏览文件后保存。每行一个路径,空格属于路径内容。模块与有效值来自 Maven 的实际项目模型,包含启用的 Profiles。每个模块可单独覆盖目标字节码。新增本地 JAR 使用原生 system 作用域依赖;团队共享项目优先在 POM 中添加仓库依赖。

运行时状态和暂存放在宿主提供的用户状态/临时目录;插件安装包始终只读。暂存文件由一次保存拥有,完成或取消时删除,不跨工作树共享。新后端与翻译由各平台构建入口打入同一版本包并校验。

## Compatibility

This version requires a desktop host advertising `sourceSettings: 0`. Older hosts retain their previous compatible plugin version. Read compiler settings under Build, Execution, Deployment; read local JAR dependencies on the language/build-system page. Save changes only the listed native sources and rejects a changed baseline. JDK selection and target bytecode are separate settings.

Tests in `scripts/compiler/` execute the real upstream engine, inspect class-file major versions and run code using an external JAR. HTML and JUnit timing reports are written to `.artifacts/test-stability/`; tests own and clean their temporary workspaces and processes.
23 changes: 23 additions & 0 deletions docs/releases/v1.0.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Maven 1.0.0

## 中文

- 新增真实项目编译设置、项目默认目标与按模块字节码覆盖,保存后重新读取生效配置。
- 新增本地 JAR 引用入口,保留无关的项目配置与注释。
- 保留 0.2.1 已提供的 Windows 安装包与路径兼容修复。

### 兼容性

此主版本新增 `sourceSettings: 0` 宿主要求;旧宿主无法安装,应继续使用上一兼容版本或先升级桌面端。读取项目工具可能执行项目代码及下载依赖;仅明确保存才修改列出的配置文件。详见 [编译设置说明](../native-settings.md)。

---

## English

- Add native compiler settings with project defaults, per-module bytecode overrides and effective-value readback.
- Add local JAR dependencies while preserving unrelated project configuration and comments.
- Retain the Windows archives and native path fixes already available in 0.2.1.

### Compatibility

This major release requires `sourceSettings: 0`. Upgrade the desktop host first, or keep the previous compatible plugin version. Reading project tools may execute project code and download dependencies. Only explicit Save changes the displayed native sources.
134 changes: 134 additions & 0 deletions e2e/host/desktop/internal/settingswindow/plugin_native_source_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
//go:build vivahead && lithevisual

package settingswindow

import (
"context"
"encoding/json"
"errors"
"os"
"path/filepath"
"testing"
"time"

"github.com/1lck/Lithe-IDEA/desktop/internal/core"
"github.com/1lck/Lithe-IDEA/desktop/internal/i18n"
"github.com/1lck/Lithe-IDEA/desktop/internal/marketplace"
"github.com/1lck/Lithe-IDEA/desktop/internal/pluginhost"
"github.com/1lck/Lithe-IDEA/desktop/internal/pluginservice"
"github.com/1lck/Lithe-IDEA/desktop/internal/pluginsettings"
"github.com/vivaui/viva/headless"
)

// This plugin-owned overlay renders the public projection captured from its real
// engine tests. It does not publish files; native publication is tested separately.
type pluginNativeVisualSource struct {
store *pluginsettings.Store
manifest json.RawMessage
packageRoot, workspace string
sources pluginsettings.SourceEditor
}

func (s *pluginNativeVisualSource) Load(ctx context.Context, _ string, language i18n.Language) (pluginservice.SettingsEditor, error) {
snapshot, err := s.store.LoadPresented(ctx, s.manifest, s.workspace, pluginsettings.Presentation{Package: s.packageRoot, Language: language.Code()})
return pluginservice.SettingsEditor{Snapshot: snapshot}, err
}
func (s *pluginNativeVisualSource) Save(context.Context, pluginservice.SettingsEditor, string, []core.PluginSettingEdit) (pluginsettings.SaveResult, error) {
return pluginsettings.SaveResult{}, errors.New("visual capture never publishes")
}
func (s *pluginNativeVisualSource) Action(context.Context, pluginservice.SettingsEditor, string, bool) (pluginservice.SettingsActionResult, error) {
return pluginservice.SettingsActionResult{Plan: core.PluginSettingsActionPlan{Kind: "invoke", ActionID: "compiler", SourceEditor: true}, Sources: &s.sources}, nil
}
func (s *pluginNativeVisualSource) SaveSources(context.Context, pluginservice.SettingsEditor, string, pluginsettings.SourceEditor, []core.SourceSettingsEdits) (pluginsettings.SourceEditor, error) {
return s.sources, errors.New("visual capture never publishes")
}

func TestPluginNativeSourceVisual(t *testing.T) {
packageRoot, input, out := os.Getenv("LITHE_NATIVE_PACKAGE"), os.Getenv("LITHE_NATIVE_SNAPSHOTS"), os.Getenv("LITHE_NATIVE_OUTPUT")
if packageRoot == "" || input == "" || out == "" {
t.Fatal("run the plugin's scripts/compiler/visual.mjs")
}
manifest, err := os.ReadFile(filepath.Join(packageRoot, "plugin.json"))
if err != nil {
t.Fatal(err)
}
var metadata struct {
ID, DisplayName, Version string
SettingActions []struct {
ID string
Page struct{ CompilerID string }
}
}
if err = json.Unmarshal(manifest, &metadata); err != nil {
t.Fatal(err)
}
admission, cancelAdmission := context.WithTimeout(context.Background(), 10*time.Second)
defer cancelAdmission()
if _, err = core.NewClient().ValidatePluginManifest(admission, manifest, pluginhost.Declared()); err != nil {
t.Fatal(err)
}
compilerID := ""
for _, action := range metadata.SettingActions {
if action.ID == "compiler" {
compilerID = action.Page.CompilerID
}
}
if compilerID == "" {
t.Fatal("compiler action missing")
}
if err = os.MkdirAll(out, 0755); err != nil {
t.Fatal(err)
}
for _, language := range []i18n.Language{i18n.Chinese, i18n.English} {
for _, theme := range []string{"dark", "light"} {
t.Run(language.Code()+"-"+theme, func(t *testing.T) {
code := "en"
if language == i18n.Chinese {
code = "zh"
}
raw, err := os.ReadFile(filepath.Join(input, "visual-"+code+".json"))
if err != nil {
t.Fatal(err)
}
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
state, err := core.NewClient().ReadSourceSettings(ctx, raw)
if err != nil {
t.Fatal(err)
}
source := &pluginNativeVisualSource{store: pluginsettings.New(core.NewClient(), t.TempDir()), manifest: manifest, packageRoot: packageRoot, workspace: t.TempDir(), sources: pluginsettings.SourceEditor{State: state}}
fetch := func(context.Context) (marketplace.Snapshot, error) {
return marketplace.Snapshot{Index: core.MarketplaceIndex{Plugins: []core.MarketplacePlugin{{ID: metadata.ID, Name: metadata.DisplayName, LatestVersion: metadata.Version}}}}, nil
}
w := newWindow(NewController(Options{Text: func() *i18n.Messages { return i18n.For(language) }, Language: func() i18n.Language { return language }, SystemLanguage: language, SystemDark: func() bool { return theme == "dark" }, PluginSettings: source, SettingsNavigation: core.NewClient().SettingsNavigation, SettingsPages: func(ctx context.Context) ([]core.SettingsPage, error) {
return core.NewClient().SettingsPages(ctx, []core.SettingsContribution{{Manifest: manifest, Owner: core.PluginSettingsOwner{PluginID: metadata.ID, Version: metadata.Version}, Enabled: true}})
}, Marketplace: fetch, MarketplaceInstalled: fetch, PluginState: func(string) PluginState {
return PluginState{Installed: true, Enabled: true, Version: metadata.Version}
}}), Values{Theme: theme, Language: language.Code()})
config := w.config()
config.Width, config.Height = 1120, 900
session, err := headless.Open(config, nil, headless.Options{})
if err != nil {
t.Fatal(err)
}
t.Cleanup(session.Close)
d := &windowDriver{t: t, w: w, driver: session.Driver()}
d.until("compiler contribution", func() bool { return len(w.dynamic.pages) > 0 })
w.selectSettingsPage(pageBuild, "compiler:"+compilerID)
d.until("compiler read action", func() bool { return w.pluginSettings.pageKey == w.dynamicPage && w.pluginSettings.loaded })
title := ""
for _, action := range w.pluginSettings.editor.Snapshot.State.Actions {
if action.ID == "compiler" {
title = action.Title
}
}
d.click(title)
d.until("native compiler form", func() bool { return w.pluginSettings.sources != nil })
d.pump()
if err = session.Screenshot(filepath.Join(out, "compiler-"+language.Code()+"-"+theme+".png")); err != nil {
t.Fatal(err)
}
})
}
}
}
2 changes: 1 addition & 1 deletion extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<groupId>io.github.lithe-idea</groupId>
<artifactId>lithe-maven-extension</artifactId>
<!-- Kept equal to plugin.json's version; scripts/package.mjs checks it. -->
<version>0.2.1</version>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Lithe Maven extension</name>

Expand Down
48 changes: 48 additions & 0 deletions extension/src/main/java/io/github/litheidea/maven/ModelExport.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ Map<String, Object> document() {
properties.put("artifactId", project.getArtifactId());
properties.put("version", project.getVersion());
properties.put("packaging", project.getPackaging());
compilerFacts(project, properties);
if(project.getParent()!=null){
Map<String,Object> inherited=new LinkedHashMap<>();compilerFacts(project.getParent(),inherited);
for(String key:new String[]{"target","releaseEnabled","debug","showDeprecation","showWarnings","arguments"})if(inherited.containsKey("compiler."+key))properties.put("compiler.inherited."+key,inherited.get("compiler."+key));
}
entry.put("properties", properties);
projects.add(entry);
if (!"pom".equals(project.getPackaging())) {
Expand Down Expand Up @@ -183,6 +188,49 @@ private void addGoals(MavenProject project, String owner, List<Object> tasks) {
}
}

/** Query Maven's merged plugin model and native parameter evaluator. No
* module/configuration model is inferred by the desktop or the backend. */
private void compilerFacts(MavenProject project, Map<String,Object> output) {
Plugin compiler=null;
for(Plugin candidate:project.getBuildPlugins()) if("maven-compiler-plugin".equals(candidate.getArtifactId())) {compiler=candidate.clone();break;}
if(compiler==null) return;
try {
if(compiler.getVersion()==null) compiler.setVersion(versionResolver.resolve(new DefaultPluginVersionRequest(compiler,session)).getVersion());
PluginDescriptor descriptor=pluginManager.getPluginDescriptor(compiler,project.getRemotePluginRepositories(),session.getRepositorySession());
MojoDescriptor mojo=descriptor.getMojo("compile");
org.apache.maven.plugin.MojoExecution execution=new org.apache.maven.plugin.MojoExecution(mojo,"default-compile");
org.codehaus.plexus.util.xml.Xpp3Dom merged=project.getGoalConfiguration("org.apache.maven.plugins","maven-compiler-plugin","default-compile","compile");
execution.setConfiguration(merged);
org.apache.maven.plugin.PluginParameterExpressionEvaluator evaluator=new org.apache.maven.plugin.PluginParameterExpressionEvaluator(session,execution);
for(String key:new String[]{"source","target","release","debug","showDeprecation","showWarnings"}) {
org.codehaus.plexus.util.xml.Xpp3Dom node=merged==null?null:merged.getChild(key);
Object value=node==null?null:evaluator.evaluate(node.getValue());
if(value==null) value=project.getProperties().getProperty("maven.compiler."+key);
if(value==null && mojo.getMojoConfiguration()!=null) {
org.codehaus.plexus.configuration.PlexusConfiguration defaults=mojo.getMojoConfiguration().getChild(key,false);
if(defaults!=null) {
String expression=defaults.getValue(null);
if(expression!=null) value=evaluator.evaluate(expression);
if(value==null || value.toString().contains("${")) value=defaults.getAttribute("default-value",null);
}
}
if(value!=null&&!value.toString().contains("${")) output.put("compiler."+key,value.toString());
}
List<String> arguments=new ArrayList<>();
org.codehaus.plexus.util.xml.Xpp3Dom args=merged==null?null:merged.getChild("compilerArgs");
if(args!=null) for(org.codehaus.plexus.util.xml.Xpp3Dom arg:args.getChildren()) {
Object evaluated=evaluator.evaluate(arg.getValue());
if(evaluated!=null) arguments.add(evaluated.toString());
}
output.put("compiler.arguments",Json.write(arguments));
Object release=output.get("compiler.release");
output.put("compiler.releaseEnabled",Boolean.toString(release!=null&&!release.toString().isEmpty()));
if(release!=null&&!release.toString().isEmpty()) output.put("compiler.target",release.toString());
} catch(Exception failure) {
throw new IllegalStateException("Maven compiler settings could not be evaluated.",failure);
}
}

/**
* The goal prefix and goals of a plugin. The descriptor needs the plugin
* jar, which Maven downloads like any build would; offline or without
Expand Down
Loading
Loading