Saba Ahang
Saba Ahang

Reputation: 598

What's the correct way of importing a Grails plugin if not mentioned in instructions

I'm trying to use the methods defined in this Grails plugin after confirming that the plugin is installed correctly:

https://github.com/agorapulse/grails-open-exchange-rates/blob/master/grails-app/services/grails/plugin/openexchangerates/OpenExchangeRatesService.groovy

For all I can speculate, I add the following import line in my Controller:

import grails.plugin.openexchangerates

but the the compiler keeps nagging that it's unable to resolve the class. I have tried all the following combinations with no avail:

grails.plugin.openexchangerates.*
services.grails.plugin.openexchangerates
services.grails.plugin.openexchangerates.*

etc.

What obvious thing am I missing here?

Upvotes: 1

Views: 113

Answers (1)

Igor Artamonov
Igor Artamonov

Reputation: 35961

It's not importing Grails plugins, btw. Just standard (groovy/java/jvm) import, but for a class that coming from a grails plugin, it's a pretty common situation.

This class have package grails.plugin.openexchangerates, so you can do:

import grails.plugin.openexchangerates.*

or

import grails.plugin.openexchangerates.OpenExchangeRatesService

But make sure that plugin is added to dependencies, into BuildConfig, as

compile ':open-exchange-rates:0.1'

Plugin readme suggests to use runtime ':open-exchange-rates:0.1', but at this case compiler don't have plugin classes in classpath. You need to use compile scope. See more about dependency scopes: http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope

Upvotes: 1

Related Questions