svn commit: r1751785 - /ofbiz/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: r1751785 - /ofbiz/trunk/build.gradle

Taher Alkhateeb
Author: taher
Date: Thu Jul  7 12:19:43 2016
New Revision: 1751785

URL: http://svn.apache.org/viewvc?rev=1751785&view=rev
Log:
introduce gradle task "terminateOfbiz" - OFBIZ-7534

This commit introduces a gradle task which kills all running
OFBiz server instances both on Windows and Unix-like systems.
The task has a few workarounds that might change in the future
as the executable name for OFBiz changes. More specifically
right now because the executable is huge in Linux (greater
than 4K of text), we cannot grep org.ofbiz.base.start.Start.
This might change in the future

Also removing unnecessary lib dependency (extra line unused)

Modified:
    ofbiz/trunk/build.gradle

Modified: ofbiz/trunk/build.gradle
URL: http://svn.apache.org/viewvc/ofbiz/trunk/build.gradle?rev=1751785&r1=1751784&r2=1751785&view=diff
==============================================================================
--- ofbiz/trunk/build.gradle (original)
+++ ofbiz/trunk/build.gradle Thu Jul  7 12:19:43 2016
@@ -65,7 +65,6 @@ dependencies {
     getDirectoryInActiveComponentsIfExists('lib').each { libDir ->
         compile fileTree(dir: libDir, include: '**/*.jar')
     }
-    compile fileTree(dir: 'lib', include: '**/*.jar')
     runtime files("${projectDir}/build/libs/ofbiz-base-test.jar")
 }
 
@@ -133,6 +132,25 @@ task testIntegration(group: ofbizServer)
     description 'Run OFBiz integration tests; You must run loadDefault before running this task'
 }
 
+task terminateOfbiz(group: ofbizServer,
+    description: 'Force termination of any running OFBiz servers, only use if \"--shutdown\" command fails') << {
+    def os = System.getProperty("os.name").toLowerCase()
+    if (os.contains("windows")) {
+        Runtime.getRuntime().exec("wmic process where \"CommandLine Like \'%org.ofbiz.base.start%\'\" Call Terminate")
+    } else {
+        def processOutput = new ByteArrayOutputStream()
+        exec {
+            commandLine 'ps', 'ax'
+            standardOutput = processOutput
+        }
+        processOutput.toString().split(System.lineSeparator()).each { line ->
+            if(line ==~ /.*java.*/ && line ==~ /.*framework.*/) {
+                exec { commandLine 'kill', '-9', line.tokenize().first() }
+            }
+        }
+    }
+}
+
 task loadAdminUserLogin(group: ofbizServer) {
     description 'Create admin user with temporary password equal to ofbiz. You must provide userLoginId'
     createOfbizCommandTask('executeLoadAdminUser',