Hi devs,
While reviewing a recent PR, I noticed that several runtime dependencies had been added to a -test-docker module. That’s sometimes needed, but I think it often means that the module under test is missing a dependency for a feature it implements: the test passes, but someone who installs that extension gets a broken feature.
So I had a look at the runtime dependencies of all our -test-docker poms (50 poms, 196 dependencies outside the feature being tested), and I’d like to brainstorm with you about some best practices for this. If we reach an agreement, I’d then document them on dev.xwiki.org and in our LLM knowledge base, and fix the poms.
I haven’t found any previous discussion on this exact topic. Related past discussions:
- [VOTE] Optional dependencies and Maven (2017, XCOMMONS-1229): https://lists.xwiki.org/hyperkitty/list/xwiki-devs@xwiki.org/thread/SWLLTKVV4JF6RLR6Z7NOEWJ6VV3I2JDM/
- Potentially missing deps on translation macro module (2013): https://lists.xwiki.org/hyperkitty/list/xwiki-devs@xwiki.org/thread/7WSYHXY2FRJMWHRN24S7OJJABGI2425D/
- Conditional optional dependencies (2023, no conclusion): Extension Manager feature for conditional installation of extension?
- Adding to minimaldependencies is technical debt (2024): Add dependency to xwiki-platform-search-api to the war
Here are some ideas to start the discussion.
Idea 1: A module declares the dependencies that its own features need
If the module’s pages, templates, JS or Java use a macro, script service, component, XClass, page, translation bundle, webjar or RequireJS module provided by another module, then the module declares a dependency on it. This would include the default implementation of an API the module depends on, when the feature can’t work without one (e.g. depending on wiki-user-api but needing a WikiUserManager implementation).
In other words, we wouldn’t rely on a test module, a flavor or the WAR to bring it. Declaring a dependency that the WAR also brings (e.g. through xwiki-platform-minimaldependencies) would be fine.
Question 2: What do we do for optional integrations?
Some dependencies only enable an integration that the module works without. The most common case is a module’s administration section: it needs administration-ui (for XWiki.ConfigurableClass), but without it the module works fine, its admin UI is just not visible. Same for a panel contributed by a module.
Today we do different things:
- a mandatory dependency (e.g.
export-pdf-ui,search-uiandckeditor-ui→administration-ui), - an optional dependency (e.g.
legacy-messagestream-ui→administration-ui,filter-ui/menu-ui/release-ui→panels-ui,linkchecker-ui→index-ui,like-ui→user-profile-ui), - no dependency at all, with the test module adding it (12 modules for
administration-ui, e.g.annotation-ui,like-ui,logging-ui,notifications-ui).
Since 2017, Extension Manager installs optional dependencies by default and lets users uninstall them, so <optional>true</optional> (with a comment saying what it enables) looks like a possible fit to me. However, in the 2017 thread Thomas said that optional dependencies were mainly meant for flavors, and that extensions should depend on what they use.
So, what do you think we should do?
- Mandatory dependency
- Optional dependency
- Something else?
Idea 3: A functional test module only adds runtime dependencies that the test itself needs, each with a comment
Every non-test-scope dependency of a -test-docker pom gets installed into the tested XWiki instance, so it can hide a missing dependency (see idea 1). A runtime dependency would stay in the test pom only when:
- it’s test infrastructure (e.g.
@WikisSourceneedswiki-creationjob+wiki-template-default, startup-time components, stubs), - it’s a feature the scenario only uses as a means (setting rights from the administration, sample pages to visit),
- it’s an optional integration that the test checks on purpose,
- the module can’t declare it (dependency cycle).
Each such dependency (or group) would have an XML comment saying what in the test needs it (and for a cycle, why the module can’t depend on it). “Required by FooIT” wouldn’t be enough.
A way to check: remove the dependency and run the test. If the feature itself breaks (and not just the test setup), it belongs in the module. When moving a dependency into a module, the functional tests of the modules depending on it also need to be run, since they now get it too (see XWIKI-23351, where adding websocket to realtime-ui broke the CKEditor tests and was reverted).
Idea 4: Dependencies needed by skin files are declared by the skin
xwiki-platform-minimaldependencies is only meant to define a minimal XWiki WAR, so it wouldn’t be the place to declare a dependency that a module is missing. Dependencies needed by Flamingo skin files (templates, etc.) would be declared in xwiki-platform-flamingo-skin-resources.
Question 5: What about the WAR templates (xwiki-platform-web-templates)?
Templates in web-templates (e.g. diff_macros.vm needs $services.diff, macros.vm needs $services.wiki.user) have no runtime dependencies at all. Ideally web-templates would declare them and flamingo-skin-resources would depend on it. From what I found, here’s why it isn’t done today:
web-templateswas split out ofxwiki-platform-webin 2021 only to be able to test the templates, and it inherited the “skinny WAR” decision of 2011 (XWIKI-6581, “[VOTE] Remove distribution (war) from xwiki-platform”: https://lists.xwiki.org/hyperkitty/list/xwiki-devs@xwiki.org/thread/VCXKXZKZKXPXLRCS3RJ4PPKBVSDREJ5B/): the WAR has no JAR dependencies because of Maven duplicating JARs with WAR dependencies, and the runtime dependencies are listed inminimaldependencies/distribution-war-dependenciesinstead (see the FIXME comments inminimaldependencies/pom.xml).web-wardepends onweb-templateswith theprovidedscope and unpacks it into/templates/. It’s not a core extension, and aruntimedependency on it makes EM install it as an extension (XWIKI-20964, XWIKI-20965 still open).- Doing it would need care: avoid
web-templates.jarending up inWEB-INF/lib(e.g. depend on it with<type>pom</type>), reactor cycles (rest-serverandattachment-apihave test dependencies onweb-templatesbut provide$services.rest/$services.attachment), and many services used by templates are optional.
Should we try to make web-templates declare its runtime deps (and if so, how), or keep the current approach for it?
What it would mean in practice
To give an idea of the impact, here’s what would need to change if we go with the ideas above. Module names omit the xwiki-platform- prefix.
Idea 1 (add a dependency to the module)
rest-server←wiki-user-default(WikiUserManageris injected, only the API is declared). Would also fix therestandappwithinminutestests.realtime-ui←websocket(XWIKI-23351, reopened)blocknote-api←websocket,wysiwyg-ui;blocknote-webjar←user-rest-defaultattachment-ui←wysiwyg-ui(the attachment selector uploads throughXWiki.WYSIWYG.FileUploader)notifications-ui←xwiki-commons-diff-script(mail template →diff_macros.vm); depends on question 5localization-webjar←localization-rest-default(needed by everyxwiki-l10n!user; would fix the poms ofattachment-picker,export-pdf,image-lightbox,livedata,panels,realtimeandsecurity-requiredrightsin one place). Already in every WAR, so no user-visible bug.livedata-livetable←livetable-ui;repository-server-ui←icon-script(both already in every WAR)
Question 2 (depending on the answer)
administration-uiin:annotation-ui,attachment-validation-ui,image-style-ui,index-ui,index-tree-ui,like-ui,logging-ui,model-validation-ui,notifications-ui,office-ui,xclass-ui,repository-server-uipanels-uiinhelp-uiuser-profile-uiinadministration-ui- Possibly aligning
export-pdf-ui,search-uiandckeditor-ui, which have a mandatory dependency onadministration-ui
Idea 3 (test poms: add or fix comments, remove what moved)
- Missing comment (19):
extension-test-docker(8 deps),export-pdf,extension-security,filter,flamingo-skin,flamingo-theme,notifications,realtime-wysiwyg,repository,skin,webjars(2),whatsnew(wherecommons-ioshould also betestscoped) - Vague or wrong comment (31):
administration,appwithinminutes,ckeditor,edit,flamingo-skin(6),image-style,invitation,like,localization,notifications,rest,search,security-authentication,security-requiredrights,sharepage,tour,user-profile,user-rest,wiki - Redundant (11, already brought by the module under test or by the test framework):
administration,ckeditor,filter,flamingo-skin,linkchecker,menu,panels - To verify by running the test without them (15):
administration,blocknote,extension(4),flamingo-skin(3),flamingo-theme,index,livedata,observation(2),repository
Idea 4
flamingo-skin-resources←xwiki-commons-diff-script,diff-xml(previewdiff.vmandchanges.vmneed the diff services), removing them fromflamingo-skin-test-docker
WDYT? Any other ideas or cases I’ve missed?
Thanks
PS: This post was co-written with Claude Code, which also did the review of the test poms.