changeset 5158:8ea90b7c8586

made eclipseinit generate Eclipse debug-on-attach launch config in mx/attach-8000.launch
author Doug Simon <doug.simon@oracle.com>
date Mon, 26 Mar 2012 22:25:26 +0200
parents 2a3938fac230
children 24c77ad284dc
files mxtool/mx.py
diffstat 1 files changed, 22 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mxtool/mx.py	Mon Mar 26 22:24:07 2012 +0200
+++ b/mxtool/mx.py	Mon Mar 26 22:25:26 2012 +0200
@@ -124,7 +124,7 @@
 Property values can use environment variables with Bash syntax (e.g. ${HOME}).
 """
 
-import sys, os, errno, time, subprocess, shlex, types, urllib2, contextlib, StringIO, zipfile, signal
+import sys, os, errno, time, subprocess, shlex, types, urllib2, contextlib, StringIO, zipfile, signal, xml.sax.saxutils
 import shutil, fnmatch, re, xml.dom.minidom
 from collections import Callable
 from threading import Thread
@@ -1379,6 +1379,9 @@
     def println(out, obj):
         out.write(str(obj) + '\n')
 
+    source_locator_memento = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<sourceLookupDirector><sourceContainers duplicates="false">'
+    entities = { '"':  "&quot;", "'":  "&apos;", '\n': '&#10;' }
+
     for p in projects():
         if p.native:
             continue
@@ -1492,7 +1495,6 @@
         update_file(join(p.dir, '.project'), out.getvalue())
         out.close()
 
-        out = StringIO.StringIO()
         settingsDir = join(p.dir, ".settings")
         if not exists(settingsDir):
             os.mkdir(settingsDir)
@@ -1506,6 +1508,24 @@
                         content = f.read()
                     content = content.replace('${javaCompliance}', str(p.javaCompliance))
                     update_file(join(settingsDir, name), content)
+                    
+        memento = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<javaProject name="' + p.name + '"/>\n'
+        source_locator_memento += '\n<container memento="' + xml.sax.saxutils.escape(memento, entities) + '" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/>'
+        
+    source_locator_memento += '</sourceContainers>\n</sourceLookupDirector>'
+    launch = r"""<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.launching.remoteJavaApplication">
+<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
+<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="{0}"/>
+<booleanAttribute key="org.eclipse.jdt.launching.ALLOW_TERMINATE" value="true"/>
+<mapAttribute key="org.eclipse.jdt.launching.CONNECT_MAP">
+<mapEntry key="hostname" value="localhost"/>
+<mapEntry key="port" value="8000"/>
+</mapAttribute>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value=""/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_CONNECTOR_ID" value="org.eclipse.jdt.launching.socketAttachConnector"/>
+</launchConfiguration>""".format(xml.sax.saxutils.escape(source_locator_memento, entities))
+    update_file(join(suite.dir, 'mx', 'attach-8000.launch'), launch)
 
 def netbeansinit(args, suite=None):
     """(re)generate NetBeans project configurations"""