Overview

In this chapter, we’ll see about the application & module structures.

Application

An application is nothing but a configuration of a set of modules. The modules are built-time packages handled with Gradle build system.

The axelor shell utility included with the Axelor Open Platform provides commands for scaffolding application project and it’s modules.

Application

The axelor --new <NAME> command can be used to create the application project.

$ axelor --new axelor-demo

new application will be created in /path/to/workspace/axelor-demo

OK, application created.

Enjoy!

Here is a directory structure of a the demo application:

axelor-demo
├── build.gradle (1)
├── gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradlew (2)
├── gradlew.bat
├── settings.gradle (3)
└── src
    ├── license
    │   └── header.txt (4)
    └── main
        └── resources
            ├── application.properties (5)
            ├── log4j.properties
            └── META-INF
                └── persistence.xml
1 The gradle build script
2 The gradle wrapper script for Linux & Mac (.bat is for windows)
3 The gradle settings script
4 The license header for the source code
5 The application config file

The modules directory contains application specific feature modules. First, let’s see about some important files here before checking module structure.

The build.gradle file is a build script used by gradle to build the application.

build.gradle
apply plugin: 'axelor-app' (1)

application { (2)

    name "axelor-demo"
    title "Axelor demo"

    version "1.0.0"

    // module dependencies
    module "modules:axelor-contact" (3)
}

license { (4)
    ext.product = "axelor-demo"
    ext.owner = "My Company"
    ext.website = "http://my-company.com"
}

tomcat { (5)
    httpPort = project.properties.get("http.port", 8080) as Integer
    stopPort = 9451
}
1 The gradle plugin for the application project
2 The application project configuration
3 The feature modules this application depends on
4 The license header configuration, see the license/header.txt template.
5 The embedded tomcat server settings

The apply plugin: 'axelor-app' tells gradle to use the given plugin for this build script. This plugin defines an extension point application where we can define various properties.

  • name - name of the application

  • title - display title for the application

  • version - application version

The license settings are used to configure the license header to be placed on source files. The tomcat settings are used to configure the embedded tomcat server.

Another important build script is the settings.gradle which aggregates all the feature module projects to be used in current build process:

settings.gradle
// Include modules
include "modules:axelor-contact"

The include "modules:axelor-contact" line tells gradle to include the module axelor-contact in current build cycle. It is required to list all the modules used by the application in settings.gradle file.

Module

The application project generally doesn’t provide any implementation logic. The functionalities should be provided by creating modules.

The axelor new-module --name <NAME> command can be used to generate a module project.

$ axelor new-module --name axelor-contact

new module will be created in /path/to/workspace/axelor-demo/modules/axelor-contact

OK, module created.

Enojoy!

Now let’s see what a feature module directory structure looks like:

axelor-contact
├── build.gradle (1)
└── src
    ├── main (2)
    │   ├── groovy
    │   ├── java
    │   └── resources
    │       ├── domains (3)
    │       ├── views (4)
    │       └── i18n (5)
    └── test (6)
        ├── java
        └── resources
1 The gradle build script
2 The main sources
3 The XML resources for domain object definitions
4 The XML resources for object view definitions
5 The CSV files with translations
6 The unit test sources

You can see the module structure follows standard maven/gradle directory structure.

Let’s see the build.gradle script for the module.

modules/axelor-contact/build.gradle
apply plugin: 'axelor-module' (1)

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

    // module dependencies
    // module "modules:axelor-foo" (3)
    // module "modules:axelor-bar"
}
1 The gradle plugin for module project
2 The module project configuration
3 The modules this module depends on

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

  • name - name of the module

  • title - display title for the module

  • removable - whether the module is removable (optional, default is false)

A module may have dependencies to another modules which can be specified by the `module "modules:<module-name>" calls.