Skip to content

Build Files

m0rkeulv edited this page Oct 20, 2026 · 2 revisions

In version 2.0 your build files are the configuration of the project. The plugin reads them to know your targets, defines, libraries and source folders, and runs them to build. This page lists the build files the plugin supports, how it finds them and how you add, hide, activate and reload them.

You manage build files in the Build files group of the Haxe tool window; see The Haxe Tool Window.

Supported build files

Kind File How the plugin recognizes it Built with
hxml *.hxml Every file with the .hxml extension. haxe build.hxml
Lime *.xml or *.lime, usually project.xml The file has a <project> element with at least one <haxelib>, <source> or <classpath> element somewhere below it. haxelib run lime <action> project.xml <target>
OpenFL *.xml or *.lime, usually project.xml Like Lime, and one of the <haxelib> elements is <haxelib name="openfl" />. haxelib run openfl <action> project.xml <target>
NME *.nmml, usually project.nmml A .nmml file with a <project> element. haxelib run nme <action> project.nmml <target>
HXP project (Beta) *.hxp A Haxe script with a class that extends HXProject. It is treated like a Lime project. haxelib run lime <action> project.hxp <target>
HXP script (Beta) *.hxp Any other .hxp file. haxelib run hxp build.hxp

Note

Beta. HXP support works and is supported, but may still change.

A .lime file is recognized like a .xml one and edited as XML. A .nmml file is always treated as an NME project and built with the nme tool, even when it declares openfl: NME maps OpenFL and Lime onto its own API.

A library's include file (include.xml, include.lime or include.hxp) is never a build file: Lime merges it into every build that uses the library and skips it when it looks for a project, and so does the plugin. It is still edited as a Lime project file, with completion, Ctrl+click navigation and the check for missing include files, also when its root element is <extension> instead of <project>, as in most libraries. NME builds any .nmml file, so an include.nmml stays an NME build file.

hxml

An hxml file holds compiler arguments, one per line. The plugin reads the target flag (for example -js or -hl), -D defines, -lib libraries and -cp class paths. Lines that name another hxml file are read too, so arguments in an included file count. See the Haxe manual on hxml files.

-cp src
-main Main
-lib mylib
-D analyzer_optimize
-hl bin/app.hl

The compiler turns every dash in a define name into an underscore, so -D analyzer-optimize works too, but #if only knows the analyzer_optimize spelling. The editor therefore warns about a define name with a dash; see Editing build files.

An hxml file can chain several compilations with --next. The plugin then lets you pick which one it follows; see Targets and Sections.

Lime and OpenFL

A Lime or OpenFL project file describes the app, its sources and its libraries in XML. See the Lime documentation on the project XML format.

<?xml version="1.0" encoding="utf-8"?>
<project>
	<meta title="My App" package="com.example.myapp" version="1.0.0" />
	<app main="Main" path="Export" file="MyApp" />
	<source path="src" />
	<haxelib name="openfl" />
</project>

You pick the target (HTML5, Windows, HashLink, ...) in the tool window; see Targets and Sections.

NME

NME project files use the .nmml extension and a format similar to Lime's. The plugin runs the NME tool through haxelib, so the nme library must be installed.

HXP

An HXP file is Haxe code that the hxp tool runs. The plugin distinguishes two kinds:

  • HXP project: a Lime project written in Haxe instead of XML. Its class extends HXProject, as described in the Lime documentation on the HXP format. It gets Lime's targets and actions.

    import hxp.*;
    import lime.tools.*;
    
    class Project extends HXProject {
    	public function new() {
    		super();
    		sources.push("src");
    		haxelibs.push(new Haxelib("lime"));
    	}
    }
  • HXP script: any other .hxp file. The plugin cannot know what such a script builds, so it has no target, no defines and no libraries in the tree. It has one action, build, which runs the script.

Modules that contain .hxp files get the hxp and lime libraries attached, so the scripts themselves have completion.

Where the plugin looks for build files

The plugin looks at the top level of each module's root folder, and at the top level of the project directory. It does not look into subfolders, so files generated into an output folder (such as OpenFL's Export folder) never show up by accident.

A build file in a subfolder must be added by hand.

Adding a build file by hand

Use one of these:

  • In the Haxe tool window, right-click the Build files group (or a build file) and choose Add Build File…. Select the file in the Select Haxe Build File dialog.
  • In the Project view, right-click the file and choose Add as Haxe Build File. If the project has several modules, pick the module in the Add Build File to Module list.

