Step 1: Create a Project

The Axelor Development Kit uses Gradle to manage application project and it’s modules.

Directory structure

The directory structure of a typical Axelor Development Kit application project is something like this:

axelor-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

Create build.gradle

Create the application build script like this:

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.0.0-SNAPSHOT' (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 = '5.0.0-SNAPSHOT'

    sourceCompatibility = 1.8
    targetCompatibility = 1.8
}

dependencies {
    // add dependencies
}
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

Create settings.gradle

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

settings.gradle
rootProject.name = 'axelor-demo'

// 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 in settings.gradle file.

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

To check whether application project is configured properly, issue the following command:

$ gradle build

The build process should finish without any error.

Generate gradle wrapper

The recommended way to execute gradle build is with the help of Gradle Wrapper. Run the following command from terminal to generate wrapper:

$ gradle wrapper

Now onward, you can use either @gradlew@ shell script or @gradlew.bat@ batch script to execute build. Like:

$ ./gradlew build

Create config files

We also need to create following configuration files:

  1. src/main/resources/application.properties - the application config file

  2. src/main/resources/META-INF/persistence.xml - the jpa configuration file

Please follow the app configuration guide for more details.