构建战争时删除插件视图(gsp) [英] deleting plugins views (gsp) when building the war

查看:10
本文介绍了构建战争时删除插件视图(gsp)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在 grails 应用程序中使用了各种插件(如日志记录、spring 安全核心、ui、acl 等).现在这些插件带有默认的 gsps(在每个插件的视图文件夹中).

We are using various plugins in our grails application (like logging, spring security core, ui, acl and many others). Now these plugins come with default gsps (in the views folder of each plugin).

我想构建一个不包含任何插件视图的 WAR.因此,当现在构建战争时,它会创建插件文件夹,其中包含插件默认附带的视图文件夹,这些视图引入了很多漏洞,因此我想排除插件视图.

I want to build a WAR without including the views of any plugin. So when the war is built right now it creates the plugins folder which contains views folder which come by default with the plugin, these views are introducing a lot of vulnerabilities and so I want to exclude the plugins views.

我现在正在 BuildConfig.groovy 中尝试这个,如下所示:

I am trying this right now in BuildConfig.groovy like below:

grails.project.dependency.resolution = {
grails.war.resources = { stagingDir ->
   println "Customized delete started..."
   delete{fileset dir: "${stagingDir}/WEB-INF/plugins/logging-0.1/grails-app/views/"}
   delete{fileset dir: "${stagingDir}/WEB-INF/plugins/spring-security-ui-0.1.2/grails-app/views/"}
    }
   }

但问题是代码试图删除尚未由战争构建过程创建的视图.因此,我收到了这些插件视图的文件未找到错误.

But the problem is the code tries to delete the views when they are not yet created by the war building process. Hence I get a file not found error for those plugins views.

我应该在哪里编写代码来删除插件视图,以便在构建 WAR 时它们已经创建并可以删除,或者我如何不将插件视图包含在 WAR 中?

Where should I write the code to delete the plugins views so that they are already created and available to delete when building the WAR, or how do I not include the plugins views in the WAR?

提前致谢..普里扬克

推荐答案

我在 Grails 邮件列表上回答了这个问题.http://grails.1312388.n4.nabble.com/deleting-plugins-views-gsp-when-building-the-war-td4560517.html(答案还没有出现在 nabble 中)

I answered this question on the Grails mailing list. http://grails.1312388.n4.nabble.com/deleting-plugins-views-gsp-when-building-the-war-td4560517.html (The answer hasn't yet shown up in nabble)

您可以在事件CreateWarStart 中从/向war 文件中删除/添加文件脚本/_Events.groovy 文件中指定的事件.

You can remove/add files from/to a war file in the eventCreateWarStart event specified in scripts/_Events.groovy file.

这可能有效:

文件名:scripts/_Events.groovy

filename: scripts/_Events.groovy

eventCreateWarStart = { warName, stagingDir ->
   Ant.delete(dir: "${stagingDir}/WEB-INF/plugins/logging-0.1/grails-app/views")
   Ant.delete(dir: "${stagingDir}/WEB-INF/classes", includes:"gsp_logging*.*")
   Ant.delete(dir: "${stagingDir}/WEB-INF/plugins/spring-security-ui-0.1.2/grails-app/views")
   Ant.delete(dir: "${stagingDir}/WEB-INF/classes", includes:"gsp_springSecurityUi*.*")
}

我不确定您是否也可以毫无问题地删除插件控制器类.我们已经使用过滤器类来禁用"插件提供的控制器.

I'm not sure if you could also remove plugin Controller classes without problems. We've used Filter classes to "disable" controllers provided by plugins.

附带说明,您可以使用尚未记录的grails.plugins.excludes"功能在生产环境中禁用仅开发"插件:

As a side-note you can disable "development-only" plugins in the production environment by using the yet undocumented "grails.plugins.excludes" feature:

示例:在 Config.groovy 中:

Example: in Config.groovy:

import grails.util.Environment

if(Environment.current == Environment.PRODUCTION) {
    grails.plugin.excludes = ['somePluginName']
}

这篇关于构建战争时删除插件视图(gsp)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