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

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

问题描述

我们在我们的grails应用程序中使用了各种插件(如日志记录,弹簧安全核心,ui,acl和其他许多插件)。现在这些插件带有默认的gsps(在每个插件的视图文件夹中)。



我想在不包含任何插件视图的情况下构建WAR。因此,当战争现在建立时,它会创建包含views文件夹的插件文件夹,这些文件夹默认会与插件一起提供,这些视图引入了很多漏洞,所以我想排除插件视图。



我现在在BuildConfig.groovy中试试这个,就像下面这样:

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

但是问题是代码在战争构建过程尚未创建时尝试删除视图。因此,我为这些插件视图得到了文件未找到的错误。



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



在此先感谢..
Priyank

解决方案

我在Grails邮件列表上回答了这个问题。
http ://grails.1312388.n4.nabble.com/deleting-plugins-views-gsp-when-building-the-war-td4560517.html
(答案还没有出现在可以在脚本/ _Events.groovy文件中指定的eventCreateWarStart
事件中将文件从/中移除/添加到war文件中。



这可能有效:

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,包括: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,包括:gsp_springSecurityUi *。*)
}

我不确定您是否也可以毫无问题地移除插件控制器类。我们使用Filter类来禁用由插件提供的控制器。



作为旁注,您可以禁用生产环境中的仅限开发插件尚未记录的grails.plugins.excludes功能:

示例:Config.groovy中的


  import grails.util.Environment 

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


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).

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.

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.

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?

Thanks in advance.. Priyank

解决方案

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)

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

This might work:

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.

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

Example: in Config.groovy:

import grails.util.Environment

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

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

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