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/03/12 08:03:43 UTC

svn commit: r1786562 - in /ofbiz/ofbiz-framework/trunk: README.md build.gradle

Author: taher
Date: Sun Mar 12 08:03:43 2017
New Revision: 1786562

URL: http://svn.apache.org/viewvc?rev=1786562&view=rev
Log:
Implemented: New task pullAllPluginsSource and improvements to plugins API
(OFBIZ-9182)

Implemented a new gradle task called pullAllPluginsSource which downloads
all the official apache OFBiz plugins from source control and places them
in the /plugins directory inclusive of their .svn directory. This task makes
it possible to automate buildbot for OFBiz with the need to use something like
svn:externals and to have two separate build scripts for framework-alone and
framework+plugins. The task delete all pre-existing plugins as it needs to
download the plugins as a full sub-repository

In addition to above mentioned new task, this commit also applies:
- Update README.md with new task definition and cleanup
- Improve the plugins API in gradle to make use of shared code for calling
  gradle as a sub-process from multiple locations
- minor formatting issues in build.gradle

Modified:
    ofbiz/ofbiz-framework/trunk/README.md
    ofbiz/ofbiz-framework/trunk/build.gradle

Modified: ofbiz/ofbiz-framework/trunk/README.md
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/README.md?rev=1786562&r1=1786561&r2=1786562&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/README.md (original)
+++ ofbiz/ofbiz-framework/trunk/README.md Sun Mar 12 08:03:43 2017
@@ -515,14 +515,30 @@ If you need username and password to acc
 
 `gradlew pullPlugin -PrepoUrl="http://www.example.com/custom-maven" -PrepoUser=myuser -PrepoPassword=mypassword -PdependencyId="org.apache.ofbiz.plugin:myplugin:0.1.0"`
 
-### Pull a source plugin
+### Pull an official plugin from source control
 
-Download a plugin from source control (currently subversion) and place it in
-the plugins directory. This is mostly useful when working on the trunk branch
-as it requires the latest version of a plugin
+Download an official plugin from source control (currently subversion) and place
+it in the plugins directory. In addition, this task also executes the "install"
+task if it is defined for the plugin being downloaded.
+
+This task is mostly useful when working on the trunk branch
+as it pulls in the latest version of a plugin
 
 `gradlew pullPluginSource -PpluginId=ecommerce`
 
+### Pull all official plugins from source control
+
+Download all officially supported plugins from source control (currently subversion)
+and place them inclusive of their ".svn" directory in /plugins. WARNING! This task
+deletes the /plugins directory and replaces it with the official plugins.
+
+`gradlew pullAllPluginsSource`
+
+This task makes it easy to download and develop officially supported plugins. It is
+mostly used by developers or individuals working on the trunk branch. We do not
+recommend using this task on releases of OFBiz, instead consider using the "pullPlugin"
+task to get the correct version of a plugin compatible with your release.
+
 ### Install a plugin
 
 If you have a plugin called mycustomplugin and want to install it in OFBiz follow the

