I’ll post my solution, just in case:
- There was a mistake in the title, it only failed in C8.9 but not C9.0,
- I was using
<rest-migration>
, which is not required. If not used, then Confluence 7.19-8.9 will use the old REST v1, and Confluence 9.0 will use the new one, and the createcontent plugin doesn’t fail,
Now, I have:
- A REST API which is only activated for Confluence 9.0, which contains the REST v2 imports,
- A REST API which is only activated for Confluence 7.19-to-8.9, which contains the REST v1 imports,
- A common REST API, which contains other resources which are not sensitive to package names,
- I’ve created a separate module for each, so that only the correct libraries are included by Maven, and it’s much easier to write code with autocompletion See this post about polyfills if necessary.
<rest key="rest" path="/my-rest-prefix/common" version="1" name="REST resources">
<description>REST API for Requirement Yogi</description>
<package>com.requirementyogi.datacenter.confluenceapp.rest</package>
</rest>
<!-- Remove when Confluence 9.0 is the new minimum -->
<rest key="rest-c719" path="/my-rest-prefix/compat" version="1" name="REST resources for C7 and C8">
<description>REST APIs for Confluence 7.19 and above</description>
<package>com.requirementyogi.datacenter.polyfills.confluence.c719.rest</package>
<restrict application="confluence" version="(,9)" />
</rest>
<rest key="rest-c900" path="/my-rest-prefix/compat" version="1" name="REST resources for C9.0+">
<description>REST APIs for Confluence 9.0 and above</description>
<package>com.requirementyogi.datacenter.polyfills.confluence.c900.rest</package>
<restrict application="confluence" version="(8.9999,)" />
</rest>
Note the use of <restrict>
which is incredibly useful for other situations too.