Table of contents
1.
Introduction
2.
Application Profiles in Grails
3.
Creating Profiles
4.
Profile Inheritance
5.
Understanding Profiles
6.
Profile Commands
7.
Profile Features
8.
Publishing Profiles
8.1.
Publishing Profiles to Grails Central Repository
8.2.
Publishing Profiles to an Internal Repository
9.
Frequently Asked Questions
9.1.
What is the default profile when we create an app in grails?
9.2.
Name some application profiles in grails.
9.3.
Does profile inheritance allow CLI commands and features from the parent to be inherited?
9.4.
Where can we publish an application profile in Grails?
10.
Conclusion
Last Updated: Aug 13, 2025
Medium

Grails-Application Profiles

Author Aditya Kumar
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Hey Ninja!

Do you know what application profiles are in Grails? Have you ever heard how we create a profile in Grails? If not, then don't worry; we will help you.

application profiles in grails

 In this article, we’ll discuss application profiles in grails. We will also discuss how we can create them and how to publish them. But before that, let’s look at grails in brief. Grails make creating web applications in Java easier. It helps in reducing the complexity of making a web application in Java. Grails achieve this by using already existing technologies such as Hibernate and Spring. Let us understand what applications profiles are in Grails.

Application Profiles in Grails

Application Profiles in Grails can help you to use the profile's commands, templates, and plugins. Thus specifying a correct profile is very important. The default profile when we create an app in Grails. To create an application in Grails, we use the command 

grails create-app app_name

To change the profile, we specify the profile explicitly. For example,

$ grails create-app app_name --profile=web-plugin


The above command will create an app named 'app_name,' and the profile for the app will be web-plugin.

application profiles

We have a command to list all the application profiles in Grails. The command is

$ grails list-profiles

For information about application profiles in Grails, the command is

$ grails profile-info web-plugin

To use your profile with some defaults, we can specify the profile in the settings .groovy file such as

grails {
  profiles {
    my_own {
      groupId = "com.Coding Ninjas Studio.grails.profiles"
      version = "1.0.0"
    }
    repositories {
      ...
    }
  }
}


After specifying our profile, we can use it in the following manner:

$ grails create-app myapp --profile=my_own

Creating Profiles

When we create custom profiles, we can specify default values and plugins. 

creating profiles

To create custom profiles, we have the following command, which will create an empty profile in the mentioned directory:

$ grails create-profile Coding Ninjas Studio

If we use interactive mode in the directory, we get multiple commands for creating profiles:

commands for creating profiles

Below is the profile.yml file, which includes dependencies specific to our profile.

features:
    defaults:
        - hibernate
        - asset-pipeline
build:
    plugins:
        - org.grails.grails-web
    excludes:
        - org.grails.grails-core
dependencies:
    - scope: compile
      coords: "org.Coding Ninjas Studio:Coding Ninjas Studioplugin:1.0.1"
    - scope: testCompile
      coords: org.spockframework:spock-core
      excludes:
        - group: org.codehaus.groovy
          module: groovy-all

After the above configuration, we have our profile ready for publishing in the local repository.

Now, to install the profile, we need to type the following command:

$ gradle install

To use the profile we need to type the following command:

$ grails create-app myapp --profile Coding Ninjas Studio

Now let us understand what profile inheritance is.

Profile Inheritance

Profile inheritance means that you can extend other parent profiles. Also, inheritance allows CLI commands and features from the parent profile to be inherited.

profile inheritance

To inherit a profile, we need to modify the build.gradle of the profile. In the build.gradle file, we need to add the profile dependencies.

dependencies {
    runtime "org.grails.profiles:base:$baseprofile"
}

The above line will extend the base profile. Running an inherited profile with the create-app command will copy the parent's skeleton first.  Then application.yml, build.gradle, and dependencies will going to be merged. Let us now understand what profiles are.

Understanding Profiles

The profile contains a file profile.yml file. It also includes three other directories, 'commands,' 'templates,' and 'skeleton.' profile.yml describes the profile. It also controls how the build for the profile is configured.        

understanding profiles

Creating an app using the create-app command copies the parent's skeleton to a new project. After this, the build.gradle is generated.

We came across the profile.yml file a lot. Let us now understand it a bit better. 

Let us see what all is there in the file:

✍🏼repositories: It contains all the maven repos that the 'generated build' has to hold. Example-

repositories:
    - "https://repo.grails.org/grails/core"

