Is it possible to convert a Grab annotation to a Grapes.grab call?

Example:
Convert this…

@Grapes([
  @GrabConfig(systemClassLoader=true),
  @Grab('com.oracle:ojdbc6:11.2.0.1.0'),
])
import groovy.sql.Sql

to this…

groovy.grape.Grape.grab(group:'com.oracle', module:'ojdbc6', 
version:'11.2.0.1.0')


I’m assuming I’d need to add map entries for classLoader: and refObject: but 
I’m not sure how to assemble these if needed.

I’d like to put the Grapes.grab call in my compiled library.  Is this even 
possible?

My library connects to oracle like this…

Sql.withInstanceOracle(user:'tauser03',name:'ecprd4') { sql -> }

The static method withInstanceOracle is a metaClass method that under the hood 
calls this…



    static Sql newInstance (Map map) {

        // groovy.grape.Grape.grab(group:'com.oracle', module:'ojdbc6', 
version:'11.2.0.1.0')

        Map connectionMap = buildConnectionMap(map)

        log.info "connecting to [${connectionMap.url}] as 
[${connectionMap.user}]"

        Sql sql = Sql.newInstance(connectionMap)

        sql.connection.setAutoCommit(false)

        sql

    }

In my Oracle class.

Reply via email to