Step 2: Create a Module

A module is again a gradle project, created inside modules directory.

In this section, we will see how to create a simple axelor-contact module. This demo module defines some objects for managing contacts.

Go to the application project directory and issue following command:

$ cd /path/axelor-demo
$ axelor new-module --name axelor-contact

A new module will be created inside modules/axelor-contact directory with a sample object and views.

The directory structure of the module looks like this:

├── build.gradle (1)
└── src
    └── main
        └── resources
            ├── domains (2)
            │   └── HelloContact.xml (3)
            └── views (4)
                ├── HelloContact.xml (5)
                └── Menu.xml (6)
1 The gradle build script
2 The domains directory contains definition of model objects
3 The domain object definition (sample)
4 The views directory contains definition of the object views
5 The view definitions for the domain object (sample)
6 The menu definitions (sample)

The build.gradle file looks something like:

apply plugin: 'axelor-module' (1)

module { (2)
    name "axelor-contact"
    title "Axelor contact"

    // module dependencies
    // module "modules:axelor-foo" (3)
1 The gradle plugin for module project
2 The module project configuration
3 The modules this module depends on
if you want to use groovy in your module, add apply plugin: groovy to the build script

That’s it. You have successfully created your first module.

Let’s check the build.gradle script:

The apply plugin: 'axelor-module' tells gradle to use a gradle plugin for this build script. This plugin defines an extension point module where we define various properties.

  • name - name of the module

  • title - display title for the application

  • removable - whether the module can be installed/removed (default false)

  • module - define a dependency on some another module

Now as we have the module ready, we have to utilize it in the build process. So we have to include the module to the settings.gradle of the application project.

// Include modules
include "modules:axelor-contact"

And the application is using this module, so the build.gradle has to be updated like this:

apply plugin: 'axelor-app'

application {

    name "axelor-demo"
    title "Axelor demo"

    version "1.0.0"

    // module dependencies
    module "modules:axelor-contact" (1)

license {
    ext.product = "axelor-demo"
    ext.owner = "My Company" = ""

tomcat {
    httpPort ="http.port", 8080) as Integer
    stopPort = 9451

Now check whether the project is configured properly, build it again:

$ ./gradlew clean build

The build should complete without any error.

Now it’s time to test the application. Issue the following command on your terminal:

$ cd /path/to/axelor-demo
$ ./gradlew tomcatRun


$ cd /path/to/axelor-demo
$ axelor run

If everything was done properly, you should see some logs being printed on the terminal and finally you may see something like this:

Started Tomcat Server
The Server is running at http://localhost:8080/axelor-demo

Open the link in your browser. Use the default admin/admin as the user name and password to log in. You should be in the application with a menu having three top-level menu items.

In the next few sections, we’ll learn how to create new domain objects, views, actions and menu.