Grails Version 2
- Convention over Configuration
grails-app - top level directory for Groovy sources
conf - Configuration sources.
controllers - Web controllers - The C in MVC.
domain - The application domain.
i18n - Support for internationalization (i18n).
services - The service layer.
taglib - Tag libraries.
utils - Grails specific utilities.
views - Groovy Server Pages - The V in MVC.
scripts - Gant scripts.
src - Supporting sources
groovy - Other Groovy sources
java - Other Java sources
test - Unit and integration tests.
- Configuration
- grails-app/conf/BuildConfig.groovy : Used when your are running grails commands
grailsVersion The version of Grails used to build the project.
grailsSettings An object containing various build related settings, such as baseDir. It's of type BuildSettings.
- grails-app/conf/Config.groovy : Used when that application is running. It is packaged with the app.
grailsApplication The GrailsApplication instance
- Both
userHome Location of the home directory for the account that is running the Grails application.
grailsHome Location of the home directory for the account that is running the Grails application.
appName The application name as it appears in application.properties.
appVersion The application version as it appears in application.properties.
For example:
my.tmp.dir = "${userHome}/.grails/tmp"
class MyService {
def grailsApplication
def method() {
def recipient = grailsApplication.config.foo.bar.hello //Can be used directly in Controller or by Injection in Service.
}
}
- Gorm
- grails.gorm.failOnError. If true throws a grails.validation.ValidationException
grails.gorm.failOnError = ['com.companyname.somepackage']
- grails.gorm.autoFlush, to auto flush in mege, save, delete. No need to use save(flush: true
- Enviroment
- Used in Config.groovy, DataSource.groovy and Bootstrap.groovy.
- DataSource
- grails.project.dependency.resolution = {
...
dependencies {
runtime 'mysql:mysql-connector-java:5.1.16'
} }
- dbCreate: create, create-drop, update, validate.
- Multiple Datasources: ex: dataSource_lookup, dataSouce_lookup2.
- Configuring Domain Classes
mapping = {
datasources(['lookup', 'auditing']) or datasources(['lookup', 'DEFAULT']) datasource 'ALL'
- Configurations and Dependencies
- build(Dependencies for the build system only), compile, runtime, test,
provided( Dependencies needed at development time, but not during WAR deployment)
- Repositories
- In BuildConfig.groovy.
repositories {
mavenCentral()
}
- Depoy to a maven repository
- grails maven-install(install project or plugin local Maven cache) or maven-deploy(deploy project in a remote Maven repository)
- Grails commands
- Maven integration
grails create-pom com.mycompany
- General Commands
grails:create-controller - Calls the create-controller command
grails:create-domain-class - Calls the create-domain-class command
grails:create-integration-test - Calls the create-integration-test command
grails:create-pom - Creates a new Maven POM for an existing Grails project
grails:create-script - Calls the create-script command
grails:create-service - Calls the create-service command
grails:create-taglib - Calls the create-tag-lib command
grails:create-unit-test - Calls the create-unit-test command
grails:exec - Executes an arbitrary Grails command line script
grails:generate-all - Calls the generate-all command
grails:generate-controller - Calls the generate-controller command
grails:generate-views - Calls the generate-views command
grails:install-templates - Calls the install-templates command
grails:list-plugins - Calls the list-plugins command
grails:package - Calls the package command
grails:run-app - Calls the run-app command
For a complete, up to date list, run mvn grails:help
Nenhum comentário:
Postar um comentário