I'm writing a plugin and I'm trying to write a file inside of the Plugin's root or installed directory (not sure what to refer to this to). I can't seem to figure out how to get a hold of this value. Doing System.properties['base.dir']
will result in the implementing Grails project's root directory. So right now I have two directories:
C:/PluginProject/
C:/GrailsAppThatUsesPlugin/
It's my understanding that when this becomes a distributed plugin a user will similarly have two directories:
GRAILS_HOME/grails-version/projects/projectName/plugins/myPlugin/
C:/GrailsAppThatUsesPlugin/
Inside of my plugin project I need to create a file. It needs to be inside of my plugin because the file I'm writing needs to reference other files that my plugin provides. The few things that I've tried that haven't worked are:
System.properties['base.dir']
new File("")
pluginNamePluginDir
but I'm trying to access this from a POGO. System.properties
none of them have the plugin directoryAny help is greatly appreciated.
By default the plugins are in . grails/<version>/<project>/plugins . You can change it by setting grails. project.
A Grails plugin project is just like an application project except it contains a plugin descriptor and can be packaged as a plugin and installed into other applications. Plugins are not just useful for plugin developers, but also as a way to modularize large Grails applications.
This worked for me (both in-place and regular plug-ins):
import org.codehaus.groovy.grails.plugins.GrailsPluginUtils
GrailsPluginUtils.pluginInfos.find { it.name == pluginName }.pluginDir
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With