====== Using Console to Create and Build a Project ====== ===== Create a Project ===== - Assume the development environment has been set up correctly. If not go see [[grails:setup_grails_3_development_environment]]. - Check to the directory you want to work on. ''d:\grailsapp'' for example. C:\>d: D:\>cd\grailsapp D:\grailsapp> - Create the app with the create-app command. The following code show how to create an app with name helloworld. D:\grailsapp>grails create-app helloworld | Application created at D:\grailsapp\helloworld - We now have an new app under helloworld directory. We can ''cd'' in it, and start to work with it. ===== Run a Project ===== - Go to your project directory - Type the command ''grails'' to enter Grails mode. It might take some time for Grails to download the libraries for the first time. D:\grailsapp\helloworld>grails BUILD SUCCESSFUL | Enter a command name to run. Use TAB for completion: grails> - Grails, inherit from Spring Boot, has it own embedded Apache Tomcat. Thus it is a self-contained web-app. - To run your app, type the command ''run-app'' grails> run-app | Running application... Grails application running at http://localhost:8080 in environment: development grails> - Note that your app is now running in the back ground. You can stop your app by using command ''stop-app''. - To test the web-app, open a web browser and input the URL http://localhost:8080 as instructed. You should able to see the Grails welcome page. ===== Build a war File ===== There are three different versions of war file you can build, and they are the ''test'', ''development'', and ''production'' versions. In any case, the output war file will be located at ''YOUR_PROJECT_LOCATION\build\libs\YOUR_PROJECT_NAME_VERSION.war''. You might deploy such war file to a Java Servlet Container such as Apache Tomcat[[http://tomcat.apache.org/]] or Undertow[[http://undertow.io/]]. ==== Test Version ==== In grails mode, type ''test war'' grails> test war . . . BUILD SUCCESSFUL Total time: 5.634 secs | Built application to build\libs using environment: test grails> ==== Development Version ==== In grails mode, type ''dev war'' grails> dev war . . . BUILD SUCCESSFUL Total time: 5.619 secs | Built application to build\libs using environment: development grails> ==== Production Version ==== In grails mode, type ''prod war'' or ''assemble'' grails> prod war . . . BUILD SUCCESSFUL Total time: 5.447 secs | Built application to build\libs using environment: production grails>