Author: kwin
Date: Tue May  5 12:24:46 2015
New Revision: 1677798

URL: http://svn.apache.org/r1677798
Log:
SLING-4677 allow to override debug settings of all controlled Sling servers 
through Mojo parameter

Modified:
    
sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/run/LauncherCallable.java
    
sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/run/LaunchpadEnvironment.java
    
sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/run/ServerConfiguration.java
    
sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/run/StartMojo.java

Modified: 
sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/run/LauncherCallable.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/run/LauncherCallable.java?rev=1677798&r1=1677797&r2=1677798&view=diff
==============================================================================
--- 
sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/run/LauncherCallable.java
 (original)
+++ 
sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/run/LauncherCallable.java
 Tue May  5 12:24:46 2015
@@ -141,7 +141,7 @@ public class LauncherCallable implements
 
         args.add("java");
         add(args, this.configuration.getVmOpts());
-        add(args, this.configuration.getVmDebugOpts());
+        add(args, 
this.configuration.getVmDebugOpts(this.environment.getDebug()));
 
         args.add("-cp");
         args.add("bin");

Modified: 
sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/run/LaunchpadEnvironment.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/run/LaunchpadEnvironment.java?rev=1677798&r1=1677797&r2=1677798&view=diff
==============================================================================
--- 
sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/run/LaunchpadEnvironment.java
 (original)
+++ 
sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/run/LaunchpadEnvironment.java
 Tue May  5 12:24:46 2015
@@ -35,15 +35,18 @@ public class LaunchpadEnvironment {
     private final boolean cleanWorkingDirectory;
     private final boolean shutdownOnExit;
     private final int readyTimeOutSec;
+    private final String debug;
 
     public LaunchpadEnvironment(final File launchpadJar,
                                 final boolean cleanWorkingDirectory,
                                 final boolean shutdownOnExit,
-                                final int readyTimeOutSec) {
+                                final int readyTimeOutSec,
+                                final String debug) {
         this.launchpadJar = launchpadJar;
         this.cleanWorkingDirectory = cleanWorkingDirectory;
         this.shutdownOnExit = shutdownOnExit;
         this.readyTimeOutSec = readyTimeOutSec;
+        this.debug = debug;
     }
 
     public boolean isShutdownOnExit() {
@@ -137,4 +140,13 @@ public class LaunchpadEnvironment {
             }
         }
     }
+
+    /**
+     * 
+     * @return the global debug parameter for all Sling instances. Set through 
{@link StartMojo#debug}.
+     */
+    public String getDebug() {
+        return debug;
+    }
+
 }

Modified: 
sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/run/ServerConfiguration.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/run/ServerConfiguration.java?rev=1677798&r1=1677797&r2=1677798&view=diff
==============================================================================
--- 
sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/run/ServerConfiguration.java
 (original)
+++ 
sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/run/ServerConfiguration.java
 Tue May  5 12:24:46 2015
@@ -110,10 +110,18 @@ public class ServerConfiguration impleme
     }
 
     /**
+     * Returns the debugging options derived from the passed globalDebug 
parameter and the debug field (where the globalDebug parameter has precedence 
over the local field)
+     * @param globalDebug the global debug options (may be {@code null}).
      * @return the debugging options to use or {@code null}. Should be 
appended to the ones being returned by {@link #getVmOpts()}.
      * @see <a 
href="http://docs.oracle.com/javase/7/docs/technotes/guides/jpda/conninv.html#Invocation";>JPDA
 Sun VM Invocation Options</a>
      */
-    public String getVmDebugOpts() {
+    public String getVmDebugOpts(String globalDebug) {
+        if (globalDebug != null) {
+            if (Boolean.valueOf(globalDebug).equals(Boolean.TRUE)) {
+                return DEFAULT_VM_DEBUG_OPTS;
+            }
+            return globalDebug;
+        }
         if (Boolean.valueOf(debug).equals(Boolean.TRUE)) {
             return DEFAULT_VM_DEBUG_OPTS;
         }
@@ -186,7 +194,7 @@ public class ServerConfiguration impleme
         return "LaunchpadConfiguration [id=" + id + ", runmode=" + runmode
                 + ", port=" + port + ", controlPort=" + controlPort
                 + ", contextPath=" + contextPath
-                + ", vmOpts=" + vmOpts + ", vmDebugOpts=" + getVmDebugOpts() + 
", opts=" + opts + ", instances="
+                + ", vmOpts=" + vmOpts + ", vmDebugOpts=" + 
getVmDebugOpts(null) + ", opts=" + opts + ", instances="
                 + instances + ", folder=" + folder + "]";
     }
 }

Modified: 
sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/run/StartMojo.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/run/StartMojo.java?rev=1677798&r1=1677797&r2=1677798&view=diff
==============================================================================
--- 
sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/run/StartMojo.java
 (original)
+++ 
sling/trunk/tooling/maven/slingstart-maven-plugin/src/main/java/org/apache/sling/maven/slingstart/run/StartMojo.java
 Tue May  5 12:24:46 2015
@@ -74,6 +74,13 @@ public class StartMojo extends AbstractM
      */
     @Parameter
     private List<ServerConfiguration> servers;
+    
+    /**
+     * Overwrites debug parameter of all server configurations (if set).
+     * Attaches a debugger to the forked JVM. If set to "true", the process 
will allow a debugger to attach on port 8000. If set to some other string, that 
string will be appended to the vmOpts, allowing you to configure arbitrary 
debuggability options (without overwriting the other options specified through 
the vmOpts parameter of the servers).
+     */
+    @Parameter(property = "launchpad.debug")
+    protected String debug;
 
     /**
      * Ready timeout in seconds. If the launchpad has not been started in this
@@ -189,7 +196,8 @@ public class StartMojo extends AbstractM
         final LaunchpadEnvironment env = new 
LaunchpadEnvironment(this.findLaunchpadJar(),
                 this.cleanWorkingDirectory,
                 !this.keepLaunchpadRunning,
-                this.launchpadReadyTimeOutSec);
+                this.launchpadReadyTimeOutSec,
+                this.debug);
 
         // create callables
         final Collection<LauncherCallable> tasks = new 
LinkedList<LauncherCallable>();


Reply via email to