craft_parts.plugins.ant_plugin module

The Ant plugin.

class craft_parts.plugins.ant_plugin.AntPlugin(*, properties, part_info)[source]

Bases: JavaPlugin

A plugin for Apache Ant projects.

The plugin requires the ant tool installed on the system. This can be achieved by adding the appropriate declarations to build-packages or build-snaps, or by having it installed or built in a different part. In this case, the name of the part supplying ant must be “ant-deps”.

Additionally, Java projects need a dev kit (jdk) to build and a runtime environment (jre) to run. There are multiple choices here, but frequently adding default-jdk-headless to build-packages and default-jre-headless to stage-packages is enough.

Once built, the plugin will create the following structure in the part’s install dir (which will later be staged/primed/packaged):

  • A bin/java symlink pointing to the actual java binary provided by the jre;

  • A jar/ directory containing the .jar files generated by the build.

The ant plugin uses the common plugin keywords, plus the following ant- specific keywords:

  • ant-build-targets (list of strings) The ant targets to build. These are directly passed to the ant command line.

  • ant-build-file (str) The name of the main ant build file. Defaults to build.xml.

  • ant-properties (dict of strings to strings) A series of key: value pairs that are passed to ant as properties (using the -D{key}={value} notation).


Return a list of commands to run during the build step.

Return type:



Return a dictionary with the environment to use in the build step.

Return type:

Dict[str, str]


Return a set of required packages to install in the build environment.

Return type:



Return a set of required snaps to install in the build environment.

Return type:



alias of AntPluginProperties


alias of AntPluginEnvironmentValidator

class craft_parts.plugins.ant_plugin.AntPluginEnvironmentValidator(*, part_name, env, properties)[source]

Bases: PluginEnvironmentValidator

Check the execution environment for the Ant plugin.

  • part_name (str) – The part whose build environment is being validated.

  • env (str) – A string containing the build step environment setup.

  • properties (PluginProperties) –

validate_environment(*, part_dependencies=None)[source]

Ensure the environment contains dependencies needed by the plugin.


part_dependencies (Optional[List[str]]) – A list of the parts this part depends on.


PluginEnvironmentValidationError – If ant is invalid

and there are no parts named ant.

Return type:


class craft_parts.plugins.ant_plugin.AntPluginProperties(**data)[source]

Bases: PluginProperties, PluginModel

The part properties used by the Ant plugin.


data (Any) –

ant_build_file: Optional[str]
ant_build_targets: List[str]
ant_properties: Dict[str, str]
source: str
classmethod unmarshal(data)[source]

Populate make properties from the part specification.


data (Dict[str, Any]) – A dictionary containing part properties.

Return type:



The populated plugin properties data object.


pydantic.ValidationError – If validation fails.