+package org.argeo.slc.ui.launch;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+import java.util.List;\r
+import java.util.Vector;\r
+\r
+import org.eclipse.core.runtime.CoreException;\r
+import org.eclipse.jdt.launching.IVMInstall;\r
+import org.eclipse.jdt.launching.JavaRuntime;\r
+\r
+public class DeployedSlcRuntime implements SlcRuntime {\r
+ private File baseDir;\r
+ private String relLibDir = "lib";\r
+\r
+ public DeployedSlcRuntime(String baseDirPath) {\r
+ try {\r
+ this.baseDir = new File(baseDirPath).getCanonicalFile();\r
+ } catch (IOException e) {\r
+ throw new RuntimeException("Cannot get path for " + baseDirPath, e);\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public String[] getClasspath() throws CoreException {\r
+ List<String> classpath = new Vector<String>();\r
+ File libDir = new File(baseDir.getPath() + File.separator + relLibDir);\r
+ File[] files = libDir.listFiles();\r
+ for (File file : files) {\r
+ try {\r
+ classpath.add(file.getCanonicalPath());\r
+ } catch (IOException e) {\r
+ throw new RuntimeException("Cannot get path for " + file, e);\r
+ }\r
+ }\r
+ return classpath.toArray(new String[classpath.size()]);\r
+ }\r
+\r
+ @Override\r
+ public IVMInstall getVmInstall() throws CoreException {\r
+ return JavaRuntime.getDefaultVMInstall();\r
+ }\r
+\r
+ public String getAntHome() {\r
+ return baseDir.getPath();\r
+ }\r
+\r
+ @Override\r
+ public String getJavaLibraryPath() {\r
+ return baseDir.getPath() + File.separator + "bin";\r
+ }\r
+\r
+}\r