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.

Here is a directory structure of a typical axelor application:

open-platform-demo
└── src
│   └── main
│       ├── java
│       └── resources
│           ├── application.properties (1)
│           └── META-INF
│               └── persistence.xml (2)
├── gradle (3)
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── modules (4)
├── gradlew (5)
├── gradlew.bat (5)
├── settings.gradle (6)
└── build.gradle (7)
1 The application config file
2 The minimal persistence xml file to confirm JPA requirement
3 The directory to keep gradle wrapper files
4 The directory to keep module projects
5 The shell and batch scripts to execute the build with wrapper
6 The gradle settings script
7 The gradle build script

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
buildscript {
  ext.repos = {
    jcenter()
    mavenCentral()
    maven { url 'https://plugins.gradle.org/m2/' }
    maven { url 'https://repository.axelor.com/nexus/public/' } (1)
  }
  repositories repos
  dependencies {
    classpath 'com.axelor:axelor-gradle:5.2.0' (2)
  }
}

allprojects {
  repositories repos
}

apply plugin: 'com.axelor.app' (3)

axelor { (4)
  title = 'Axelor :: DEMO'
}

allprojects {
  apply plugin: 'idea'
  apply plugin: 'eclipse'

  group = 'com.axelor'
  version = '1.0.0'

  sourceCompatibility = 1.8
  targetCompatibility = 1.8
}

dependencies {
  // add dependencies
  compile project(':modules:axelor-contact')
}
1 Use axelor maven repository
2 Use axelor gradle plugin to buildscript classpath
3 Use axelor application plugin
4 The application project config

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

  • title - display title for the application

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.

A module is again a gradle sub project. Usually created inside modules directory. However, you can use any directory structure. See gradle multi-project builds documentation for more details.

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

axelor-contact
├── build.gradle (1)
└── src
    ├── main (2)
    │   ├── 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: 'com.axelor.app-module' (1)

axelor { (2)
  title = "Axelor :: Contact"
}
1 The gradle plugin for module project
2 The module project configuration

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

  • title - display title for the module

  • description - a short description about the module

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