6.4 Understanding Profiles 3.1.4

See the light - agile, industrial strength, rapid web application development made easy

(Quick Reference) # 6.4 Understanding Profiles - Reference Documentation Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith, Lari Hotari Version: 3.1.4 ## 6.4 Understanding Profiles A profile is a simple directory that contains a `profile.yml` file and directories containing the "commands", "skeleton" and "templates" defined by the profile. Example:
    web
        * commands
            * create-controller.yml
            * run-app.groovy
            …
        * features
            * asset-pipeline
                * skeleton
                * feature.yml
        * skeleton
            * grails-app
                * controllers
                …
            * build.gradle
        * templates
            * artifacts
                * Controller.groovy
        * profile.yml
The above example is a snippet of structure of the 'web' profile. The `profile.yml` file is used to describe the profile and control how a the build is configured. #### Understanding the profile.yml descriptor The `profile.yml` can contain the following child elements. #### 1) repositories A list of Maven repositories to include in the generated build. Example:
    repositories:
        - "https://repo.grails.org/grails/core"
#### 2) build.repositories A list of Maven repositories to include in the buildscript section of the generated build. Example:
    build:
        repositories:
            - "https://repo.grails.org/grails/core"
#### 3) build.plugins A list of Gradle plugins to configure in the generated build. Example:
    build:
        plugins:
            - eclipse
            - idea
            - org.grails.grails-core
#### 4) build.excludes A list of Gradle plugins to exclude from being inherited from the parent profile:
    build:
        excludes:
            - org.grails.grails-core
#### 5) dependencies A map of scopes and dependencies to configure. The `excludes` scope can be used to exclude from the parent profile. Example:
    dependencies:
        excludes:
            - "org.grails:hibernate"
        build:
            - "org.grails:grails-gradle-plugin:$grailsVersion"
        compile:
            - "org.springframework.boot:spring-boot-starter-logging"
            - "org.springframework.boot:spring-boot-autoconfigure"
#### 6) features.defaults A default list of features to use if no explicit features are specified.
    features:
        defaults:
            - hibernate
            - asset-pipeline
#### What happens when a profile is used? When the `create-app` command runs it takes the skeleton of the parent profiles and copies the skeletons into a new project structure. The `build.gradle` file is generated as is result of obtaining all of the dependency information defined in the `profile.yml` files and produces the required dependencies. The command will also merge any `build.gradle` files defined within a profile and its parent profiles. The `grails-app/conf/application.yml` file is also merged into a a single YAML file taking into account the profile and all of the parent profiles. | Quick Reference (hide)