Last updated: 2022-05-12

  1. Learn
  2. Documentation DevOps
  3. Custom Files

Uploading custom files and templates

In the Export Settings tab, you can add your own files to the source code of your projects by uploading a zip archive. The zip may contain the following files:

  • any files and templates to be added to the project output
  • a .bootify file in the top-level directory that specifies the conditions under which files should be added
  • a buildExtensions directory with template files to be included in your pom.xml, build.gradle or build.gradle.kts

During the upload, a basic validation of the .bootify file as well as the templates is performed.

Upload a zip with your custom files

Upload a zip with your custom files

File handling

By default, all files in your zip archive are added to the output. Files in the top folder and below the buildExtensions directory are ignored. Included files can overwrite any regular file that would otherwise be created by the code generation.

The directory and file name in the zip archive defines the output path in your project's source code, except for the parent folder, which is stripped. For example, a file /files/buildSrc/dependencies.gradle in your archive is written to your project as /buildSrc/dependencies.gradle.

If a file has the extension .ftl and a total of two dots (for example, myFile.txt.ftl), the content is evaluated as a Freemarker template and the .ftl extension is truncated when added to a project (myFile.txt). With only one dot (myFile.ftl) the files are written directly to the output without evaluation - in case you need a plain .ftl file.

The current project with its custom options is available, so a simple template could look like the following. More details about Freemarker in the official docs. The basic project structure with its available fields can be reviewed here.

An example Freemarker template with basic commands

.bootify schema

If present in the archive, the .bootify file must be valid YAML with the following structure:

Each rule must contain a pattern and a condition. The pattern defines on which files the rule should be applied. The rules are checked from the bottom up to the top against the files in your zip file, so the more specific rules should be at the bottom of the list.

The pattern is based on the glob syntax of the FileSystem class. For an explanation and more examples, see this link. The pattern must also take into account the top directory of your zip file (which is stripped when added to the project). This allows you to manage different directories based on different conditions.

When the first matching rule is found for a file, the condition is evaluated to decide whether to add the file to the project's source code. Conditions are written in Spring Expression Language (more details) with the project and its custom options available as parameters.

If you want to change the default behavior of adding all files to the output, you can add a general rule at the top of the list as in the given example above.

Build Extensions

In the buildExtensions directory of the zip archive, you can provide additional files that will be evaluated as a Freemarker template and inserted into your build file at a specific location. Use the following links to find out the exact file names and locations for each build type:

So for example a file buildExtensions/gradleSingleRepositories.ftl allows you to add custom repositories to a Gradle project. Names and locations for multi-module builds are available on request.