Modified: ofbiz/ofbiz-framework/trunk/build.gradle
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/build.gradle?rev=1786562&r1=1786561&r2=1786562&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/build.gradle (original)
+++ ofbiz/ofbiz-framework/trunk/build.gradle Sun Mar 12 08:03:43 2017
@@ -513,14 +513,14 @@ task createPlugin(group: ofbizPlugin, de
         if (!project.hasProperty('basePermission')) {
             ext.basePermission = pluginId.toUpperCase()
         }
-    
+
         def filterTokens = ['component-name': pluginId,
             'component-resource-name': pluginResourceName,
             'webapp-name': webappName,
             'base-permission': basePermission]
         def templateDir = "${rootDir}/framework/resources/templates"
         def pluginDir = "${pluginsDir}/${pluginId}"
-    
+
         mkdir pluginDir
         mkdir pluginDir+"/config"
         mkdir pluginDir+"/data"
@@ -543,7 +543,7 @@ task createPlugin(group: ofbizPlugin, de
         mkdir pluginDir+"/webapp/${webappName}/WEB-INF"
         mkdir pluginDir+"/webapp/${webappName}/WEB-INF/actions"
         mkdir pluginDir+"/widget/"
-    
+
         generateFileFromTemplate(templateDir+"/ofbiz-component.xml", pluginDir,
             filterTokens, "ofbiz-component.xml")
         generateFileFromTemplate(templateDir+"/TypeData.xml", pluginDir+"/data",
@@ -584,12 +584,12 @@ task createPlugin(group: ofbizPlugin, de
             filterTokens, "${pluginResourceName}Forms.xml")
         generateFileFromTemplate(templateDir+"/build.gradle", pluginDir,
             filterTokens, "build.gradle")
-    
+
         println "plugin successfully created in directory ${pluginsDir}/${pluginId}."
     }
 }
 
-task installPlugin(group: ofbizPlugin, description: 'activate a plugin and run its install task if it exists') {
+task installPlugin(group: ofbizPlugin, description: 'executes plugin install task if it exists') {
 
     doFirst {
         if (!project.hasProperty('pluginId')) {
@@ -598,22 +598,22 @@ task installPlugin(group: ofbizPlugin, d
     }
 
     if (project.hasProperty('pluginId')) {
-        if (subprojectExists(":plugins:${pluginId}")) {
-            if (taskExistsInproject(":plugins:${pluginId}", 'install')) {
-                dependsOn ":plugins:${pluginId}:install"
-                doLast { println "installed plugin ${pluginId}" }
-            } else {
-                doLast { println "No install task defined for plugin ${pluginId}" }
-            }
-        } else {
-            doLast {
-                installPlugin pluginId
+        iterateOverActiveComponents { component ->
+            if (component.name == pluginId) {
+                if (subprojectExists(":plugins:${pluginId}")) {
+                    if (taskExistsInproject(":plugins:${pluginId}", 'install')) {
+                        dependsOn ":plugins:${pluginId}:install"
+                        doLast { println "installed plugin ${pluginId}" }
+                    } else {
+                        doLast { println "No install task defined for plugin ${pluginId}" }
+                    }
+                }
             }
         }
     }
 }
 
-task uninstallPlugin(group: ofbizPlugin, description: 'run the uninstall task if exists for a plugin and deactivate it') {
+task uninstallPlugin(group: ofbizPlugin, description: 'executes plugin uninstall task if it exists') {
 
     doFirst {
         if (!project.hasProperty('pluginId')) {
@@ -626,6 +626,9 @@ task uninstallPlugin(group: ofbizPlugin,
 
     if (project.hasProperty('pluginId') && taskExistsInproject(":plugins:${pluginId}", 'uninstall')) {
         dependsOn ":plugins:${pluginId}:uninstall"
+        doLast { println "uninstalled plugin ${pluginId}" }
+    } else {
+        doLast { println "No uninstall task defined for plugin ${pluginId}" }
     }
 }
 
@@ -689,7 +692,7 @@ task pullPlugin(group: ofbizPlugin, desc
         if (!project.hasProperty('dependencyId')) {
             throw new GradleException('You must pass the dependencyId of the plugin')
         }
-    
+
         // Connect to a remote maven repository if defined
         if (project.hasProperty('repoUrl')) {
             repositories {
@@ -704,12 +707,12 @@ task pullPlugin(group: ofbizPlugin, desc
                 }
             }
         }
-    
+
         // download plugin and dependencies
         dependencies {
             ofbizPlugins dependencyId
         }
-    
+
         // reverse the order of dependencies to install them before the plugin
         def ofbizPluginArchives = new ArrayList(configurations.ofbizPlugins.files)
         Collections.reverse(ofbizPluginArchives)
@@ -722,7 +725,7 @@ task pullPlugin(group: ofbizPlugin, desc
                 from zipTree(pluginArchive)
                 into "${pluginsDir}/${pluginId}"
             }
-            installPlugin pluginId
+            gradlewSubprocess(['installPlugin', "-PpluginId=${pluginId}"])
         }
     }
 }
@@ -737,7 +740,41 @@ task pullPluginSource(group: ofbizPlugin
         dependsOn pullPluginFromSvn
     }
     doLast {
-        installPlugin pluginId
+        gradlewSubprocess(['installPlugin', "-PpluginId=${pluginId}"])
+    }
+}
+
+task pullAllPluginsSource(group: ofbizPlugin, 
+        description: 'Download and install all plugins from source control. Warning! deletes existing plugins') {
+
+    task pullPluginsFromSvn(type: SvnCheckout) {
+        svnUrl = "https://svn.apache.org/repos/asf/ofbiz/ofbiz-plugins/trunk"
+        workspaceDir = "${rootDir}/temp"
+        doLast{
+            delete "${rootDir}/plugins"
+            ant.move(file: "${rootDir}/temp", toFile: "${rootDir}/plugins")
+        }
+    }
+    dependsOn pullPluginsFromSvn
+
+    task installAllPlugins {
+        file("${rootDir}/plugins").eachDir { plugin ->
+            iterateOverActiveComponents { component ->
+                if (component.name == plugin.name) {
+                    if (subprojectExists(":plugins:${plugin.name}")) {
+                        if (taskExistsInproject(":plugins:${plugin.name}", 'install')) {
+                            dependsOn ":plugins:${pluginId}:install"
+                            doLast { println "installed plugin ${plugin.name}" }
+                        } else {
+                            doLast { println "No install task defined for plugin ${plugin.name}" }
+                        }
+                    }
+                }
+            }
+        }
+    }
+    doLast {
+        gradlewSubprocess(['installAllPlugins'])
     }
 }
 
@@ -1016,7 +1053,9 @@ def taskExistsInproject(fullyQualifiedPr
     return taskExists
 }
 
-def installPlugin(pluginId) {
+def gradlewSubprocess(commandList) {
     def gradleRunner = os.contains('windows') ? 'gradlew.bat' : './gradlew'
-    exec { commandLine gradleRunner, '--no-daemon', 'installPlugin', "-PpluginId=${pluginId}" }
+    def fullCommand = [gradleRunner, "--no-daemon"]
+    fullCommand.addAll(commandList)
+    exec { commandLine fullCommand }
 }