svn commit: r1833951 - /ofbiz/ofbiz-framework/trunk/build.gradle

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1833951 - /ofbiz/ofbiz-framework/trunk/build.gradle

jleroux@apache.org
Author: jleroux
Date: Wed Jun 20 20:43:35 2018
New Revision: 1833951

URL: http://svn.apache.org/viewvc?rev=1833951&view=rev
Log:
Improved: Use functional programming in build script
(OFBIZ-10429)

No functional change, the idea is to have more declarative code.

Thanks: Mathieu Lirzin

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=1833951&r1=1833950&r2=1833951&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/build.gradle (original)
+++ ofbiz/ofbiz-framework/trunk/build.gradle Wed Jun 20 20:43:35 2018
@@ -907,7 +907,7 @@ task cleanFooterFiles(group: cleanupGrou
  * declaration is important because it means that it will automatically
  * run whenever the task cleanAll executes (dependency matched by regex)
  */
-def cleanTasks = getTasksMatchingRegex(/^clean.+/)
+def cleanTasks = tasks.findAll { it.name ==~ /^clean.+/ }
 task cleanAll(group: cleanupGroup, dependsOn: [cleanTasks, clean]) {
     description 'Execute all cleaning tasks.'
 }
@@ -1004,16 +1004,6 @@ def deleteAllInDirWithExclusions(dirName
     }
 }
 
-def getTasksMatchingRegex(theRegex) {
-    def filteredTasks = []
-    tasks.each { task ->
-        if (task.name ==~ theRegex) {
-            filteredTasks.add(task)
-        }
-    }
-    return filteredTasks
-}
-
 def generateFileFromTemplate(templateFileInFullPath, targetDirectory, filterTokens, newFileName) {
     copy {
         from (templateFileInFullPath) {
@@ -1037,27 +1027,17 @@ def getJarManifestClasspathForCurrentOs(
 }
 
 def subprojectExists(fullyQualifiedProject) {
-    def projectFound = false
-    subprojects.each { subproject ->
-        if (subproject.getPath().equals(fullyQualifiedProject.toString())) {
-            projectFound = true
-        }
-    }
-    return projectFound
+    subprojects.stream()
+        .filter { it.path == fullyQualifiedProject.toString() }
+        .findAny()
+        .isPresent()
 }
 
 def taskExistsInproject(fullyQualifiedProject, taskName) {
-    def taskExists = false
-    subprojects.each { subProject ->
-        if (subProject.getPath().equals(fullyQualifiedProject.toString())) {
-            subProject.tasks.each { projTask ->
-                if (taskName.equals(projTask.name)) {
-                    taskExists = true
-                }
-            }
-        }
-    }
-    return taskExists
+    subprojects.stream()
+        .filter { it.path == fullyQualifiedProject.toString() }
+        .flatMap { it.tasks.stream() }
+        .anyMatch taskName.&equals
 }
 
 def gradlewSubprocess(commandList) {