Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 32 Next »

Grails File Structure

In Grails they stress convention over configuration.  Grails basic structures follow the MVC pattern.  The grails-app/domain directory holds the Models, the grails-app/views directory holds the Views and the grails-app/controllers directory holds the Controllers.  There are 

%PROJECT HOME%

  • grails-app
    • conf
      • BootStrap.groovy                        <- Initializes the database with given data.
      • BuildConfig.groovy                      <- Holds configurations for the build (dependencies, plugins, repositories, error logging level).
      • Config.groovy                             <- Holds various configurations for the project.
      • DataSource.groovy                     <- Holds database settings for each type of environment.
      • SpringSecurityConfig.groovy        <- Holds additional configuration settings for the Spring Security plugins.  Has to be included at the
                                                             beginning of Config.groovy.
      • UrlMappings.groovy                    <- Allows the changing of the Url scheme.
    • controllers          <- Holds the controller classes.
    • domain               <- Holds the model classes, grails will by default create a corresponding table for each file in this
                                    directory.
    • services              <- Directory to hold any services the application will host.
    • views                  <- Holds the view gsps.
  • lib
  • scripts               <- Holds the various grails command scripts as well as any user-defined scripts.
  • src
    • groovy                <- Generic groovy source files that don't have a conventional location.
    • java                    <- Java source files, will be compiled and included in WAR file.
  • test                   <- Holds the test files that will be run by the "grails test-app" script.

Grails Commands

Running grails is done through script commands in the command windows after installing grails.

Some commonly used commands:

  • grails create-app " " - Sets up the new project, creating the file structure.
  • grails clean - Deletes all compiled resources from the application, usually used before running application.
  • grails run-app - Runs the application.
  • grails create-domain-class " " - Creates a domain class of the given name (ex. edu.hawaii.its.holidayWebService.Holidays will create the Holidays domain
                                                  class in the package edu.hawaii.its.holidayWebService)
  • grails create-service " " - Creates a service class.
  • grails generate-all " " - Creates a fully implemented controller and a corresponding set of GSP views.

All the commands can be seen here or by running the "grails help" script from the command line.

  • No labels