TOMEE-1638 fixing ExecRunner for script/java usages

Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/009b7f83
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/009b7f83
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/009b7f83

Branch: refs/heads/tomee-7.0.0-M1
Commit: 009b7f83052b0e43c56c0d249e8b169c1636ebd3
Parents: d68c149
Author: Romain Manni-Bucau <rmann...@gmail.com>
Authored: Tue Oct 20 08:48:07 2015 +0200
Committer: Romain Manni-Bucau <rmann...@gmail.com>
Committed: Tue Oct 20 08:48:07 2015 +0200

----------------------------------------------------------------------
 .../openejb/maven/plugin/runner/ExecRunner.java | 39 ++++++++++----------
 1 file changed, 20 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/009b7f83/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/runner/ExecRunner.java
----------------------------------------------------------------------
diff --git 
a/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/runner/ExecRunner.java
 
b/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/runner/ExecRunner.java
index 44daac3..e858da3 100644
--- 
a/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/runner/ExecRunner.java
+++ 
b/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/runner/ExecRunner.java
@@ -76,23 +76,6 @@ public class ExecRunner {
             IO.writeString(timestampFile, config.getProperty("timestamp", 
Long.toString(System.currentTimeMillis())));
         }
 
-        final File[] extracted = distribOutput.listFiles();
-        if (extracted != null) {
-            File newRoot = null;
-            for (final File e : extracted) {
-                if (e.isDirectory()) {
-                    if (newRoot == null) {
-                        newRoot = e;
-                    } else {
-                        newRoot = null;
-                        break;
-                    }
-                }
-            }
-            if (newRoot != null) {
-                distribOutput = newRoot;
-            }
-        }
         final File[] scripts = new File(distribOutput, "bin").listFiles();
         if (scripts != null) { // dont use filefilter to avoid dependency issue
             for (final File f : scripts) {
@@ -112,11 +95,11 @@ public class ExecRunner {
                 final boolean isWin = 
System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("win");
                 final String script = cmd.substring(lastSlash + 1, 
cmd.length() - SH_BAT_AUTO.length()).replace('/', isWin ? '\\' : '/')
                         + (isWin ? ".bat" : ".sh");
-                cmd = dir + File.separator + script;
-                final File scriptFile = new File(distribOutput, cmd);
+                final File scriptFile = new File(distribOutput, dir + 
File.separator + script);
                 if (!scriptFile.exists()) {
                     throw new IllegalArgumentException("Can't find  " + cmd);
                 }
+                cmd = scriptFile.getAbsolutePath();
                 if (cmd.endsWith(".sh")) {
                     if(!scriptFile.setExecutable(true)){
                         System.err.println("Failed make script file 
executable: " + scriptFile);
@@ -129,6 +112,24 @@ public class ExecRunner {
 
         final Collection<String> params = new ArrayList<>();
         if ("java".equals(cmd)) {
+            final File[] extracted = distribOutput.listFiles();
+            if (extracted != null) {
+                File newRoot = null;
+                for (final File e : extracted) {
+                    if (e.isDirectory()) {
+                        if (newRoot == null) {
+                            newRoot = e;
+                        } else {
+                            newRoot = null;
+                            break;
+                        }
+                    }
+                }
+                if (newRoot != null) {
+                    distribOutput = newRoot;
+                }
+            }
+
             final QuickServerXmlParser parser = QuickServerXmlParser.parse(new 
File(distribOutput,"conf/server.xml"));
 
             System.setProperty("openejb.home", 
distribOutput.getAbsolutePath());

Reply via email to