Error on import org.sonatype.nexus.repository.storage.StorageFacet in Groovy script / Admin task

I’m trying to import org.sonatype.nexus.repository.storage.StorageFacet in my test Groovy script. However, for some reason I’m geting “Script4.groovy: 3: unable to resolve class org.sonatype.nexus.repository.storage.StorageFacet”. Same for other classes from the storage package. “import org.sonatype.nexus.repository.Repository” is fine.

Is that expected? Are classes from the storage package expected to be available by default in Groovy scripts, once scripting got enabled? Should I add some jar in some path somewhere?
I understand that scripting is being actively deprecated, but still…

Thanks

If you’ve migrated to an SQL database the internal classes around components, assets, etc. are completely different from what was used for Orient.

Hello,

I’m looking for a groovy script to count the number of components per repository in Nexus OSS 3.71 (H2 database).
The script provided via this link works well with an OrientDB database.
Do you know if there is an equivalent script that would be compatible with an H2 database, please?

I’m using H2. Does it mean "org.sonatype.nexus.repository.storage.StorageFacet” is expected to be missing and import expected to fail?

Its not compatible.

Correct, that class does not exist in the code for SQL.

Where is the H2 repository scripting API documented? If not in the docs, where in the nexus-public source code should I look?

I strongly urge Sonatype to conspicuously call out this breaking change in the Script API.

This is called out in the help documentation: Feature Differences Between Legacy OrientDB and H2/PostgreSQL

The public APIs extend ScriptApi, otherwise these are internal APIs and may change in releases. You may wish to look at ContentFacet which is attached to repositories while using an SQL database.