Japanese Creating Plugins

Last updated by admin 4 years ago

??????????????????{excerpt:hidden=true}Creating, Distributing & Installing{excerpt}

????????{excerpt:hidden=true}Creating a Plugin{excerpt}

???????????????Grails?????????????????:{excerpt:hidden=true} You can create a Grails plugin by running the command:{excerpt}

grails create-plugin [PLUGIN NAME]
???????????????????????????????????? {{grails create-plugin example}} ???? {{example}} ?????????????????????????Grails????????????????????????????????groovy????????????????Grails????????????????????????? {{example}} ??????????????????:{excerpt:hidden=true} This will create a plugin project for the name you specify. Say for example {{grails create-plugin example}} would create a new plugin project called {{example}}. The structure of a Grails plugin is exactly the same as a regular Grails project's directory structure, except that in the root of the plugin directory you will find a plugin Groovy file. Following our {{example}} plugin it will look something like:{excerpt}
code: null
class ExampleGrailsPlugin { def version = 0.1

… }

code: null
??????????????????????????????????????????????????????????????????????????????????(???????)?????????????????????????????{excerpt:hidden=true} All plugins must have this class in the root of their directory structure to be valid. The plugin class defines the version of the plugin and optionally various hooks into plugin extension points (covered shortly).{excerpt} ???????????????????????Grails????????????????????????Grails??????????????????????????? {{grails run-app}} ??????Grails??????????????????{excerpt:hidden=true} In fact, not only is the structure the same, but a plugin is a Grails application so you can just type {{grails run-app}} from the root of the plugin directory to execute a Grails plugin as a Grails app. {excerpt}

???????????????{excerpt:hidden=true}Installing & Distributing Plugins{excerpt}

{{example}} ????????????? {{cd example}} ??????????????????????????????????:{excerpt:hidden=true} To distribute the {{example}} plugin you need to navigate to its root directory using {{cd example}} and then type:{excerpt}

code: null
grails package-plugin
code: null
???????"grails"??????????????????????zip????????????????????? {{grails-example-0.1.zip}} ?????????????{excerpt:hidden=true} This will create a zip file of the plugin starting with "grails" then the plugin name and version. For example in the above case this would be {{grails-example-0.1.zip}}.{excerpt} ?????????????????????????Grails?????????????????:{excerpt:hidden=true} Once you have a plugin distribution file you can navigate to a Grails project and type:{excerpt}
grails install-plugin /path/to/plugin/grails-example-0.1.zip
????????????HTTP????????????????????????:{excerpt:hidden=true} If the plugin was hosted on a remote HTTP server you can also do:{excerpt}
grails install-plugin http://myserver.com/plugins/grails-example-0.1.zip
???Grails????????http://dist.codehaus.org/grails/plugins??????????????????????:{excerpt:hidden=true} Also for Grails plugins that are distributed at http://dist.codehaus.org/grails/plugins you can do:{excerpt}
grails install-plugin example 0.1