1 package org.codehaus.mojo.gwt.shell;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.artifact.Artifact;
23 import org.apache.maven.plugin.MojoExecutionException;
24 import org.apache.maven.plugin.MojoFailureException;
25 import org.apache.maven.plugins.annotations.Execute;
26 import org.apache.maven.plugins.annotations.LifecyclePhase;
27 import org.apache.maven.plugins.annotations.Mojo;
28 import org.apache.maven.plugins.annotations.Parameter;
29 import org.apache.maven.plugins.annotations.ResolutionScope;
30 import org.apache.maven.project.MavenProject;
31
32 import java.io.File;
33
34
35
36
37
38
39
40 @Mojo(name = "run-codeserver", requiresDirectInvocation = true, requiresDependencyResolution = ResolutionScope.COMPILE)
41 @Execute(phase = LifecyclePhase.PROCESS_CLASSES)
42 public class SuperDevModeMojo extends AbstractGwtShellMojo
43 {
44
45
46
47
48
49
50 @Parameter(property = "gwt.bindAddress")
51 private String bindAddress;
52
53
54
55
56 @Parameter(property = "gwt.codeServerPort")
57 private Integer codeServerPort;
58
59
60
61
62
63 @Parameter
64 private File codeServerWorkDir;
65
66
67
68
69
70
71 @Parameter(defaultValue = "true", property = "gwt.codeServer.precompile")
72 private boolean precompile;
73
74
75
76
77
78
79 @Parameter(defaultValue = "auto", property = "maven.compiler.source")
80 private String sourceLevel;
81
82
83
84
85
86
87
88
89 @Parameter(alias = "strict", defaultValue = "false", property = "gwt.compiler.strict")
90 private boolean failOnError;
91
92
93
94
95
96
97 @Parameter(alias = "compilePerFile", defaultValue = "true", property = "gwt.compiler.incremental")
98 private boolean incremental;
99
100
101
102
103
104
105 @Parameter(alias = "generateJsInteropExports", defaultValue = "false", property = "gwt.compiler.generateJsInteropExports")
106 private boolean generateJsInteropExports;
107
108
109
110
111
112
113
114
115 @Parameter(defaultValue = "NONE", property = "gwt.compiler.methodNameDisplayMode")
116 private String methodNameDisplayMode;
117
118
119
120
121
122
123 @Parameter(property = "gwt.codeServer.launcherDir")
124 private File launcherDir;
125
126
127
128
129 @Parameter(defaultValue = "${executedProject}")
130 private MavenProject executedProject;
131
132 @Override
133 public void doExecute()
134 throws MojoExecutionException, MojoFailureException
135 {
136 JavaCommand cmd = createJavaCommand()
137 .setMainClass( "com.google.gwt.dev.codeserver.CodeServer" );
138
139 if ( gwtSdkFirstInClasspath )
140 {
141 cmd.addToClasspath( getGwtUserJar() )
142 .addToClasspath( getGwtDevJar() );
143 }
144
145 cmd.addToClasspath( getClasspath( Artifact.SCOPE_COMPILE ) );
146 addCompileSourceArtifacts( cmd );
147 addPersistentUnitCache(cmd);
148
149 if ( !gwtSdkFirstInClasspath )
150 {
151 cmd.addToClasspath( getGwtUserJar() )
152 .addToClasspath( getGwtDevJar() );
153 }
154
155 cmd.arg( "-logLevel", getLogLevel() );
156 cmd.arg( !precompile, "-noprecompile" );
157 cmd.arg( "-sourceLevel", sourceLevel );
158 cmd.arg( failOnError, "-failOnError" );
159 cmd.arg( !incremental, "-noincremental" );
160 cmd.arg( generateJsInteropExports, "-generateJsInteropExports" );
161
162 if ( style != null && style.length() > 0 )
163 {
164 cmd.arg( "-style", style );
165 }
166
167 if ( methodNameDisplayMode != null && methodNameDisplayMode.length() > 0 && !methodNameDisplayMode.equals( "NONE" ))
168 {
169 cmd.arg( "-XmethodNameDisplayMode", methodNameDisplayMode );
170 }
171 if ( bindAddress != null && bindAddress.length() > 0 )
172 {
173 cmd.arg( "-bindAddress", bindAddress );
174 }
175 if ( codeServerPort != null )
176 {
177 cmd.arg( "-port", String.valueOf( codeServerPort ) );
178 }
179 if ( codeServerWorkDir != null )
180 {
181 codeServerWorkDir.mkdirs();
182 cmd.arg( "-workDir", codeServerWorkDir.getAbsolutePath() );
183 }
184
185 if ( launcherDir != null )
186 {
187 cmd.arg( "-launcherDir", launcherDir.getAbsolutePath() );
188 }
189
190 for ( String module : getModules() )
191 {
192 cmd.arg( module );
193 }
194
195 try
196 {
197 cmd.execute();
198 }
199 catch ( JavaCommandException e )
200 {
201 throw new MojoExecutionException( e.getMessage(), e );
202 }
203 }
204
205 public void setExecutedProject( MavenProject executedProject )
206 {
207 this.executedProject = executedProject;
208 }
209
210 @Override
211 public MavenProject getProject()
212 {
213 return executedProject;
214 }
215 }
216