h2. Build Language

h3. Introduction
Build language is an MPS counterpart of [Apache Ant|http://ant.apache.org/]. Like in Ant, the each build script in build language is a project. A project can contain property and target declarations, imports of property files and other projects, task calls. A build language task library has all core Ant tasks and most of all optional Ant tasks.


On the above screenshot you can see an example project on build language -- {{HelloWorldProject}}. It has a property declaration -- {{hello.world.text}} property and a target declaration -- {{default}} target, which is default target for this project. The {{default}} target calls {{echo}} task to output the value of the {{hello.world.text}} property to the console. Here is the Ant script, generated from {{HelloWorldProject}}.

<?xml version="1.0" encoding="UTF-8"?>

<project name="HelloWorldProject" default="default">

  <property name="hello.world.text" value="Hello World!" />

  <target name="default">





You can see, that the generated Ant file looks very similar to input project.

h3. Features

Though the build language seems to be very similar to Ant, it has some differences with it. Those differences are described below. 

h4. Typesystem 

When calling a task in Ant, values are set to it's attributes. In build language a typesystem is declared for validating those values. Each attribute has a type. Available types are: {{boolean}}, {{file}}, {{integer}}, {{reference}} and {{string}}. Some attribute's values are restricted with enumerations of some type. For example Ant task {{zip}} has an attribute {{duplicate}} which allow string values {{"add"}}, {{"preserve"}} and {{"fail"}}.

Properties also have types. For example, as you can see on the screenshot of {{HelloWorldProject}}, property  {{hello.world.text}} has type {{string}}.

h4. Expressions

An expression can be assigned to an attribute. Simple expressions are string, integer and boolean literals, files, references to properties, tasks and targets. Two types of composite expressions are available: plus operation, which is a simple concatenation of two expressions and a multi-line expression which is also a concatenation but written in several lines.

{anchor:external properties}
h4. External Properties

External properties are useful when a build environment can pass to the Ant script some values, like build number or vcs revision number. They provide ability to use those values in the script safely.

External property is a special kind of property. They also can be defined in the beginning of build language project or task and be used along with ordinary properties, but they can't be assigned a value. A useful feature of an external property is that they are automatically checked and if they are not set by the environment, the script or task fail.

Let's see a simple script, demonstrating several kinds of external properties.


As you can see, three external properties are defined in the beginning on the project and one in the beginning of the {{default}} task. Property {{some.really.important.property}} is a checked property. This means, that when the Ant build would fail on start if it wont be set by build environment. The other two properties are checked only in tasks where they are used.

Property {{some.internal.property}} is visible in the {{default}} task and checked on it's start.

Here is the Ant script, generated from the project.

<?xml version="1.0" encoding="UTF-8"?>
<project name="myProject" default="default">
  <fail unless="some.really.important.property" message="Property some.really.important.property unspecified." />
  <target name="some.other.target">
    <fail unless="some.not.so.important.property2" message="Property some.not.so.important.property2 unspecified." />
  <target name="default">
    <fail unless="some.internal.property" message="Property some.internal.property unspecified." />
    <fail unless="some.not.so.important.property1" message="Property some.not.so.important.property1 unspecified." />

{h3. Tasks}

Buildlanguage allows user to use standart ant tasks and some optional tasks like junit. Tasks are located in models {{jetbrains.mps.build.generictasks.generated}} and {{jetbrains.mps.build.generictasks.optional}}. To use this tasks one should import language {{jetbrains.mps.build.generictasks}}.

{anchor:using build language}
h3. Using Build Language

This section describes stuff, which makes build language usage more comfortable.

{anchor:run build language}
h4. Running Build Language Project

For executing build language projects MPS has special run configuration {{"Build"}}. It could be created from {{"Run/Debug Configurations"}} dialog:



Also a project could be runned from context menu:


Build output is shown in {{"Run"}} tool window:


[Previous|Build languages (obsolete)]&nbsp;[Next|Packaging Language (obsolete)]