1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.scala_tools.maven;
17
18 import java.io.File;
19 import java.util.HashSet;
20 import java.util.Set;
21
22
23
24
25
26
27
28
29 public class ScalaConsoleMojo extends ScalaMojoSupport {
30
31
32
33
34
35
36
37 protected String mainConsole;
38
39
40
41
42
43
44
45 protected boolean useTestClasspath;
46
47
48
49
50
51
52
53 protected boolean useRuntimeClasspath;
54
55
56
57
58
59
60
61 protected File javaRebelPath;
62
63 @Override
64 @SuppressWarnings("unchecked")
65 protected void doExecute() throws Exception {
66 Set<String> classpath = new HashSet<String>();
67 addToClasspath("org.scala-lang", "scala-compiler", scalaVersion, classpath);
68 addToClasspath("org.scala-lang", "scala-library", scalaVersion, classpath);
69 classpath.addAll(project.getCompileClasspathElements());
70 if (useTestClasspath) {
71 classpath.addAll(project.getTestClasspathElements());
72 }
73 if (useRuntimeClasspath) {
74 classpath.addAll(project.getRuntimeClasspathElements());
75 }
76 String classpathStr = JavaCommand.toMultiPath(classpath.toArray(new String[classpath.size()]));
77 JavaCommand jcmd = new JavaCommand(this, mainConsole, classpathStr, jvmArgs, args);
78 if (javaRebelPath != null) {
79 if (!javaRebelPath.exists()) {
80 getLog().warn("javaRevelPath '"+javaRebelPath.getCanonicalPath()+"' not found");
81 } else {
82 jcmd.addJvmArgs("-noverify", "-javaagent:" + javaRebelPath.getCanonicalPath());
83 }
84 }
85 jcmd.setLogOnly(false);
86 jcmd.run(displayCmd);
87 }
88 }