You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ta...@apache.org on 2017/06/27 15:39:34 UTC
svn commit: r1800073 - /ofbiz/ofbiz-framework/trunk/build.gradle
Author: taher
Date: Tue Jun 27 15:39:34 2017
New Revision: 1800073
URL: http://svn.apache.org/viewvc?rev=1800073&view=rev
Log:
Improved: refactored and improved the createPlugin task in gradle script
(OFBIZ-9436)
Applied the following changes:
- reduced the copy-paste pattern in creating the directory structure for a
new component by converting the mkdir logic into a loop over a list of the
directory names
- reduced the copy-paste pattern in creating the files from their templates
by converting the calls to the generator function to a loop over a list
of maps containing the arguments to the generator function
- added missing src/java/main and src/java/test
- removed duplicate / redundant directories as creating child directory
automatically creates the parent
Modified:
ofbiz/ofbiz-framework/trunk/build.gradle
Modified: ofbiz/ofbiz-framework/trunk/build.gradle
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/build.gradle?rev=1800073&r1=1800072&r2=1800073&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/build.gradle (original)
+++ ofbiz/ofbiz-framework/trunk/build.gradle Tue Jun 27 15:39:34 2017
@@ -577,69 +577,37 @@ task createPlugin(group: ofbizPlugin, de
def templateDir = "${rootDir}/framework/resources/templates"
def pluginDir = "${pluginsDir}/${pluginId}"
- mkdir pluginDir
- mkdir pluginDir+"/config"
- mkdir pluginDir+"/data"
- mkdir pluginDir+"/data/helpdata"
- mkdir pluginDir+"/dtd"
- mkdir pluginDir+"/documents"
- mkdir pluginDir+"/entitydef"
- mkdir pluginDir+"/lib"
- mkdir pluginDir+"/patches"
- mkdir pluginDir+"/patches/test"
- mkdir pluginDir+"/patches/qa"
- mkdir pluginDir+"/patches/production"
- mkdir pluginDir+"/script"
- mkdir pluginDir+"/servicedef"
- mkdir pluginDir+"/src"
- mkdir pluginDir+"/testdef"
- mkdir pluginDir+"/webapp"
- mkdir pluginDir+"/webapp/${webappName}"
- mkdir pluginDir+"/webapp/${webappName}/error"
- mkdir pluginDir+"/webapp/${webappName}/WEB-INF"
- mkdir pluginDir+"/webapp/${webappName}/WEB-INF/actions"
- mkdir pluginDir+"/widget/"
+ ['config', 'data/helpdata', 'dtd', 'documents', 'entitydef', 'lib', 'patches/test', 'patches/qa',
+ 'patches/production', 'script', 'servicedef', 'src/main/java', 'src/test/java', 'testdef',
+ 'widget', "webapp/${webappName}/error", "webapp/${webappName}/WEB-INF",
+ "webapp/${webappName}/WEB-INF/actions"].each {
+ mkdir pluginDir+'/'+it
+ }
- generateFileFromTemplate(templateDir+"/ofbiz-component.xml", pluginDir,
- filterTokens, "ofbiz-component.xml")
- generateFileFromTemplate(templateDir+"/TypeData.xml", pluginDir+"/data",
- filterTokens, "${pluginResourceName}TypeData.xml")
- generateFileFromTemplate(templateDir+"/SecurityPermissionSeedData.xml", pluginDir+"/data",
- filterTokens, "${pluginResourceName}SecurityPermissionSeedData.xml")
- generateFileFromTemplate(templateDir+"/SecurityGroupDemoData.xml", pluginDir+"/data",
- filterTokens, "${pluginResourceName}SecurityGroupDemoData.xml")
- generateFileFromTemplate(templateDir+"/DemoData.xml", pluginDir+"/data",
- filterTokens, "${pluginResourceName}DemoData.xml")
- generateFileFromTemplate(templateDir+"/HELP.xml", pluginDir+"/data/helpdata",
- filterTokens, "HELP_${pluginResourceName}.xml")
- generateFileFromTemplate(templateDir+"/document.xml", pluginDir+"/documents",
- filterTokens, "${pluginResourceName}.xml")
- generateFileFromTemplate(templateDir+"/entitymodel.xml", pluginDir+"/entitydef",
- filterTokens, "entitymodel.xml")
- generateFileFromTemplate(templateDir+"/services.xml", pluginDir+"/servicedef",
- filterTokens, "services.xml")
- generateFileFromTemplate(templateDir+"/Tests.xml", pluginDir+"/testdef",
- filterTokens, "${pluginResourceName}Tests.xml")
- generateFileFromTemplate(templateDir+"/UiLabels.xml", pluginDir+"/config",
- filterTokens, "${pluginResourceName}UiLabels.xml")
- generateFileFromTemplate(templateDir+"/index.jsp", pluginDir+"/webapp/${webappName}",
- filterTokens, "index.jsp")
- generateFileFromTemplate(templateDir+"/error.jsp", pluginDir+"/webapp/${webappName}/error",
- filterTokens, "error.jsp")
- generateFileFromTemplate(templateDir+"/controller.xml", pluginDir+"/webapp/${webappName}/WEB-INF",
- filterTokens, "controller.xml")
- generateFileFromTemplate(templateDir+"/web.xml", pluginDir+"/webapp/${webappName}/WEB-INF",
- filterTokens, "web.xml")
- generateFileFromTemplate(templateDir+"/CommonScreens.xml", pluginDir+"/widget",
- filterTokens, "CommonScreens.xml")
- generateFileFromTemplate(templateDir+"/Screens.xml", pluginDir+"/widget",
- filterTokens, "${pluginResourceName}Screens.xml")
- generateFileFromTemplate(templateDir+"/Menus.xml", pluginDir+"/widget",
- filterTokens, "${pluginResourceName}Menus.xml")
- generateFileFromTemplate(templateDir+"/Forms.xml", pluginDir+"/widget",
- filterTokens, "${pluginResourceName}Forms.xml")
- generateFileFromTemplate(templateDir+"/build.gradle", pluginDir,
- filterTokens, "build.gradle")
+ [ [tempName:'ofbiz-component.xml', newName:'ofbiz-component.xml', location:''],
+ [tempName:'build.gradle', newName:'build.gradle', location:''],
+ [tempName:'TypeData.xml', newName:"${pluginResourceName}TypeData.xml", location:'data'],
+ [tempName:'SecurityPermissionSeedData.xml', newName:"${pluginResourceName}SecurityPermissionSeedData.xml", location:'data'],
+ [tempName:'SecurityGroupDemoData.xml', newName:"${pluginResourceName}SecurityGroupDemoData.xml", location:'data'],
+ [tempName:'DemoData.xml', newName:"${pluginResourceName}DemoData.xml", location:'data'],
+ [tempName:'HELP.xml', newName:"HELP_${pluginResourceName}.xml", location:'data/helpdata'],
+ [tempName:'document.xml', newName:"${pluginResourceName}.xml", location:'documents'],
+ [tempName:'entitymodel.xml', newName:'entitymodel.xml', location:'entitydef'],
+ [tempName:'services.xml', newName:'services.xml', location:'servicedef'],
+ [tempName:'Tests.xml', newName:"${pluginResourceName}Tests.xml", location:'testdef'],
+ [tempName:'UiLabels.xml', newName:"${pluginResourceName}UiLabels.xml", location:'config'],
+ [tempName:'index.jsp', newName:'index.jsp', location:"webapp/${webappName}"],
+ [tempName:'error.jsp', newName:'error.jsp', location:"webapp/${webappName}/error"],
+ [tempName:'controller.xml', newName:'controller.xml', location:"webapp/${webappName}/WEB-INF"],
+ [tempName:'web.xml', newName:'web.xml', location:"webapp/${webappName}/WEB-INF"],
+ [tempName:'CommonScreens.xml', newName:'CommonScreens.xml', location:'widget'],
+ [tempName:'Screens.xml', newName:"${pluginResourceName}Screens.xml", location:'widget'],
+ [tempName:'Menus.xml', newName:"${pluginResourceName}Menus.xml", location:'widget'],
+ [tempName:'Forms.xml', newName:"${pluginResourceName}Forms.xml", location:'widget']
+ ].each { tmpl ->
+ generateFileFromTemplate(templateDir + '/' + tmpl.tempName,
+ pluginDir + '/' + tmpl.location, filterTokens, tmpl.newName)
+ }
println "plugin successfully created in directory ${pluginsDir}/${pluginId}."
}