Component file missing in jar when using confluence-compat-lib

We’ve added the confluence-compat-lib maven dependency to support readonly mode in our Confluence app like described here: https://developer.atlassian.com/server/confluence/how-to-make-your-add-on-compatible-with-read-only-mode/

We encountered an issue that the app would work fine if built locally, but did not activate when built on our build server. Upon comparing both jars we noticed that the file META-INF/plugin-components/component was missing when using the build server.
After trying out different maven configuration things we found out that the file is missing when running a clean build (after atlas-clean). On the second build, the file is present in the jar and everything works fine. That’s why it worked locally, but not with the build server that uses a clean docker image. My suspicion is that some resource is loaded too late if not already present on the disk.

Our current workaround is to let the buildserver run atlas-packe two times in a row. The second run produces the good jar. While this works, we still wonder if there’s a better option.

We use the atlassian-sdk 8.0.16 for the build. The depency is included like this in the pom.xml:

<dependency>
    <groupId>com.atlassian.confluence.compat</groupId>
    <artifactId>confluence-compat-lib</artifactId>
    <version>1.2.1</version>
</dependency>
<Import-Package>
   ...
   com.atlassian.confluence.api.service.accessmode;resolution:="optional",
   ...
   *;resolution:=optional
</Import-Package>

Has anyone else encountered a similar issue or does anyone know a solution to this? It seems to me as if this is a maven issue that’s not specific to our app.