From 076e388af4b8c87c349da593be0887c3791bf633 Mon Sep 17 00:00:00 2001
From: Mark Craig <mark.craig@forgerock.com>
Date: Tue, 31 Mar 2015 13:42:24 +0000
Subject: [PATCH] CR-6523 OPENDJ-1896 Facilitate debugging man page generation

---
 opendj-maven-plugin/src/main/java/org/forgerock/opendj/maven/GenerateRefEntriesMojo.java |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/opendj-maven-plugin/src/main/java/org/forgerock/opendj/maven/GenerateRefEntriesMojo.java b/opendj-maven-plugin/src/main/java/org/forgerock/opendj/maven/GenerateRefEntriesMojo.java
index 2dd9298..580521c 100644
--- a/opendj-maven-plugin/src/main/java/org/forgerock/opendj/maven/GenerateRefEntriesMojo.java
+++ b/opendj-maven-plugin/src/main/java/org/forgerock/opendj/maven/GenerateRefEntriesMojo.java
@@ -69,6 +69,8 @@
     @Parameter(required = true)
     private File outputDir;
 
+    private static final String EOL = System.getProperty("line.separator");
+
     /**
      * Writes a RefEntry file to the output directory for each tool.
      * Files names correspond to script names: {@code man-&lt;name>.xml}.
@@ -147,7 +149,16 @@
             process.waitFor();
             final int result = process.exitValue();
             if (result != 0) {
-                throw new MojoFailureException("Failed to write page. Tool exit code: " + result);
+                final StringBuilder message = new StringBuilder();
+                message.append("Failed to write page. Tool exit code: ").append(result).append(EOL);
+                message.append("To debug the problem, run the following command and connect your IDE:").append(EOL);
+                commands.add(1, "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000");
+                for (String arg: commands) {
+                    // Surround with quotes to handle trailing sections.
+                    message.append("\"").append(arg).append("\"").append(' ');
+                }
+                message.append(EOL);
+                throw new MojoFailureException(message.toString());
             }
         }  catch (InterruptedException e) {
             throw new MojoExecutionException(toolClass + " interrupted", e);
@@ -273,7 +284,7 @@
             String line;
             while ((line = reader.readLine()) != null) {
                 writer.write(line);
-                writer.write(System.getProperty("line.separator"));
+                writer.write(EOL);
             }
         } finally {
             if (writer != null) {

--
Gitblit v1.10.0