✍🏼build.repositories: It contains all the maven repos that the 'generated build' has to hold in the  'buildscript section.' Example-

build:
    repositories:
        - "https://repo.grails.org/grails/core"

✍🏼build.plugins: It has all the gradle plugins which the ‘generated build’ has to configure. Example-

build:
    plugins:
        - eclipse
        - idea
        - org.grails.grails-core

✍🏼build.excludes: It has all the plugins we will not use. Example-

build:
    excludes:
        - org.grails.grails-core

✍🏼dependencies: It includes the map of scopes that are to be configured. Example-

dependencies:
    - scope: excludes
      coords: "org.grails:hibernate:*"
    - scope: build
      coords: "org.grails:grails-gradle-plugin:$grailsVersion"

✍🏼features.default: In this element we can define the default features. Example-

features:
    defaults:
        - hibernate

✍🏼skeleton.excludes: It has the files we want to exclude from the parent's skeleton. Example-

skeleton:
    excludes:
        - gradlew
        - gradlew.bat
        - gradle/

✍🏼skeleton.parent.target: It is the directory where the parent’s skeleton is copied.

✍🏼skeleton.binaryExtensions: It defines the extensions which we want as binary files.

✍🏼skeleton.executable: This defines the file patterns we want as executable in the application.

✍🏼instructions: This is the information that the user sees after the application is complete.

Now, let us understand what profile commands are.

Profile Commands

We can have our commands specific to our profile. We define the commands in the YAML file. The command can have one or multiple steps. Every single step we define is itself a command.

profile commands

Let us see what type of steps we can define:

🥷🏼render - This command helps in rendering a template to a specific location. 

🥷🏼mkdir - It makes a directory according to the location parameter.

🥷🏼execute - It executes a command that is specified by the class parameter.

🥷🏼gradle - It helps accomplish gradle tasks specified by task parameter.

Profile Features

Profile feature contains templates and dependencies. We can create a profile with mutiple features, and other child profiles can inherit the features. 

profile features

We use the following command to create a feature:

$ grails create-feature feature_name

Publishing Profiles

Now, let us understand how we can publish the profiles. We can do this in two ways:

publishing a profile

Publishing Profiles to Grails Central Repository

We can publish a profile using the plugin grails-profile-publish. First, we need to upload the source to GitHub. After uploading the source to GitHub, we need to register an account on Bintray. 

So basically, Bintray is a download hub with support for RPM and Debian packages and REST automation. Android libraries are frequently distributed via Maven or/and jCenter repositories.

After registering the account, we need to configure some keys in the build.gradle file.

grailsPublish {
  user = 'user_name'
  key = 'key_value'
  githubSlug = 'repository/profile_name'
  license = 'Apache-2.0'
}

After this, we can execute the $ gradle publishProfile command to publish the profile.

Publishing Profiles to an Internal Repository

Publishing profiles to an internal repository is more accessible than publishing them in the central repository. Because in this you don't need to sign in/ sign up on Bintray. We need to specify the repository in the build.gradle and execute the $ gradle publish command.

Here’s what we need to specify in the build.gradle file:

publishing {
    repositories {
        maven {
            credentials {
                username "Coding Ninjas Studio"
                password "gradle"
            }


            url "http://Coding Ninjas Studio.com/rep"
        }
    }
}

Frequently Asked Questions

What is the default profile when we create an app in grails?

The default application profile in Grails is the web.

Name some application profiles in grails.

The following application profiles in Grails: base, plugin, rest-api, web, web-plugin.

Does profile inheritance allow CLI commands and features from the parent to be inherited?

Yes, profile inheritance allows CLI commands and features from the parent profile to be inherited.

Where can we publish an application profile in Grails?

We can publish an application profile in Grails either in the Grails Central Repository or an Internal Repository.

Conclusion

In this article, we saw what are Application Profiles in Grails. We saw how we create a profile, what profile inheritance is, and how we can publish a profile. We also covered how we make profile commands and features. If you want to explore Grails then you can check out our other blogs:

Gear up your placement preparation by solving daily DSA problems. You can also refer to guided paths for learning about competitive programming. Also why not have a look at web technologies on Coding Ninjas Studio? Don't stop yourself here. Also, practice data structures and algorithmsinterview questionsDBMScomputer networks, and operating systems to crack the interviews of big tech giants. Explore other fields like machine learningdeep learningcomputer vision, and big data. Also, check out Interview Experiences for different companies.

Happy Learning!

Live masterclass