Application development

Contents

Details on the project and code structure in Enonic apps and libraries

Get started running. Use one of our starters to bootstrap your development project.

Languages

XP apps are powered by the XP runtime.

Enonic apps may consist of both server.-side and client-side code. They are primarily written in JavaScript/TypeScript.

Server-side JavaScript must uses XP’s Javascript Framework

Applications may optionally use Java. Developers with special requirements can take advantage of advanced platform capabilities such as exposing and consuming services from other applications within the same platform instance.

Learn more about using Java in XP apps

Project structure

The example structure below includes the standard files and folders for an Enonic application (or library).

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

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

Build files

Enonic supports JS/TS based build tools like TSUP and Webpack, but relies on Gradle as the main builder.

Visit the build system section for more details.

build.gradle

Main build file

gradle.properties

Build properties

gradlew | /gradlew.bat

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

settings.gradle

Mandatory file to boostrap the build process

General resources

The majority of Enonic specific code is placed within src/main/resources/:

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. Should be in a square format.

application.xml

Application information in XML format.

assets/

Standard folder for serving of static assets, such as css and javascript. Assets are served by the asset service.

error/error.js

The HTTP error handler

main.js

The application’s main controller. Executed when an application starts and stops.

services/

Contains Http service controllers

i18n/

Short for internationalization, this folder contains app localization files

idprovider/

The application may implement an ID Provider here.

tasks/

May contain task controllers for running asynchronous and background processing.

site/site.xml

Contains site configuration schema, and declaring that the app can be added to projects and sites

site/content-types/

Contains Content type definitions.

site/processors/

For post processing of HTML response from pages built with the Enonic JS framework.

site/layouts/

Layout components are placed here.

site/mixins/

Reusable schemas are placed here.

site/macros/

Rich text Macro components are placed here.

site/pages/

Page components are placed here.

site/parts/

Part components are placed here.

site/x-data/

X-data schemas are defined here

webapp/webapp.js

Webapp based on the Enonic JS framework are placed here.

Java

/src/main/java/

Optionally place Java code here.

/src/test/java/

Optionally place Java tests here.

Libraries

Enonic libraries are similar to applications, the main difference being that a library cannot be installed and started by itself.

Check out the library starter if you are planning to build your own library.

A library may consist of the same files and functionality you would find in an application - such as Assets, Content Types and JS controllers.

Enonic libraries are added to your application by declaring a dependency in the build file.

The core functionality of XP is exposed via standard libraries. Check out the Standard Libraries documentation. You will also find additional libraries on Enonic Market


Contents

Contents

AI-powered search

Juke AI