11# Writing and migrating extensions
22
3- OIE extensions can declare a minimum extension API version instead of listing
4- every compatible engine release. The current extension API is ** 1.0.0** . It is
5- versioned independently of both OIE releases and your extension's own releases.
3+ OIE extensions can declare dependencies on the engine API and on other plugins.
4+ The current extension API is ** 1.0.0** , versioned independently of OIE releases
5+ and extension releases. Declaring an API requirement avoids listing every
6+ compatible engine release.
67
78This guide covers new plugins and connectors, migrating existing extensions,
89and validating an archive before publishing it. Use an OIE build containing
@@ -18,9 +19,10 @@ current API version is defined in
1819 your extension JARs. The current engine build uses JDK 17.
19202 . Choose your extension's own ` pluginVersion ` , such as ` 1.0.0 ` . For plugins
2021 ** and connectors** , this is your release version; it need not match OIE.
21- 3 . Set ` minExtensionApiVersion ` to the lowest OIE extension API that provides
22- every API your extension uses. For the initial contract, use ` 1.0.0 ` . Do not
23- substitute the engine release number or a build-time engine-version token.
22+ 3 . Add an ` engine-api ` dependency with ` minVersion ` set to the lowest OIE
23+ extension API that provides every API your extension uses. For the initial
24+ contract, use ` 1.0.0 ` . Do not substitute the engine release number or a
25+ build-time engine-version token.
24264 . Declare the appropriate metadata and libraries as shown below, then follow
2527 [ Packaging and validation] ( #packaging-and-validation ) .
2628
@@ -43,7 +45,9 @@ that implementation.
4345 <name >Example Plugin</name >
4446 <author >Example Author</author >
4547 <pluginVersion >1.0.0</pluginVersion >
46- <minExtensionApiVersion >1.0.0</minExtensionApiVersion >
48+ <dependencies >
49+ <dependency type =" engine-api" minVersion =" 1.0.0" />
50+ </dependencies >
4751 <description >An example server plugin.</description >
4852 <serverClasses >
4953 <string >com.example.oie.ExamplePlugin</string >
@@ -69,7 +73,9 @@ Connectors use `source.xml` and/or `destination.xml`, each with a
6973 <name >Example Listener</name >
7074 <author >Example Author</author >
7175 <pluginVersion >1.0.0</pluginVersion >
72- <minExtensionApiVersion >1.0.0</minExtensionApiVersion >
76+ <dependencies >
77+ <dependency type =" engine-api" minVersion =" 1.0.0" />
78+ </dependencies >
7379 <description >An example source connector.</description >
7480 <clientClassName >com.example.oie.ExampleListener</clientClassName >
7581 <serverClassName >com.example.oie.ExampleReceiver</serverClassName >
@@ -90,6 +96,37 @@ and [TCP destination](../server/src/main/resources/com/mirth/connect/connectors/
9096for their respective structures. If the connector also supplies a ` plugin.xml ` ,
9197that descriptor needs its own compatibility declaration too.
9298
99+ ### Requiring another plugin
100+
101+ Add a ` plugin ` dependency alongside the engine requirement:
102+
103+ ``` xml
104+ <dependencies >
105+ <dependency type =" engine-api" minVersion =" 1.0.0" />
106+ <dependency type =" plugin" name =" Provider Plugin" minVersion =" 2.1.0" />
107+ </dependencies >
108+ ```
109+
110+ The ` name ` must exactly match the provider's metadata ` name ` , including case;
111+ it is not the directory ` path ` , class name, or JAR name. The version is checked
112+ against that provider's ** ` pluginVersion ` ** , independently of the engine API.
113+ Both plugins and connectors can require plugins; connectors cannot be named
114+ as dependency providers. Keep a provider's name stable between releases.
115+
116+ All dependencies are required. A provider must be installed, enabled, satisfy
117+ the version requirement, and satisfy its own dependencies. Install providers
118+ first, or package the consumer and its providers together in one ZIP. OIE
119+ does not download dependencies. Optional dependencies and version ranges are
120+ not supported.
121+
122+ Dependencies control availability and compatibility. They do not change
123+ class initialization or start order: existing weights and conditions still
124+ apply. They do not guarantee that a provider's service has initialized or
125+ started successfully. Code that uses another plugin's services must handle
126+ its lifecycle and runtime failures. Declare dependencies on every descriptor
127+ that needs the provider, including server, Administrator, shared-library, and
128+ controller hooks.
129+
93130## Migrating an existing extension
94131
951321 . Build and test the extension against an OIE build containing this feature.
@@ -118,33 +155,48 @@ To:
118155
119156``` xml
120157<pluginVersion >2.3.0</pluginVersion >
121- <minExtensionApiVersion >1.0.0</minExtensionApiVersion >
158+ <dependencies >
159+ <dependency type =" engine-api" minVersion =" 1.0.0" />
160+ </dependencies >
122161```
123162
124- You may retain ` mirthVersion ` , but a non-null ` minExtensionApiVersion ` replaces
125- its check completely; the two are not combined. A future API requirement will
126- still reject the extension even if the legacy engine release matches. If any
127- other descriptor in the ZIP retains only a legacy requirement, it must still
128- match the engine release or installation of the entire archive is rejected.
163+ Add ` plugin ` entries for any required plugins and test against the oldest
164+ provider versions you declare. Merely adding metadata does not remove a
165+ runtime dependency or make incompatible provider releases usable.
166+
167+ You may retain ` mirthVersion ` , but an ` engine-api ` dependency replaces its
168+ check completely. A future API requirement still rejects the extension even
169+ if the legacy engine release matches. Every descriptor in the ZIP must pass
170+ its own checks or the entire archive is rejected.
171+
172+ If you already use ` <minExtensionApiVersion>1.0.0</minExtensionApiVersion> ` , it
173+ remains supported. To migrate, remove that element and add the corresponding
174+ ` engine-api ` dependency. Declaring both is invalid. Plugin dependencies can
175+ also be added while retaining either the shorthand API requirement or legacy
176+ release matching.
129177
130178### Supporting older engines
131179
132- Engines predating this feature cannot read the new metadata field. Including
133- both fields does ** not** make the same archive compatible with those engines.
180+ Engines predating dependency-list support cannot read ` dependencies ` .
181+ Including legacy fields does ** not** make the same archive compatible with
182+ those engines.
134183If you need to support them, publish a separately identified legacy archive
135- that omits ` minExtensionApiVersion ` and retains its tested ` mirthVersion ` list.
184+ that omits ` dependencies ` and ` minExtensionApiVersion ` and retains its tested
185+ ` mirthVersion ` list. Document and verify its plugin prerequisites separately.
136186Do not claim an older release supports API 1.0.0 merely because your extension
137187previously ran on it. To return an archive to legacy matching, remove the API
138- field and restore the tested release list; leaving the API field empty rejects
139- the extension.
188+ declaration and restore the tested release list; leaving an API requirement
189+ empty rejects the extension.
140190
141191## Packaging and validation
142192
143193Keep the existing extension ZIP layout: an extension directory at the archive
144194root, containing its metadata and libraries. For the plugin template above,
145195include ` example/ ` , ` example/plugin.xml ` , and ` example/example-server.jar ` .
146196The metadata ` path ` must match that directory, and each ` library ` path is
147- relative to it. Do not wrap the extension directory in another ` extensions/ `
197+ relative to it. Keep package-directory spelling and case unchanged when
198+ updating or uninstalling an extension. Archive paths that differ only by case
199+ are rejected to avoid filesystem-dependent results. Do not wrap the extension directory in another ` extensions/ `
148200directory. Library declarations are direct children of the metadata root,
149201not nested under a ` libraries ` element. Include directory entries before their
150202files, as normal recursive ZIP packaging does:
@@ -167,27 +219,61 @@ Before publishing an archive:
167219 compatible API, reuse the ** same archive** without changing its metadata.
168220 For an existing extension, also test upgrading an installation containing
169221 the previous extension version and any stored configuration it owns.
222+ 5 . For plugin dependencies, test a missing or disabled provider, a provider
223+ below the minimum, and a provider with a different major version. Check
224+ transitive failures, dependency cycles, and recovery after correcting the
225+ declarations or enabling compatible providers. Verify a provider update,
226+ disable, or removal cannot break an enabled consumer with satisfied
227+ dependencies.
170228
171229An incompatible requirement is rejected during installation before the archive
172- payload is extracted. Already installed incompatible extensions are excluded
173- from launcher library selection and engine metadata loading. Compatibility
174- metadata declares a requirement; it does not prove binary or runtime behavior.
230+ payload is extracted. Installation checks the complete inventory for the next
231+ startup: installed packages, pending removals, staged installations, and every
232+ descriptor in the new ZIP. Descriptor order within the ZIP does not determine
233+ dependency availability. Pending installs replace the corresponding package
234+ directory, including its descriptors.
235+
236+ A provider update, disable, or removal is rejected if it would break the
237+ dependencies of an enabled consumer whose requirements currently pass. Disable
238+ or uninstall consumers first when intentionally removing their providers.
239+ Restart the server and Administrator to apply staged changes; staging does
240+ not unload classes from a running process.
241+
242+ At startup, dependency checks run before extension libraries are admitted and
243+ before metadata is made available to the engine. Unsatisfied extensions are
244+ excluded, with diagnostics identifying the requirement. Disabled consumers
245+ still need valid declarations and engine compatibility, but their plugin
246+ requirements are checked when they are enabled. Compatibility metadata
247+ declares a requirement; it does not prove binary or runtime behavior.
175248
176249## Compatibility rules
177250
178- The engine API must be at least the requested version and have the same major
179- number. As a hypothetical later version, engine API ` 1.2.0 ` accepts a minimum of ` 1.0.0 ` or ` 1.2.0 ` ,
180- but rejects ` 1.3.0 ` and ` 2.0.0 ` . These are ** API versions** , not engine releases.
251+ For either dependency type, the available version must be at least ` minVersion `
252+ and have the same major number. For example, engine API ` 1.2.0 ` accepts a
253+ minimum of ` 1.0.0 ` or ` 1.2.0 ` , but rejects ` 1.3.0 ` and ` 2.0.0 ` . A plugin
254+ requirement of ` 2.1.0 ` accepts provider release ` 2.2.0 ` , but rejects ` 2.0.0 `
255+ and ` 3.0.0 ` . Plugin authors should use major version changes to signal
256+ incompatible changes to their published extension interfaces.
181257
182258Versions must contain three nonnegative decimal integers separated by periods,
183259with no leading zeroes, suffixes, or wildcards; each component must fit a Java
184260signed integer. Surrounding whitespace is allowed. Empty or malformed values
185- reject the extension, even if ` mirthVersion ` matches.
186-
187- Omitting the API requirement, or using XStream's explicit ` class="null" `
188- representation, retains legacy matching: ` mirthVersion ` lists exact releases
189- separated by commas, ignoring the engine's fourth build component. Bundled
190- extensions continue using that existing mechanism.
261+ reject the requirement, even if ` mirthVersion ` matches. A required provider's
262+ ` pluginVersion ` must use this format too; the engine does not infer compatibility
263+ from arbitrary release labels.
264+
265+ Only ` engine-api ` and ` plugin ` dependency types are supported, and both require
266+ ` minVersion ` . Plugin dependencies also require ` name ` ; engine dependencies do
267+ not use a name. Unknown types, malformed declarations, duplicate requirements,
268+ self-dependencies, cycles, and ambiguous duplicate provider names are rejected.
269+
270+ The engine check uses the ` engine-api ` dependency if present. Otherwise it uses
271+ a non-null ` minExtensionApiVersion ` , then legacy ` mirthVersion ` matching when
272+ the shorthand is absent or explicitly null. A list containing only plugin
273+ dependencies, or an empty list, never skips the engine check. Legacy matching
274+ accepts exact comma-separated engine releases, ignoring the engine's fourth
275+ build component. Existing descriptors without the new declarations keep this
276+ behavior.
191277
192278## Maintaining the API version
193279
0 commit comments