diff --git a/Cargo.lock b/Cargo.lock index b2b2202..672b55a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -763,6 +763,7 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbc04313cab124e498ab1724e739720807b6dc405b9ed0edc5860164d2e4ff70" dependencies = [ + "indexmap", "xml", ] diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 70e272b..b3073fc 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -23,6 +23,6 @@ dunce = "1.0.5" sha2.workspace = true java-properties = "2.0.0" -xmltree = "0.12.0" +xmltree = { version = "0.12.0", features = ["attribute-order"] } jsonc-parser = { version = "0.34.0", features = ["cst", "serde"] } libc = "0.2" diff --git a/backend/src/lib.rs b/backend/src/lib.rs index e54912d..a991261 100644 --- a/backend/src/lib.rs +++ b/backend/src/lib.rs @@ -58,6 +58,7 @@ pub mod project_model; pub mod project_settings; pub mod run; pub mod settings_session; +pub mod web_facet; use crate::launch::LAUNCH_FUNCTION_ID; use crate::run::{ diff --git a/backend/src/module_structure.rs b/backend/src/module_structure.rs index 60c128f..24685fd 100644 --- a/backend/src/module_structure.rs +++ b/backend/src/module_structure.rs @@ -586,7 +586,7 @@ pub fn edit( if flag(&entry, EXPORTED)? { element.attributes.insert(EXPORTED.into(), "true".into()); } else { - element.attributes.remove(EXPORTED); + element.attributes.shift_remove(EXPORTED); } set_nested(&mut element, TEST, flag(&entry, TEST)?.then_some("true")); next.push(element); diff --git a/backend/src/project_settings.rs b/backend/src/project_settings.rs index a8bd0dd..25bf76b 100644 --- a/backend/src/project_settings.rs +++ b/backend/src/project_settings.rs @@ -368,11 +368,20 @@ impl ProjectSettings { }; let mut groups = if libraries { let mut groups = Vec::new(); - if !module_sources.is_empty() { + if module_sources + .iter() + .any(|source| source["group"] == "modules") + { groups.push( json!({"id":"modules","title":local(zh,"Modules","模块"),"layout":"sidebar"}), ); } + if module_sources + .iter() + .any(|source| source["group"] == "facets") + { + groups.push(json!({"id":"facets","title":local(zh,"Web Facets","Web Facet"),"layout":"sidebar"})); + } if module_sources.is_empty() || sources.iter().any(|source| source["group"] == "libraries") { @@ -468,6 +477,8 @@ impl ProjectSettings { // (folder, source file, source) in folder order, so that an // enclosing module comes before the modules inside it. let mut rows: Vec<(PathBuf, PathBuf, Value)> = Vec::new(); + let mut facet_sources = Vec::new(); + let mut unreadable_facets: u64 = 0; for (project, file, revision, classpath, name) in classpaths { let rel = project_model::relative_inside(root, &file).ok_or_else(fail)?; let choices = modules::Choices { @@ -479,6 +490,32 @@ impl ProjectSettings { if classpath.editable { bindings.insert(id.clone(), file.clone()); } + // Web Facet is stored in another native XML source. Keep it + // separate from .classpath so each save replaces exactly one file. + // A facet file this page cannot edit safely costs only its own + // source: the module still shows, and the page reports one + // degradation for all such files. + if facet_sources.len() < 256 { + let facet_file = project.join(crate::web_facet::FILE); + if fs::symlink_metadata(&facet_file).is_ok_and(|info| info.is_file()) { + let facet = read(&facet_file).and_then(|(bytes, revision)| { + Ok(crate::web_facet::fields(zh, &bytes)?.map(|fields| (revision, fields))) + }); + match facet { + Ok(Some((revision, fields))) => { + let rel = project_model::relative_inside(root, &facet_file) + .ok_or_else(fail)?; + let facet_id = format!("facet{:x}", Sha256::digest(rel.as_bytes())); + if paths.insert(facet_file.clone()) { + bindings.insert(facet_id.clone(), facet_file); + facet_sources.push(json!({"id":facet_id,"group":"facets","title":name.clone(),"path":rel,"revision":revision,"writable":true,"fields":fields})); + } + } + Ok(None) => {} + Err(_) => unreadable_facets += 1, + } + } + } rows.push((project, file, json!({"id":id,"group":"modules","title":name,"path":rel,"revision":revision,"writable":classpath.editable,"fields":fields}))); } let mut unavailable = 0; @@ -554,6 +591,16 @@ impl ProjectSettings { } sources.push(source); } + sources.extend(facet_sources); + if unreadable_facets > 0 { + // An error from `degraded` only means the arguments were invalid, + // so the page itself stands. + let _ = context.diagnostics().degraded( + context.function_id(), + "webFacetUnreadable", + Some(unreadable_facets), + ); + } Ok(sources) } /// Prepares only the confirmed native source; publication belongs to the host. @@ -591,6 +638,8 @@ impl ProjectSettings { let values = params["values"].as_object().ok_or_else(fail)?; let replacement = if path.ends_with(".classpath") { crate::module_structure::edit(&bytes, parent, values)? + } else if path.ends_with(crate::web_facet::FILE) { + crate::web_facet::edit(&bytes, values)? } else if path.ends_with(SETTINGS) { let workspace = context.workspace_context().ok_or_else(fail)?; let options = session.model_options(workspace.context_id()); @@ -769,8 +818,11 @@ pub(crate) fn write_classpath( xmltree::XMLNode::Element(_) => doc .write_with_config( &mut out, + // Eclipse writes ``; matching it keeps a + // save from rewriting every self-closing line. xmltree::EmitterConfig::new() .perform_indent(true) + .pad_self_closing(false) .write_document_declaration(false), ) .map_err(|_| fail())?, diff --git a/backend/src/web_facet.rs b/backend/src/web_facet.rs new file mode 100644 index 0000000..30a94a7 --- /dev/null +++ b/backend/src/web_facet.rs @@ -0,0 +1,277 @@ +//! Safe editing of the Eclipse WTP Dynamic Web Module facet version. +//! The source-settings host owns conflict checking and publication. This +//! module prepares only an XML replacement and preserves unrelated entries. +use lithe_plugin_sdk::{FunctionError, PluginError, Value}; +use serde_json::{json, Map}; +use xmltree::{Element, XMLNode}; + +pub const FILE: &str = ".settings/org.eclipse.wst.common.project.facet.core.xml"; +const FIELD: &str = "web-facet-version"; +/// Dynamic Web Module versions WTP offers, with the lowest `jst.java` level +/// each one accepts (1.x levels are written as x). A version is offered only +/// when the project's installed `jst.java` facet satisfies it, so a save never +/// produces a combination Eclipse itself rejects. +const SUPPORTED: &[(&str, u32)] = &[ + ("2.2", 3), + ("2.3", 3), + ("2.4", 3), + ("2.5", 5), + ("3.0", 6), + ("3.1", 7), + ("4.0", 8), + ("5.0", 8), + ("6.0", 11), + ("6.1", 17), +]; + +fn minimum_java(version: &str) -> Option { + SUPPORTED + .iter() + .find(|(known, _)| *known == version) + .map(|(_, java)| *java) +} + +/// The Java level of a `jst.java` facet version: "1.8" is 8, "17" is 17. +fn java_level(version: &str) -> Option { + let level = version.strip_prefix("1.").unwrap_or(version); + level.parse().ok() +} + +/// Whether a project whose `jst.java` facet is `java` may use `web`. +/// A project without a readable `jst.java` facet is not constrained here. +fn compatible(web: &str, java: Option) -> bool { + match (minimum_java(web), java) { + (None, _) => false, + (Some(_), None) => true, + (Some(minimum), Some(level)) => level >= minimum, + } +} + +fn failed() -> FunctionError { + PluginError::new( + "java.webFacet.invalid", + "The Web Facet source is invalid or has changed. Reload the Java project structure.", + ) + .into() +} + +fn parsed(bytes: &[u8]) -> Result { + if bytes + .windows(9) + .any(|window| window.eq_ignore_ascii_case(b" Result, FunctionError> { + installed_version(document, "jst.web") +} + +fn java_version(document: &Element) -> Result, FunctionError> { + Ok(installed_version(document, "jst.java")? + .as_deref() + .and_then(java_level)) +} + +/// The version of the one installed `facet`; more than one is invalid. +fn installed_version(document: &Element, facet: &str) -> Result, FunctionError> { + let mut version = None; + for element in document.children.iter().filter_map(XMLNode::as_element) { + if element.name != "installed" + || element.attributes.get("facet").map(String::as_str) != Some(facet) + { + continue; + } + if version.is_some() { + return Err(failed()); + } + let found = element.attributes.get("version").ok_or_else(failed)?; + if found.is_empty() || found.len() > 16 { + return Err(failed()); + } + version = Some(found.clone()); + } + Ok(version) +} + +/// Returns the fields of one existing Eclipse Dynamic Web Module facet. +/// If a project has no jst.web facet, it gets no editable Web Facet source. +pub fn fields(zh: bool, bytes: &[u8]) -> Result>, FunctionError> { + let document = parsed(bytes)?; + let Some(version) = web_version(&document)? else { + return Ok(None); + }; + let java = java_version(&document)?; + let mut options: Vec = SUPPORTED + .iter() + .filter(|(value, _)| *value == version || compatible(value, java)) + .map(|(value, _)| json!({"value": value, "title": value})) + .collect(); + if minimum_java(&version).is_none() { + options.push(json!({"value": version, "title": version})); + } + Ok(Some(vec![json!({ + "id": FIELD, + "title": if zh { "Dynamic Web Module 版本" } else { "Dynamic Web Module version" }, + "kind": "enum", + "section": "Facet", + "value": version, + "effectiveValue": version, + "effectiveSource": if zh { "Eclipse WTP 工程文件" } else { "Eclipse WTP project file" }, + "options": options, + "description": if zh { + "仅修改现有 Eclipse jst.web Facet 的版本,只列出与本模块 Java Facet(jst.java)兼容的版本。不会修改 web.xml、.classpath、Web 根或其他 Facet;升级到 5.0 及以上时,代码和 web.xml 需要自行迁移到 jakarta 命名空间。" + } else { + "Changes only the version of an existing Eclipse jst.web facet, offering the versions the module's Java facet (jst.java) supports. web.xml, classpaths, Web roots and other facets are not edited; moving to 5.0 or later also needs the code and web.xml moved to the jakarta namespace." + } + })])) +} + +/// Applies only the approved version field. The caller owns the source +/// revision and writes this output into a host-staged temporary file. +pub fn edit(bytes: &[u8], values: &Map) -> Result, FunctionError> { + if values.len() != 1 || !values.contains_key(FIELD) { + return Err(failed()); + } + let chosen = values[FIELD].as_str().ok_or_else(failed)?; + let mut document = parsed(bytes)?; + let original = web_version(&document)?.ok_or_else(failed)?; + if chosen == original { + return Ok(bytes.to_vec()); + } + if !compatible(chosen, java_version(&document)?) { + return Err(failed()); + } + let mut changed = false; + for node in &mut document.children { + if let XMLNode::Element(element) = node { + if element.name == "installed" + && element.attributes.get("facet").map(String::as_str) == Some("jst.web") + { + element + .attributes + .insert("version".to_owned(), chosen.to_owned()); + changed = true; + break; + } + } + } + if !changed { + return Err(failed()); + } + crate::project_settings::write_classpath(bytes, &document) +} + +#[cfg(test)] +mod tests { + use super::*; + + const DOCUMENT: &[u8] = br#" + + + + + + +"#; + + #[test] + fn reads_a_web_facet_and_preserves_other_facets_on_edit() { + let fields = fields(true, DOCUMENT).unwrap().unwrap(); + assert_eq!(fields[0]["value"], "3.1"); + assert_eq!(fields[0]["id"], FIELD); + let change = json!({"web-facet-version": "4.0"}); + let modified = edit(DOCUMENT, change.as_object().unwrap()).unwrap(); + let output = String::from_utf8(modified).unwrap(); + assert!(output.contains("jst.web")); + // Attribute order and Eclipse's self-closing style are kept, so a + // save changes only the version in a diff. + assert!(output.contains("")); + assert!(output.contains("")); + assert!(output.contains("jst.java")); + assert!(output.contains("")); + } + + #[test] + fn unchanged_versions_preserve_bytes_exactly() { + let change = json!({"web-facet-version": "3.1"}); + assert_eq!( + edit(DOCUMENT, change.as_object().unwrap()).unwrap(), + DOCUMENT + ); + } + + #[test] + fn rejects_unexpected_edits_and_conflicting_web_facets() { + for value in [ + json!({"web-facet-version": "7.5"}), + json!({"web-facet-version": null}), + json!({"other": "4.0"}), + ] { + assert!(edit(DOCUMENT, value.as_object().unwrap()).is_err()); + } + let duplicate = br#" + + + "#; + assert!(fields(false, duplicate).is_err()); + } + + #[test] + fn offers_and_accepts_only_versions_the_java_facet_supports() { + let java8 = br#" + + +"#; + let fields = fields(false, java8).unwrap().unwrap(); + let offered: Vec<&str> = fields[0]["options"] + .as_array() + .unwrap() + .iter() + .map(|option| option["value"].as_str().unwrap()) + .collect(); + assert!(offered.contains(&"4.0")); + assert!(offered.contains(&"5.0")); + assert!(!offered.contains(&"6.0")); + assert!(!offered.contains(&"6.1")); + let too_new = json!({"web-facet-version": "6.0"}); + assert!(edit(java8, too_new.as_object().unwrap()).is_err()); + let allowed = json!({"web-facet-version": "5.0"}); + assert!(edit(java8, allowed.as_object().unwrap()).is_ok()); + + let java17 = json!({"web-facet-version": "6.1"}); + assert!(edit(DOCUMENT, java17.as_object().unwrap()).is_ok()); + } + + #[test] + fn an_unknown_current_version_stays_selectable() { + let unknown = + br#""#; + let fields = fields(false, unknown).unwrap().unwrap(); + let offered = fields[0]["options"].as_array().unwrap(); + assert!(offered.iter().any(|option| option["value"] == "9.9")); + let same = json!({"web-facet-version": "9.9"}); + assert_eq!(edit(unknown, same.as_object().unwrap()).unwrap(), unknown); + } + + #[test] + fn non_web_facets_are_not_editable() { + let plain = + br#""#; + assert!(fields(false, plain).unwrap().is_none()); + } + + #[test] + fn refuses_doctype_and_external_entities() { + let dangerous = + br#"]> +"#; + assert!(fields(false, dangerous).is_err()); + } +} diff --git a/docs/assets/module-structure/web-facet-en-dark.png b/docs/assets/module-structure/web-facet-en-dark.png new file mode 100644 index 0000000..a3bdac4 Binary files /dev/null and b/docs/assets/module-structure/web-facet-en-dark.png differ diff --git a/docs/assets/module-structure/web-facet-zh-Hans-light.png b/docs/assets/module-structure/web-facet-zh-Hans-light.png new file mode 100644 index 0000000..623eaae Binary files /dev/null and b/docs/assets/module-structure/web-facet-zh-Hans-light.png differ diff --git a/docs/feature-matrix.md b/docs/feature-matrix.md index 0607775..ec120c6 100644 --- a/docs/feature-matrix.md +++ b/docs/feature-matrix.md @@ -51,3 +51,10 @@ | 项目结构页无头截图 | implemented / verified | — | — | `scripts/compiler/visual.mjs` 渲染真实投影(中英、明暗),截图见 `docs/assets/module-structure/` | 2026-11-17:macOS arm64 本机用 JDT LS 1.61.0 自动化通过。需要宿主声明 `sourceSettings` 1([1lck/Lithe-IDEA#2087](https://github.com/1lck/Lithe-IDEA/pull/2087));原生文件选择器、Windows 与 Linux 结果由实机验收和 CI 补充。 + +## Eclipse WTP Web Facet 版本编辑 + +| 能力 | macOS | Windows | Linux | 证据 | +| --- | --- | --- | --- | --- | +| Java 项目结构中的 Web Facet 独立原生来源、按 jst.java 限定可选版本、版本读写与修改前 revision 校验;无法安全编辑的 Facet 文件只跳过该来源并上报一次降级 | implemented / verified | implemented / pending | implemented / pending | `backend/src/web_facet.rs` 单元测试;`scripts/compiler/test-module-structure.mjs` 用真实 JDT LS 1.61 覆盖读取、不合规文件、版本限制、保存,以及所有来源和字段 ID 符合 Core 规则;`scripts/compiler/visual.mjs` 在固定宿主上经 Core `ReadSourceSettings` 渲染 Web Facet 页,截图见 `docs/assets/module-structure/web-facet-*.png`。2026-11-18 macOS arm64 本机通过;Linux 由 CI 的同一脚本覆盖;Windows 与原生窗口点按待实机验收 | +| 编辑 WTP .component、IDEA .iml Web Facet、WTP 服务器配置 | not-implemented | not-implemented | not-implemented | 单文件安全修改,不覆盖其他 IDE 模型 | diff --git a/docs/module-structure.md b/docs/module-structure.md index 2529f34..eeab309 100644 --- a/docs/module-structure.md +++ b/docs/module-structure.md @@ -42,3 +42,13 @@ JRE 下拉框可选“工作区默认 JRE”或 JavaSE-1.8/11/17/21/25 执行环 ## 验证 `scripts/compiler/test-module-structure.mjs` 用真实 JDT LS 打开两个 Eclipse 工程和一个 Maven 模块:检查读取页面不写任何项目文件、Maven 模块只读并带解析出的类路径;再通过页面添加模块依赖(导出)、工作区外的 JAR、新的源文件夹并修改输出文件夹,确认写回的 `.classpath` 保留注释和源码附件,JDT 随后编译成功,class 落在新的输出文件夹;插件包和 JDT LS 安装不变。`scripts/compiler/visual.mjs` 用宿主 Viva 无头窗口渲染同一份真实投影(中英、明暗)。 + +## Eclipse WTP Web Facet + +带有 `.classpath` 的 Eclipse 工程如果同时存在 `.settings/org.eclipse.wst.common.project.facet.core.xml` 中的 `jst.web`,项目结构页会额外显示「Web Facets」分组。可在独立来源中选择 Dynamic Web Module 版本,再点击保存。下拉框只列出与同一文件中 `jst.java` 版本兼容的版本(例如 Java 8 最高到 5.0,6.0 需要 Java 11,6.1 需要 Java 17),与 Eclipse 自己的 Facet 约束一致。保存前宿主检查原始版本,写回时仅编辑此 XML 文件中的现有 `jst.web` 版本,保留其他 Facet、注释、属性顺序和 Eclipse 的 `/>` 写法,版本控制里只看到这一处改动。 + +![Web Facet 来源(中文,浅色)](assets/module-structure/web-facet-zh-Hans-light.png) + +文件中有重复的 `jst.web`、DOCTYPE 或其他无法安全编辑的内容时,这个模块不显示 Web Facet 来源,模块本身和项目结构页其他部分照常显示,后端对本次读取上报一次 `webFacetUnreadable` 降级。 + +这不是 Web Facet 的完整编辑器:不会自动创建缺失的 Facet,不改 WTP `.component` 的 Web 根和部署装配,也不写 IDEA `.iml`;后者仍为只读工程模型。 diff --git a/e2e/host/desktop/internal/settingswindow/plugin_native_source_test.go b/e2e/host/desktop/internal/settingswindow/plugin_native_source_test.go index 18de821..16428f1 100644 --- a/e2e/host/desktop/internal/settingswindow/plugin_native_source_test.go +++ b/e2e/host/desktop/internal/settingswindow/plugin_native_source_test.go @@ -20,6 +20,7 @@ import ( "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/gfx" "github.com/vivaui/viva/headless" ) @@ -174,6 +175,20 @@ func TestPluginNativeSourceVisual(t *testing.T) { shot(item.name + "-dependencies") d.click("service") shot(item.name + "-maven") + // The Web Facet source of app: the lower of the two + // sidebar entries titled app, under the Web Facet group. + var facet gfx.Hit + found := false + for _, hit := range d.driver.Snapshot().Hits { + if hit.Label == "app" && !hit.IsLabel && !hit.Backdrop && !hit.ID.IsZero() && (!found || hit.Bounds.Y > facet.Bounds.Y) { + facet, found = hit, true + } + } + if !found { + t.Fatal("no Web Facet source titled app") + } + d.clickHit(facet) + shot(item.name + "-web-facet") } }) } diff --git a/scripts/compiler/test-module-structure.mjs b/scripts/compiler/test-module-structure.mjs index a4414b3..5156d55 100644 --- a/scripts/compiler/test-module-structure.mjs +++ b/scripts/compiler/test-module-structure.mjs @@ -5,6 +5,10 @@ // folders, output folder and dependencies (another module, exported, and a // JAR outside the workspace) to its .classpath, keeping what the page does // not show. JDT must then compile the module against the new classpath. +// The app module is also an Eclipse WTP Dynamic Web Module: the page offers +// its jst.web version limited by its jst.java facet and saves only that +// attribute; common carries a facet file the page cannot edit safely, which +// costs only its Web Facet source, never the page. // Reading the page writes nothing, and the package and the JDT LS // installation stay unchanged. // Usage: node scripts/compiler/test-module-structure.mjs @@ -61,6 +65,10 @@ try{ write(join(app,'.classpath'),original); write(join(app,'src/demo/App.java'),'package demo; public class App { public static void main(String[] args) { System.out.print(com.common.Greeter.greet() + com.acme.Util.value() + demo.extra.Extra.NAME); } }'); write(join(app,'extra/demo/extra/Extra.java'),'package demo.extra; public class Extra { public static final String NAME = "extra"; }'); + const FACETS='.settings/org.eclipse.wst.common.project.facet.core.xml'; + const facets=`\n\n \n \n \n \n\n`; + write(join(app,FACETS),facets); + write(join(common,FACETS),''); write(join(service,'pom.xml'),'4.0.0test.litheservice11717'); write(join(service,'src/main/java/demo/Service.java'),'package demo; public class Service { }'); @@ -87,6 +95,7 @@ try{ const page=language=>invoke('libraries.settings',{context:{language,builds:[]}}); const module=(snapshot,title)=>snapshot.sources.find(source=>source.group==='modules'&&source.title===title); const field=(source,id)=>source.fields.find(item=>item.id===id); + const facet=(snapshot,title)=>snapshot.sources.find(source=>source.group==='facets'&&source.title===title); await report.step('JDT imports the two Eclipse projects and the Maven module',async()=>{ await until(()=>execute('java.project.getAll'),projects=>[common,app,service].every(project=>projects.some(uri=>samePath(fileURLToPath(uri),project))),'JDT project import',240000); @@ -113,6 +122,20 @@ try{ assert.equal(serviceModule.path,'service/pom.xml'); const resolved=field(serviceModule,'dependencies').value; assert.ok(resolved.some(entry=>entry.kind==='classes'&&slashes(entry.value).endsWith('target/classes')),JSON.stringify(resolved)); + // Core refuses the whole page (plugin.settings.invalidSourceEditor) for one + // group, source or field ID outside its identifier alphabet. + const coreID=/^[a-z0-9-]{1,128}$/; + for(const item of [...before.groups,...before.sources,...before.sources.flatMap(source=>source.fields)])assert.match(item.id,coreID,`Core identifier: ${item.id}`); + assert.ok(before.groups.some(group=>group.id==='facets'),JSON.stringify(before.groups)); + const appFacet=facet(before,'app');assert.ok(appFacet,JSON.stringify(before.sources.map(source=>[source.group,source.title]))); + assert.equal(appFacet.path,'app/'+FACETS); + const web=field(appFacet,'web-facet-version'); + assert.equal(web.value,'3.1'); + const offered=web.options.map(option=>option.value); + assert.ok(offered.includes('4.0')&&offered.includes('5.0'),JSON.stringify(offered)); + assert.ok(!offered.includes('6.0')&&!offered.includes('6.1'),'Java 8 projects must not be offered Web 6.x: '+JSON.stringify(offered)); + assert.equal(facet(before,'common'),undefined,'An unsafe facet file gets no editable source'); + assert.ok(module(before,'common'),'An unsafe facet file must not hide its module'); assert.deepEqual(projectFiles(),baseline,'Reading the structure page must not write project files'); // The public projection, rendered by the native host in scripts/compiler/visual.mjs. capture('libraries-modules-zh',before); @@ -137,6 +160,19 @@ try{ assert.equal(field(saved,'output').value,'build/classes'); assert.deepEqual(field(saved,'dependencies').value.map(entry=>[entry.kind,entry.title,entry.attributes?.exported??false]),[['module','common',true],['archive','old.jar',false],['archive','acme-util.jar',false]]); }); + await report.step('saving the Web Facet changes only the jst.web version',async()=>{ + const appFacet=facet(before,'app'); + const stageFile=join(stage,'facet-stage.xml');writeFileSync(stageFile,''); + await assert.rejects(invoke('compiler.prepareSettings',{operation:'editSource',sourceID:appFacet.id,revision:appFacet.revision,outputFile:stageFile,values:{'web-facet-version':'6.0'}}),'Web 6.0 needs Java 11 and must be refused'); + const edit=await invoke('compiler.prepareSettings',{operation:'editSource',sourceID:appFacet.id,revision:appFacet.revision,outputFile:stageFile,values:{'web-facet-version':'4.0'}}); + assert.equal(edit.changed,true); + const text=readFileSync(stageFile,'utf8'); + for(const kept of['','{ const errors=()=>JSON.stringify([...problems].filter(([,messages])=>messages.length)); // A full build cleans every project first and may build the module before