Author: taher
Date: Sun Jan 29 13:07:32 2017
New Revision: 1780790
URL: http://svn.apache.org/viewvc?rev=1780790&view=rev
Log:
Improved: fully refactored the component loading logic in Gradle
(OFBIZ-9182)
This commit provides the following:
- Fully refactor common.gradle so that it mirrors the component loading
logic found in ComponentContainer. This makes the loading very flexible
and changing the directory structure should have no impact on the build
scripts.
- Gradle will now ignore a component if it exists but disabled in
ofbiz-component.xml (i.e. enabled="false")
- Removes /plugins/component-load.xml
- Disables the ebaystore component in ofbiz-component.xml
The above is needed as a first step toward preparing the project for svn
restructure
Removed:
ofbiz/trunk/plugins/component-load.xml
Modified:
ofbiz/trunk/common.gradle
ofbiz/trunk/plugins/ebaystore/ofbiz-component.xml
Modified: ofbiz/trunk/common.gradle
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/common.gradle?rev=1780790&r1=1780789&r2=1780790&view=diff
==============================================================================
--- ofbiz/trunk/common.gradle (original)
+++ ofbiz/trunk/common.gradle Sun Jan 29 13:07:32 2017
@@ -17,27 +17,37 @@
* under the License.
*/
def iterateOverActiveComponents(applyFunction) {
- def frameworkComponents = new
XmlParser().parse("${rootDir}/framework/component-load.xml")
- def applicationsComponents = new
XmlParser().parse("${rootDir}/applications/component-load.xml")
- def pluginsComponents = new
XmlParser().parse("${rootDir}/plugins/component-load.xml")
+ // Start is not a real component, therefore loading it manually
applyFunction file("${rootDir}/framework/start")
- frameworkComponents.children().each { component ->
- applyFunction
file("${rootDir}/framework/"+component.@"component-location")
- }
- applicationsComponents.children().each { component ->
- applyFunction
file("${rootDir}/applications/"+component.@"component-location")
- }
- pluginsComponents.children().each { component ->
- applyFunction
file("${rootDir}/plugins/"+component.@"component-location")
- }
+ def rootComponents = new
XmlParser().parse("${rootDir}/framework/base/config/component-load.xml")
+ rootComponents.children().each { rootComponent ->
+ File componentLoadFile = file "${rootDir}/"+
rootComponent.@"parent-directory" + "/component-load.xml"
- file("${rootDir}/themes").eachDir { component ->
- applyFunction(component)
+ if(componentLoadFile.exists()) {
+ // iterate through the components defined in component-load.xml
+ def parsedComponents = new
XmlParser().parse(componentLoadFile.toString())
+ parsedComponents.children().each { component ->
+ def componentLocation = file "${rootDir}/"+
rootComponent.@"parent-directory" + '/' + component.@"component-location"
+ applyIfEnabled(componentLocation, applyFunction)
+ }
+ } else {
+ // iterate through all components (subdirectories of the root
component)
+ file(rootComponent.@"parent-directory").eachDir {
componentLocation ->
+ applyIfEnabled(componentLocation, applyFunction)
+ }
+ }
}
- file("${rootDir}/hot-deploy").eachDir { component ->
- applyFunction(component)
+}
+
+def applyIfEnabled(componentDir, applyFunction) {
+ File componentFile = file componentDir.toString() + '/ofbiz-component.xml'
+ if(componentFile.exists()) {
+ def parsedComponent = new XmlParser().parse(componentFile.toString())
+ if(parsedComponent.@enabled == null || parsedComponent.@enabled ==
"true") {
+ applyFunction componentDir
+ }
}
}
Modified: ofbiz/trunk/plugins/ebaystore/ofbiz-component.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/plugins/ebaystore/ofbiz-component.xml?rev=1780790&r1=1780789&r2=1780790&view=diff
==============================================================================
--- ofbiz/trunk/plugins/ebaystore/ofbiz-component.xml (original)
+++ ofbiz/trunk/plugins/ebaystore/ofbiz-component.xml Sun Jan 29 13:07:32 2017
@@ -1,48 +1,48 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<ofbiz-component name="ebaystore" enabled="true"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/ofbiz-component.xsd">
- <resource-loader name="main" type="component"/>
- <classpath type="dir" location="config"/>
-
- <entity-resource type="model" reader-name="main" loader="main"
location="entitydef/entitymodel.xml"/>
-
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/EbayStoreSecurityPermissionSeedData.xml"/>
- <entity-resource type="data" reader-name="demo" loader="main"
location="data/EbayStoreSecurityGroupDemoData.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/EbayStoreTypeData.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/EbayStoreHelpData.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main"
location="data/EbayStorePortletData.xml"/>
- <entity-resource type="data" reader-name="demo" loader="main"
location="data/DemoEbayStoreData.xml"/>
-
- <service-resource type="eca" loader="main"
location="servicedef/secas.xml"/>
- <service-resource type="model" loader="main"
location="servicedef/services.xml"/>
- <service-resource type="model" loader="main"
location="servicedef/services_store.xml"/>
-
- <webapp name="ebaystore"
- title="eBay Store"
- menu-name="secondary"
- server="default-server"
- location="webapp/ebaystore"
- base-permission="EBAYSTORE"
- mount-point="/ebaystore"
- app-bar-display="true"/>
-</ofbiz-component>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<ofbiz-component name="ebaystore" enabled="false"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/ofbiz-component.xsd">
+ <resource-loader name="main" type="component"/>
+ <classpath type="dir" location="config"/>
+
+ <entity-resource type="model" reader-name="main" loader="main"
location="entitydef/entitymodel.xml"/>
+
+ <entity-resource type="data" reader-name="seed" loader="main"
location="data/EbayStoreSecurityPermissionSeedData.xml"/>
+ <entity-resource type="data" reader-name="demo" loader="main"
location="data/EbayStoreSecurityGroupDemoData.xml"/>
+ <entity-resource type="data" reader-name="seed" loader="main"
location="data/EbayStoreTypeData.xml"/>
+ <entity-resource type="data" reader-name="seed" loader="main"
location="data/EbayStoreHelpData.xml"/>
+ <entity-resource type="data" reader-name="seed" loader="main"
location="data/EbayStorePortletData.xml"/>
+ <entity-resource type="data" reader-name="demo" loader="main"
location="data/DemoEbayStoreData.xml"/>
+
+ <service-resource type="eca" loader="main"
location="servicedef/secas.xml"/>
+ <service-resource type="model" loader="main"
location="servicedef/services.xml"/>
+ <service-resource type="model" loader="main"
location="servicedef/services_store.xml"/>
+
+ <webapp name="ebaystore"
+ title="eBay Store"
+ menu-name="secondary"
+ server="default-server"
+ location="webapp/ebaystore"
+ base-permission="EBAYSTORE"
+ mount-point="/ebaystore"
+ app-bar-display="true"/>
+</ofbiz-component>