////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
////

When you create a Grails application with the link:{commandLineRef}create-app.html[create-app] command by default the "web" profile is used:

[source,console]
----
$ grails create-app myapp
----

You can specify a different profile with the `--profile` argument:

[source,console]
----
$ grails create-app myapp --profile=rest-api
----

Profiles encapsulate the project commands, templates, and plugins that are designed to work for a given profile. The source for the profiles can be found https://github.com/apache/grails-core/tree/HEAD/grails-profiles[on GitHub], and the profiles themselves are published as JAR files to the Grails central repository.

To find out what profiles are available, use the link:{commandLineRef}list-profiles.html[list-profiles] command:

[source,console]
----
$ grails list-profiles
----

For more information on a particular profile, use the link:{commandLineRef}profile-info.html[profile-info] command:

[source,console]
----
$ grails profile-info rest-api
----

NOTE: Commands such as `profile-info` or `list-profiles` are not available when you invoke the Grails CLI inside a grails project.

==== Profile Repositories


By default, Grails will resolve profiles from  https://repo1.maven.org/maven2/org/apache/grails/profiles/[Maven central repository]. However, you can override what repositories will be searched by specifying repositories in the `USER_HOME/.grails/settings.groovy` file.

If you want profiles to be resolved with a custom repository in addition to the Maven central repository, you must specify Maven central in the file as well:

[source,groovy]
----
grails {
  profiles {
    repositories {
      myRepo {
        url = "https://foo.com/repo"
        snapshotsEnabled = true
      }
      mavenCentral()
    }
  }
}
----

NOTE: Grails uses Aether to resolve profiles, as a Gradle instance is not yet available when the `create-app` command is executed. This means that you can also define repositories and more advanced configuration (proxies, authentication etc.) in your `USER_HOME/.m2/settings.xml` file if you wish.

It is also possible to store simple credentials for profile repositories directly in the `USER_HOME/.grails/settings.groovy` file.

[source,groovy]
----
grails {
  profiles {
    repositories {
      myRepo {
        url = "https://foo.com/repo"
        snapshotsEnabled = true
        username = "user"
        password = "pass"
      }
      ...
    }
  }
}
----


==== Profile Defaults


To create an application that uses a custom profile, you must specify the full artifact.

[source,console]
----
$ grails create-app myapp --profile=com.mycompany.grails.profiles:myprofile:1.0.0
----

To simplify this process, you can define defaults for that profile in your `USER_HOME/.grails/settings.groovy` file:

[source,groovy]
----
grails {
  profiles {
    myprofile {
      groupId = "com.mycompany.grails.profiles"
      version = "1.0.0"
    }
    repositories {
      ...
    }
  }
}
----

With the defaults set, the following command will use the defined group ID and version:

[source,console]
----
$ grails create-app myapp --profile=myprofile
----

