You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 10:26:32 UTC

[sling-slingstart-maven-plugin] 02/10: SLING-4677 allow to start Sling in debug mode with a simple mojo parameter

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag slingstart-maven-plugin-1.2.0
in repository https://gitbox.apache.org/repos/asf/sling-slingstart-maven-plugin.git

commit 265f5f4fa928a675bd13e835bacb912ce40b4482
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Wed Apr 29 17:55:45 2015 +0000

    SLING-4677 allow to start Sling in debug mode with a simple mojo parameter
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/maven/slingstart-maven-plugin@1676805 13f79535-47bb-0310-9956-ffa450edef68
---
 .../maven/slingstart/run/LauncherCallable.java     |  1 +
 .../maven/slingstart/run/ServerConfiguration.java  | 24 +++++++++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/maven/slingstart/run/LauncherCallable.java b/src/main/java/org/apache/sling/maven/slingstart/run/LauncherCallable.java
index a5218cb..8c22542 100644
--- a/src/main/java/org/apache/sling/maven/slingstart/run/LauncherCallable.java
+++ b/src/main/java/org/apache/sling/maven/slingstart/run/LauncherCallable.java
@@ -141,6 +141,7 @@ public class LauncherCallable implements Callable<ProcessDescription> {
 
         args.add("java");
         add(args, this.configuration.getVmOpts());
+        add(args, this.configuration.getVmDebugOpts());
 
         args.add("-cp");
         args.add("bin");
diff --git a/src/main/java/org/apache/sling/maven/slingstart/run/ServerConfiguration.java b/src/main/java/org/apache/sling/maven/slingstart/run/ServerConfiguration.java
index 8276dfc..604a91e 100644
--- a/src/main/java/org/apache/sling/maven/slingstart/run/ServerConfiguration.java
+++ b/src/main/java/org/apache/sling/maven/slingstart/run/ServerConfiguration.java
@@ -28,6 +28,9 @@ public class ServerConfiguration implements Serializable {
 
     private static final String DEFAULT_VM_OPTS = "-Xmx1024m -XX:MaxPermSize=256m -Djava.awt.headless=true";
 
+    // http://docs.oracle.com/javase/7/docs/technotes/guides/jpda/conninv.html#Invocation
+    private static final String DEFAULT_VM_DEBUG_OPTS = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000";
+
     /** The unique id. */
     private String id;
 
@@ -46,6 +49,9 @@ public class ServerConfiguration implements Serializable {
     /** The vm options. */
     private String vmOpts = DEFAULT_VM_OPTS;
 
+    /** Attach 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).*/
+    private String debug;
+
     /** Additional application options. */
     private String opts;
 
@@ -103,6 +109,21 @@ public class ServerConfiguration implements Serializable {
         this.vmOpts = vmOpts;
     }
 
+    /**
+     * @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() {
+        if (Boolean.valueOf(debug).equals(Boolean.TRUE)) {
+            return DEFAULT_VM_DEBUG_OPTS;
+        }
+        return debug;
+    }
+
+    public void setDebug(final String debug) {
+        this.debug = debug;
+    }
+
     public String getOpts() {
         return opts;
     }
@@ -151,6 +172,7 @@ public class ServerConfiguration implements Serializable {
         copy.setPort(this.getPort());
         copy.setContextPath(this.getContextPath());
         copy.setVmOpts(this.getVmOpts());
+        copy.setDebug(this.debug);
         copy.setOpts(this.getOpts());
         copy.setInstances(1);
         copy.setFolder(this.getFolder());
@@ -164,7 +186,7 @@ public class ServerConfiguration implements Serializable {
         return "LaunchpadConfiguration [id=" + id + ", runmode=" + runmode
                 + ", port=" + port + ", controlPort=" + controlPort
                 + ", contextPath=" + contextPath
-                + ", vmOpts=" + vmOpts + ", opts=" + opts + ", instances="
+                + ", vmOpts=" + vmOpts + ", vmDebugOpts=" + getVmDebugOpts() + ", opts=" + opts + ", instances="
                 + instances + ", folder=" + folder + "]";
     }
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.