android grais app,Convert grails app to plugin

本文指导如何创建Grails插件,从生成插件描述符开始,涉及删除不必要的文件和配置,如应用.properties,调整BuildConfig.groovy的依赖,将初始化代码移至插件回调方法,删除无用视图和资源,以及编写测试和文档。这是一个优化和定制插件流程的详细指南。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Create the plugin descriptor, FooGrailsPlugin.groovy. The easiest way to do this is to rungrails create-plugin pluginname and copy the

generated file from there

delete everything from application.properties except the app.grails.version property

if you have jars in the lib directory that are available in a Maven repo, delete them and replace with BuildConfig.groovy dependencies

change any plugin and jar dependencies that are needed for development and testing but not when the plugin is installed to not be

exported, by adding export = false

If you need the _Install.groovy, _Uninstall.groovy, or _Upgrade.groovy scripts (you probably don’t) grab those from the dummy plugin from step 1 (but delete any you don’t need, they’re all

optional)

delete ApplicationResources.groovy if you aren’t using it and don’t depend on resources plugin

move code from BootStrap.groovy init() toFooGrailsPlugin.doWithApplicationContext

and/orFooGrailsPlugin.doWithDynamicMethods and destroy() to

FooGrailsPlugin.onShutdown, and delete BootStrap.groovy

add a dependency for the release plugin in BuildConfig.groovy

delete everything but the log4j configuration from Config.groovy

delete UrlMappings.groovy unless you have exported mappings; only keep the added ones

move bean definitions from resources.groovy to FooGrailsPlugin.doWithSpring and delete resources.groovy

delete grails-app/i18n message bundle files unless you added messages; only keep the added ones

delete everything from grails-app/views that you don’t use (in particular error.gsp,index.gsp, and layouts/main.gsp)

delete everything from web-app that you don’t use (including WEB-INF xml and tld files)

now would be a great time to write those tests you’ve been meaning to get to

create one or more test applications to install the plugin into to ensure that it works as a plugin; consider scripting this

write documentation for how to use the plugin; at a minimum a README file, but Grails gdoc files would be much better (run grails doc

--init to get started)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值