Development and projects

Contents

Development and projects

How are applications put together built and delivered

Project structure

The XP project structure is based on the Maven approach.

Below is is an extensive version of a project structure, listing all standard folders and files that can be used

sample-project/
  build.gradle
  gradle.properties
  gradlew
  gradlew.bat
  settings.gradle
  src/
    test/
      java/
    main/
      java/
      resources/
        admin/
          widgets/
          tools/
        application.svg
        application.xml
        assets/
        error/
        i18n/
        main.js
        services/
        tasks/
        site/
          content-types/
          layouts/
          mixins/
          pages/
          parts/
          processors/
          x-data/
          site.xml
        webapp/
          webapp.js

Every file and folder has a specific function and purpose as described below:

build.gradle

main file used by the Build system.

gradle.properties

Standard settings for XP apps

gradlew / gradlew.bat

The Gradle wrapper file. Downloads and runs Gradle without having to install it manually.

settings.gradle

Mandatory gradle file to boostrap the build process

src/main/java/

Optional folder where you place java code that might be included directly in the project - Maven style.

src/test/java/

Optional folder where you place test code - Maven style.

src/main/resources/

Non-Java files. The majority of XP project code goes here,

admin/tools

Admin tools are defined here. Tools are administrative apps listed in the admin console menu.

admin/widgets

Admin widgets are essentially user interface components that can be embedded within other admin tools.

application.svg

Application icon in SVG format.

application.xml

The XML file contains basic application settings. Currently a description.

assets/

Contains publically available resources such as css, javascript, static images etc.

error/error.js

The application’s error handler

main.js

Main controller is executed every time an app is started.

services/

Contains Http services controllers

i18n/

Short for internationalization, this folder contains app localization files

tasks/

Contains task controller for running asynchronous jobs.

site/site.xml

Contains site configuration schema and declares that the app can be added to sites

site/content-types/

Content type definition files.

site/processors/

For post processing of HTML from pages.

site/layouts/

Layout controllers are placed here.

site/mixins/

Reusable schemas are placed here.

site/pages/

Page controllers are placed here.

site/parts/

Part controllers are placed here.

site/x-data/

eXtra data schemas.

webapp/webapp.js

The Webapp controller file

Libraries

Libraries are structurally similar to applications, with the difference that a library is designed to be installed and run on it’s own. However, a library can be included in an application (or many) to provide functionality to that app.

The process of setting up and building libraries is similar to applications. To build a library we recommend using the library project template.

Once a library has been built, the output will be a .jar file, just like an application. However, libraries will have small differences in application metadata.

To add a library in an application, simply update the applications build.gradlefile

Contents