The file must be one of the supported kinds above. If it is not, Add Build File… shows an error that it is not recognized as a Haxe build file, and the Project view does not offer Add as Haxe Build File for it.

After adding the file, the plugin may ask Configure Folders from Build File: it offers to mark the file's class path folders as source folders and its output folders as excluded. It asks only when some of those class path folders are not source folders yet. Then it reloads the project, so the file's libraries are attached.

Hiding and removing build files

Right-click a build file and choose:

  • Remove Build File for a file you added by hand. It disappears from the tool window.
  • Hide Build File for a file the plugin found by itself. It stays hidden until you add it again with Add Build File….

Both ask for confirmation. The file on disk is never deleted. Pressing Delete does the same for the selected build file, and so does the toolbar's Remove Module button, which turns into Remove Build File or Hide Build File while a build file is selected.

The active build file

Each source file is analyzed under one build file: the build that compiles it, with that build's defines and compiler settings. See Resolve Context. For a file that several build files compile equally, for example two hxml files with the same -cp src, and for the standard library or a library several builds use, the active build file usually decides; a haxelib file goes only to the builds that use its library. Resolve Context lists the exact order. There is at most one active build file in the whole project; it is shown in bold with the (Active) marker.

  • If the project has exactly one build file, it is active automatically.
  • If it has several, choose one: right-click it and choose Set as Active Build File. Until you do, files that several builds compile equally are analyzed under the module's Build command file, or else the first build file in the tool window.

The active build file also decides which target-specific module files are used, and it answers wherever the IDE has no file to go by. See Conditional Compilation and Defines and Custom Targets. Your choice of active build file is saved with the project.

How Lime, OpenFL, NME and HXP files are read

hxml files are plain lists of arguments, so the plugin reads them directly. The other kinds can contain conditions (if and unless attributes, or Haxe code), and their result depends on the selected target. The plugin evaluates them in the background, once per file and target:

Kind How the plugin evaluates it What you need
Lime, OpenFL (.xml) With a small evaluator that ships with the plugin and runs on the IDE's own Java runtime. If it fails, the plugin falls back to haxelib run lime display (or openfl display). haxelib, and the project's libraries installed, for complete results. The fallback needs the lime (or openfl) library.
HXP project (.hxp) The same evaluator runs the script. Haxe, and the lime and hxp libraries installed.
NME (.nmml) haxelib run nme prepare into a temporary folder, so your project folder is not touched. The nme library installed.

The evaluated result includes everything the build really uses for the selected target, for example libraries pulled in by other libraries. For a Lime or OpenFL project, the defines are the -D set the build passes to the compiler: <haxedef> and <define> elements, -D flags in <haxeflag> and the selected target's own defines. <set> values are Lime's own and never reach the compiler, so they are not listed. <haxedef remove>, <include haxelib>, an <include path> naming a folder (its include.lime, include.nmml or include.xml), a local <haxelib path> and optional="true" are honored.

Until the evaluation finishes, or when it fails, the tree shows what the file declares, without evaluating conditions; the selected target's own defines are set all the same. An HXP project shows no defines or libraries until then.

Like Lime, the plugin reads an attribute value up to its closing quote, so a condition with a raw <, such as if="${haxe_ver < 4.0}", works although XML forbids it.

When the project file or a file it includes is not valid XML, or an <include> names a file that does not exist, the evaluation fails the way Lime would: the build file row in the tool window shows (build tool failed) with the message, the open file shows it in a banner and the plugin falls back to lime display. A <haxelib> that is not installed does not stop the evaluation; it stays listed and is marked missing.

Important

Evaluating these files runs code from your project. While the project is not trusted, the plugin skips the evaluation and only shows what the files declare. When you trust the project, the plugin reloads it. See Your First Project.

Source folders from build files

When you open a folder that has no source folders configured yet, the plugin sets them up from the build files at the top level of each module:

  • Class path folders that exist (-cp in hxml, <source> or <classpath> in XML) become source folders.
  • Output folders become excluded folders: the folder that contains an hxml file's output, and the path of the <app> element in Lime, OpenFL and NME files.

Modules that already have source folders are left alone. For a build file you add later, or a build file you mark as a tests build file, the plugin asks first (Configure Folders from Build File).

The plugin ignores paths that point at a network share (\\server\share\...), in build files and in haxelib's output: just looking at one makes the system connect to that computer and, on Windows, send it your credentials. Map the share to a drive letter instead.

Class paths outside the module

