copy groovy hotswap agent so that its path doesn't contain spaces, on unix (IDEA... cidr/96.64 idea/96.65 pycharm/96.63
authorpeter <peter.gromov@jetbrains.com>
Fri, 9 Apr 2010 12:33:44 +0000 (16:33 +0400)
committerpeter <peter.gromov@jetbrains.com>
Fri, 9 Apr 2010 12:35:05 +0000 (16:35 +0400)
plugins/groovy/hotswap/pluginSrc/META-INF/plugin.xml
plugins/groovy/hotswap/pluginSrc/org/jetbrains/plugins/groovy/debugger/GroovyHotSwapper.java

index c9ae3335026f94e1a0196eca050ef4a7e8e063dd..a14908dc40bd3242677ca396dce43548f564a9cb 100644 (file)
@@ -2,7 +2,7 @@
   <id>org.intellij.groovy.hotswap</id>
   <name>Groovy HotSwap</name>
   <description>Enables HotSwap functionality in Groovy classes</description>
-  <version>0.5</version>
+  <version>0.6</version>
   <idea-version since-build="94.632" until-build="96.1"/>
   <vendor logo="/org/jetbrains/plugins/groovy/images/groovy_16x16.png" url="http://www.jetbrains.com">JetBrains Inc.</vendor>
   <depends>org.intellij.groovy</depends>
index 77e40b67f901d3ed00a340cc6e2674a509ad7b57..a1cccf8e60a6c2a3ffb535f95eec8049703afd70 100644 (file)
@@ -6,15 +6,20 @@ import com.intellij.execution.configurations.RunConfiguration;
 import com.intellij.execution.configurations.RunProfile;
 import com.intellij.execution.executors.DefaultDebugExecutor;
 import com.intellij.execution.runners.JavaProgramPatcher;
+import com.intellij.openapi.application.PathManager;
 import com.intellij.openapi.application.PluginPathManager;
+import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.roots.LanguageLevelProjectExtension;
+import com.intellij.openapi.util.SystemInfo;
+import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.pom.java.LanguageLevel;
 import com.intellij.psi.search.FilenameIndex;
 import com.intellij.util.PathUtil;
 import org.jetbrains.plugins.groovy.GroovyFileTypeLoader;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -23,6 +28,7 @@ import java.util.List;
  * @author peter
  */
 public class GroovyHotSwapper extends JavaProgramPatcher {
+  private static final Logger LOG = Logger.getInstance("#org.jetbrains.plugins.groovy.debugger.GroovyHotSwapper");
 
   private static boolean endsWithAny(String s, List<String> endings) {
     for (String extension : endings) {
@@ -68,10 +74,25 @@ public class GroovyHotSwapper extends JavaProgramPatcher {
     }
 
     if (containsGroovyClasses(project)) {
-      javaParameters.getVMParametersList().add("-javaagent:" + getAgentJarPath());
+      javaParameters.getVMParametersList().add("-javaagent:" + handleSpacesInPath(getAgentJarPath()));
     }
   }
 
+  private static String handleSpacesInPath(String agentPath) {
+    if (SystemInfo.isUnix && agentPath.contains(" ")) {
+      final File dir = new File(PathManager.getSystemPath(), "groovyHotSwap");
+      final File toFile = new File(dir, "gragent.jar");
+      try {
+        FileUtil.copy(new File(agentPath), toFile);
+        return toFile.getPath();
+      }
+      catch (IOException e) {
+        LOG.info(e);
+      }
+    }
+    return agentPath;
+  }
+
   private static String getAgentJarPath() {
     final File ourJar = new File(PathUtil.getJarPathForClass(GroovyHotSwapper.class));
     if (ourJar.isDirectory()) { //development mode