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 tobuild-packages
orbuild-snaps
, or by having it installed or built in a different part. In this case, the name of the part supplyingant
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
tobuild-packages
anddefault-jre-headless
tostage-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 actualjava
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 theant
command line.ant-build-file
(str) The name of the main ant build file. Defaults tobuild.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).
- Parameters:
properties (
PluginProperties
)part_info (
PartInfo
)
- get_build_commands()[source]¶
Return a list of commands to run during the build step.
- Return type:
list
[str
]
- get_build_environment()[source]¶
Return a dictionary with the environment to use in the build step.
- Return type:
dict
[str
,str
]
- get_build_packages()[source]¶
Return a set of required packages to install in the build environment.
- Return type:
set
[str
]
- get_build_snaps()[source]¶
Return a set of required snaps to install in the build environment.
- Return type:
set
[str
]
- properties_class¶
alias of
AntPluginProperties
- validator_class¶
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.
- Parameters:
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.
- Parameters:
part_dependencies (
Optional
[list
[str
]]) – A list of the parts this part depends on.- Raises:
PluginEnvironmentValidationError – If
ant
is invalid and there are no parts named ant.- Return type:
None
- class craft_parts.plugins.ant_plugin.AntPluginProperties(**data)[source]¶
Bases:
PluginProperties
The part properties used by the Ant plugin.
- Parameters:
data (
Any
)
-
ant_build_file:
str
|None
¶
-
ant_build_targets:
list
[str
]¶
-
ant_properties:
dict
[str
,str
]¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function PluginProperties.<lambda>>, 'extra': 'forbid', 'frozen': True, 'validate_assignment': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
plugin:
Literal
['ant'
]¶
-
source:
str
¶