Child pages
  • Build Language
Skip to end of metadata
Go to start of metadata

Build Language

Introduction

Build language is an MPS counterpart of Apache Ant. 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.

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

Features

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

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.

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.

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.

Using Build Language

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

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 Next

  • No labels