Skip to content
Newer
Older
100755 82 lines (70 sloc) 2.35 KB
3e17890 1.1 branch is now trunk
graeme authored Mar 13, 2009
1 /*
2 * Copyright 2004-2005 the original author or authors.
835947f @burtbeckwith cleanup
burtbeckwith authored Jun 22, 2010
3 *
3e17890 1.1 branch is now trunk
graeme authored Mar 13, 2009
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
835947f @burtbeckwith cleanup
burtbeckwith authored Jun 22, 2010
7 *
3e17890 1.1 branch is now trunk
graeme authored Mar 13, 2009
8 * http://www.apache.org/licenses/LICENSE-2.0
835947f @burtbeckwith cleanup
burtbeckwith authored Jun 22, 2010
9 *
3e17890 1.1 branch is now trunk
graeme authored Mar 13, 2009
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 /**
5730781 @burtbeckwith whitespace/cleanup
burtbeckwith authored May 30, 2011
18 * Gant script that loads the Grails console.
835947f @burtbeckwith cleanup
burtbeckwith authored Jun 22, 2010
19 *
3e17890 1.1 branch is now trunk
graeme authored Mar 13, 2009
20 * @author Graeme Rocher
21 *
22 * @since 0.4
23 */
24
4a69917 @burtbeckwith whitespace, STS warnings, etc.
burtbeckwith authored May 27, 2011
25 import java.awt.event.FocusEvent
26 import java.awt.event.FocusListener
27
5730781 @burtbeckwith whitespace/cleanup
burtbeckwith authored May 30, 2011
28 import org.codehaus.groovy.grails.compiler.GrailsProjectWatcher
3e17890 1.1 branch is now trunk
graeme authored Mar 13, 2009
29 import org.codehaus.groovy.grails.support.*
afed402 @graemerocher allow exiting the console whilst interactive mode is running
graemerocher authored Mar 21, 2012
30 import org.codehaus.groovy.grails.cli.interactive.*
3e17890 1.1 branch is now trunk
graeme authored Mar 13, 2009
31
32 includeTargets << grailsScript("_GrailsBootstrap")
33
34 target ('default': "Load the Grails interactive Swing console") {
78892f5 @burtbeckwith ensuring that ExpandoMetaClass.enableGlobally() gets called when runn…
burtbeckwith authored Jul 2, 2011
35 depends(checkVersion, configureProxy, enableExpandoMetaClass, packageApp, classpath, console)
835947f @burtbeckwith cleanup
burtbeckwith authored Jun 22, 2010
36 }
3e17890 1.1 branch is now trunk
graeme authored Mar 13, 2009
37
38 target(console:"The console implementation target") {
1fdbc4c @pledbrook Fix for GRAILS-6531: when we restarted the console, we created a new
pledbrook authored Jul 27, 2010
39 depends(loadApp, configureApp)
3e17890 1.1 branch is now trunk
graeme authored Mar 13, 2009
40
41 try {
afed402 @graemerocher allow exiting the console whilst interactive mode is running
graemerocher authored Mar 21, 2012
42 def console = createConsole()
43 console.run()
5730781 @burtbeckwith whitespace/cleanup
burtbeckwith authored May 30, 2011
44 def watcher = new GrailsProjectWatcher(projectCompiler, pluginManager)
4a69917 @burtbeckwith whitespace, STS warnings, etc.
burtbeckwith authored May 27, 2011
45 watcher.start()
46 // keep the console running
afed402 @graemerocher allow exiting the console whilst interactive mode is running
graemerocher authored Mar 21, 2012
47 while (!InteractiveMode.isActive()) {
4a69917 @burtbeckwith whitespace, STS warnings, etc.
burtbeckwith authored May 27, 2011
48 sleep(Integer.MAX_VALUE)
49 }
3e17890 1.1 branch is now trunk
graeme authored Mar 13, 2009
50 } catch (Exception e) {
51 event("StatusFinal", ["Error starting console: ${e.message}"])
52 }
53 }
54
55 createConsole = {
4a69917 @burtbeckwith whitespace, STS warnings, etc.
burtbeckwith authored May 27, 2011
56 def b = new Binding(ctx: appCtx, grailsApplication: grailsApp)
3e17890 1.1 branch is now trunk
graeme authored Mar 13, 2009
57
e3fb07d @burtbeckwith renamed 'console' binding variable to 'grailsConsole' since it confli…
burtbeckwith authored Jun 16, 2011
58 def groovyConsole = new groovy.ui.Console(grailsApp.classLoader, b)
59 groovyConsole.beforeExecution = {
3e17890 1.1 branch is now trunk
graeme authored Mar 13, 2009
60 appCtx.getBeansOfType(PersistenceContextInterceptor).each { k,v ->
61 v.init()
62 }
63 }
e3fb07d @burtbeckwith renamed 'console' binding variable to 'grailsConsole' since it confli…
burtbeckwith authored Jun 16, 2011
64 groovyConsole.afterExecution = {
3e17890 1.1 branch is now trunk
graeme authored Mar 13, 2009
65 appCtx.getBeansOfType(PersistenceContextInterceptor).each { k,v ->
66 v.flush()
67 v.destroy()
68 }
69 }
70
e3fb07d @burtbeckwith renamed 'console' binding variable to 'grailsConsole' since it confli…
burtbeckwith authored Jun 16, 2011
71 return groovyConsole
3e17890 1.1 branch is now trunk
graeme authored Mar 13, 2009
72 }
73
4a69917 @burtbeckwith whitespace, STS warnings, etc.
burtbeckwith authored May 27, 2011
74 class ConsoleFocusListener implements FocusListener {
835947f @burtbeckwith cleanup
burtbeckwith authored Jun 22, 2010
75 String text
4a69917 @burtbeckwith whitespace, STS warnings, etc.
burtbeckwith authored May 27, 2011
76 void focusGained(FocusEvent e) {
835947f @burtbeckwith cleanup
burtbeckwith authored Jun 22, 2010
77 e.source.text = text
78 e.source.removeFocusListener(this)
79 }
4a69917 @burtbeckwith whitespace, STS warnings, etc.
burtbeckwith authored May 27, 2011
80 void focusLost(FocusEvent e) {}
3e17890 1.1 branch is now trunk
graeme authored Mar 13, 2009
81 }
Something went wrong with that request. Please try again.