A class path outside the module's folder, such as -cp ../shared/src or a <source> folder on another drive, cannot become one of its source folders. The module's code still sees it, as the compiler does: imports from it resolve, packages included, and Find Usages on a declaration in it finds the references in the modules whose builds use it. A folder that belongs to no module is listed under External Libraries in the Project view as Classpath path. The module setup is not changed: no module dependency and no entry in the module's .iml file.

These class paths come from the selected target or section of each build file of the module. The plugin reads them along with the libraries, so they follow the same refreshes; see When the list is refreshed. A class path that contains a module's folder, such as -cp .., is left out.

Libraries from build files

The libraries a build file declares become module libraries under External Libraries, so code in those libraries resolves and completes. A module gets the libraries of all its build files, plus those of its tests build files: each source file is analyzed under its own build, so every build's libraries must be there. As a result, code can resolve against a library that only another build of the module uses; the compiler diagnostics still report it.

Missing libraries are shown in red in the tool window and marked in the build file itself. See Libraries and Haxelib for installing them and for how versions and git pins are handled.

When a build file changes

The plugin watches the build files it found and the ones you added, and the files they import: hxml files an hxml file names (--next sections included), and the project files a Lime, OpenFL or NME file includes with <include path> or <include name> (for a folder, its include.lime, include.nmml or include.xml). Only files inside the project count; <include haxelib> and paths with ${...} are not watched. A file stops being watched after the reload that follows removing its include. When one of these files changes, the IDE reloads the Haxe project, the same way it does for Gradle or Maven projects. What triggers the reload is set by the Sync project after changes in the build scripts option in Settings | Build, Execution, Deployment | Build Tools (see the IntelliJ IDEA documentation):

  • Any changes: the IDE reloads after every change.
  • External changes: the IDE reloads after changes from version control or from outside the IDE. When you edit a build file in the IDE, a Sync Haxe Changes button appears in the editor; click it to reload.

A reload saves your open files, reads the build files again, updates the module libraries and refreshes the tool window. The IDE also runs it on its own when you open a project for the first time, and it resolves the libraries again each time it opens a trusted project, so a reopened project needs no manual reload. You can also reload by hand:

  • Reload Haxe Project on the toolbar of the Haxe tool window reloads everything.
  • Reload in the context menu of a build file reads that one file again and updates the module libraries.

Saving a build file also re-evaluates the #if blocks of the files analyzed under it right away, without waiting for a reload.

Editing build files

hxml files and Lime, OpenFL and NME project files get help in the editor:

  • Inspections in the Haxe | Build files group: a define name with a dash, a library that is not installed (with a quick fix that installs it) and an <include> whose file does not exist. See Diagnostics and Inspections.
  • Navigation in project files: Ctrl+click (⌘+click on macOS) the path of an <include>, <source>, <classpath>, <assets>, <icon> or <template> element to open the file or folder. An <include> that names a folder opens the include file Lime uses inside it. Renaming a referenced file updates the path. Paths with ${...} are not links.
  • Navigation in hxml files: Ctrl+click the class after -main (also -m or --main) to open the class the build starts from. The plugin looks it up the way the compiler does: in the class paths of the same --next section (for a -main before --each, the selected section), the last -cp first, then the hxml's working directory, then the module's libraries. A class with the same name elsewhere in the project is not a target. Renaming the class updates the -main line, and Find Usages on the class lists it. Moving the file to another package does not update the line. An unresolved -main is not marked, and there is no class completion after -main.

Tests build files

A tests build file builds your unit tests. The plugin compiles and runs it when you run tests, and the libraries it declares are added to its module, so test code resolves.

A build file can be a tests build file only if it uses a supported test framework library: utest, munit, buddy or tink_unittest. Such a file is a tests build file:

  • automatically, when it is named test.hxml or tests.hxml, or lies inside a folder named tests within the module;
  • when you right-click it and choose Mark as Tests Build File.

To stop treating a file as a tests build file, right-click it and choose Unmark as Tests Build File. This also works for files that were picked up automatically by their name.

A tests build file shows the (Tests) marker and a Tests group with a Run Unit Tests row. A module can have several tests build files. See Unit Tests for running and debugging tests.

Working directory of an hxml file

Paths in an hxml file are relative to the folder the compiler runs in. By default the plugin runs an hxml file in its own folder. If the file sits in a subfolder but its class paths only make sense from the module's root folder, the plugin runs it from the root folder instead. All other build files run in their own folder.

To choose the folder yourself, right-click the hxml file and choose Set Working Directory…. Leave the field empty to go back to the default, which the dialog shows.

Clone this wiki locally