Search code examples
searchgroovyscriptingnexus3

Searching Assets/Components via Nexus 3 programmatically


Since the new version of Nexus has no more REST functionality to search the repositories for artifacts my idea is to use a Groovy script to build "my own REST" system. Currently I am trying to post a script that looks like this:

@Singleton
class NexusSearch extends Script {
    @Inject
    SearchService service;

    def run() {
        assert service != null;
        return args;
    }
}

My problem is that service stays null and I don't know if injection would ever work in scripts. Is this the right approach? If yes what am I doing wrong, if not what would be the right approach?


Solution

  • After checking internally, you can't do injection directly in scripts, but you can use container.lookup(className)