Currently only a few IDE support Grails 3, and they are Netbeans https://netbeans.org/, and Intellij IDEA Ultimate Edition https://www.jetbrains.com/idea/. Note that the Intellij IDEA Community Edition would still able to build and run Grails 3 code, but the syntax highlight would be missing! For this page, we will focus on IntelliJ IDEA Ultimate.
The reason of using an IDE is that, it has the code syntax highlight, auto complete, easy to search, and it has a good graphic user interface (GUI) for us to run, compile the project. Intellij is pricey, but it worths every penny.
File → Settings…
.Appearance & Behavior → System Settings → HTTP Proxy
. Host Name
, Port number
Proxy authentication
, and type in the Login
, and Password
. It would be nice to have the Intellij to remember this authentication so that you do not need to type it again each time.File
→ New
→ Project…
.Grails
in the side bar.File
→ New
→ Project from Existing Sources…
.Since Grails project come with it own embedded Apache Tomcat, it is self-contained. You can run it as a server without installing any java container.
To run it click Run → Run
or Run → Debug
from the menu bar. You can also run it by clicking the run, debug button on the top right corner. If everything is correct, you will see the following output from the Run windows.
"C:\Program Files\Java\jdk1.8.0_131\bin\java.exe" -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:CICompilerCount=3 -Djline.WindowsTerminal.directConsole=false -Dfile.encoding=UTF-8 -classpath C:\Users\xxxxxx\AppData\Local\Temp\classpath1472089875.jar org.grails.cli.GrailsCli run-app --plain-output |Resolving Dependencies. Please wait... CONFIGURE SUCCESSFUL Total time: 8.602 secs |Running application... Grails application running at http://localhost:8080 in environment: development
To test if the server is run correctly, go to http://localhost:8080
with your web browser. You should see a welcome Grails page.
To Export a war file for your web server, click Build → Make Grails Web Archive
from the menu bar.
It will take some time to generate a war file. You can see the following output in the Grails Console
. The output war file is a production one, and it is located at YOUR_PROJECT_LOCATION\build\libs\YOUR_PROJECT_NAME_VERSION.war
.
... :compileJava NO-SOURCE :compileGroovy :findMainClass :assetCompile Processing File 4 of 26 - grails-cupsonly-logo-white.svg Processing File 2 of 26 - apple-touch-icon.png Processing File 1 of 26 - apple-touch-icon-retina.png Processing File 3 of 26 - favicon.ico Processing File 5 of 26 - grails.svg Processing File 6 of 26 - skin/database_add.png Processing File 7 of 26 - skin/database_delete.png Processing File 8 of 26 - skin/database_edit.png Processing File 9 of 26 - skin/database_save.png Processing File 10 of 26 - skin/database_table.png Processing File 11 of 26 - skin/exclamation.png Processing File 12 of 26 - skin/house.png Processing File 13 of 26 - skin/information.png Processing File 14 of 26 - skin/shadow.jpg Processing File 15 of 26 - skin/sorted_asc.gif Processing File 16 of 26 - skin/sorted_desc.gif Processing File 17 of 26 - spinner.gif Processing File 18 of 26 - application.js Processing File 19 of 26 - bootstrap.js Processing File 20 of 26 - jquery-2.2.0.min.js Processing File 21 of 26 - application.css Processing File 22 of 26 - bootstrap.css Processing File 23 of 26 - errors.css Processing File 24 of 26 - grails.css Processing File 25 of 26 - main.css Processing File 26 of 26 - mobile.css Finished Precompiling Assets :buildProperties :processResources :classes :compileWebappGroovyPages NO-SOURCE :compileGroovyPages :war :bootRepackage :assemble BUILD SUCCESSFUL Total time: 18.912 secs |Built application to build\libs using environment: production