or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

ant-builder.mdfile-utilities.mdgroovy-compilation.mdgroovy-documentation.mdgroovy-execution.mdindex.md

index.mddocs/

0

# Groovy Ant Tasks

1

2

Apache Groovy Ant Tasks provides comprehensive integration between Groovy programming language and Apache Ant build automation framework. This library enables execution of Groovy scripts within Ant build files, compilation of Groovy source code, generation of documentation, and programmatic access to Ant functionality from Groovy code.

3

4

## Package Information

5

6

- **Package Name**: groovy-ant

7

- **Package Type**: Maven

8

- **Group ID**: org.codehaus.groovy

9

- **Artifact ID**: groovy-ant

10

- **Language**: Java (with Groovy utilities)

11

- **Installation**: Add to Maven `pom.xml` or Gradle `build.gradle`

12

13

Maven:

14

```xml

15

<dependency>

16

<groupId>org.codehaus.groovy</groupId>

17

<artifactId>groovy-ant</artifactId>

18

<version>2.5.23</version>

19

</dependency>

20

```

21

22

Gradle:

23

```groovy

24

implementation 'org.codehaus.groovy:groovy-ant:2.5.23'

25

```

26

27

## Core Imports

28

29

For Ant build files (XML configuration):

30

```xml

31

<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy">

32

<classpath>

33

<pathelement location="groovy-ant-2.5.23.jar"/>

34

</classpath>

35

</taskdef>

36

<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc"/>

37

<taskdef name="groovydoc" classname="org.codehaus.groovy.ant.Groovydoc"/>

38

```

39

40

For programmatic use in Java/Groovy:

41

```java

42

import org.codehaus.groovy.ant.Groovy;

43

import org.codehaus.groovy.ant.Groovyc;

44

import org.codehaus.groovy.ant.Groovydoc;

45

import groovy.util.AntBuilder;

46

import groovy.util.FileNameFinder;

47

```

48

49

## Basic Usage

50

51

### Execute Groovy Script in Ant

52

```xml

53

<groovy>

54

println "Hello from Groovy in Ant!"

55

project.properties.each { key, value ->

56

println "$key = $value"

57

}

58

</groovy>

59

```

60

61

### Compile Groovy Sources

62

```xml

63

<groovyc srcdir="src/main/groovy" destdir="build/classes"

64

includeantruntime="false" fork="true">

65

<classpath>

66

<fileset dir="lib" includes="*.jar"/>

67

</classpath>

68

</groovyc>

69

```

70

71

### Programmatic Ant Access

72

```groovy

73

import groovy.util.AntBuilder

74

75

def ant = new AntBuilder()

76

ant.copy(todir: 'backup') {

77

fileset(dir: 'src', includes: '**/*.groovy')

78

}

79

```

80

81

## Architecture

82

83

The Groovy Ant integration is built around several key components:

84

85

- **Ant Task Classes**: Custom Ant tasks (`Groovy`, `Groovyc`, `Groovydoc`) that extend Ant's task framework

86

- **Builder Pattern**: `AntBuilder` providing Groovy's builder-style access to all Ant tasks

87

- **Compilation Integration**: Joint Java/Groovy compilation with stub generation

88

- **File Utilities**: Pattern-based file discovery and scanning capabilities

89

- **Configuration Management**: Comprehensive build-time configuration and classpath management

90

91

## Capabilities

92

93

### Groovy Script Execution

94

95

Execute Groovy scripts and code snippets directly within Ant build files with full access to Ant project properties and tasks.

96

97

```java { .api }

98

public class Groovy extends org.apache.tools.ant.taskdefs.Java {

99

public void setSrc(File srcFile);

100

public void addText(String txt);

101

public void setFork(boolean fork);

102

public void setClasspath(Path classpath);

103

public void execute() throws BuildException;

104

}

105

```

106

107

[Groovy Script Execution](./groovy-execution.md)

108

109

### Groovy Compilation

110

111

Comprehensive Groovy and Java source compilation with support for joint compilation, stub generation, and extensive configuration options.

112

113

```java { .api }

114

public class Groovyc extends org.apache.tools.ant.taskdefs.MatchingTask {

115

public void setSrcdir(Path srcDir);

116

public void setDestdir(File destDir);

117

public void setClasspath(Path classpath);

118

public void setFork(boolean fork);

119

public void execute() throws BuildException;

120

}

121

```

122

123

[Groovy Compilation](./groovy-compilation.md)

124

125

### Documentation Generation

126

127

Generate comprehensive API documentation from Groovy and Java source files with customizable templates and output formats.

128

129

```java { .api }

130

public class Groovydoc extends org.apache.tools.ant.Task {

131

public void setSourcepath(Path src);

132

public void setDestdir(File dir);

133

public void setPackagenames(String packages);

134

public void setAccess(String access);

135

public void execute() throws BuildException;

136

}

137

```

138

139

[Documentation Generation](./groovy-documentation.md)

140

141

### Programmatic Ant Access

142

143

Groovy builder-style interface for executing Ant tasks programmatically with full type safety and fluent API.

144

145

```java { .api }

146

public class AntBuilder extends groovy.util.BuilderSupport {

147

public AntBuilder();

148

public AntBuilder(Project project);

149

public Project getProject();

150

public void setSaveStreams(boolean saveStreams);

151

}

152

```

153

154

[Programmatic Ant Access](./ant-builder.md)

155

156

### File Pattern Matching

157

158

Ant-style file pattern matching and discovery utilities for build automation and file processing tasks.

159

160

```java { .api }

161

public class FileNameFinder implements IFileNameFinder {

162

public List<String> getFileNames(String basedir, String pattern);

163

public List<String> getFileNames(String basedir, String pattern, String excludesPattern);

164

public List<String> getFileNames(Map args);

165

}

166

```

167

168

[File Pattern Matching](./file-utilities.md)

169

170

## Types

171

172

```java { .api }

173

// Ant Configuration Types

174

public interface Path {

175

public String[] list();

176

public Path createPath();

177

public void setRefid(Reference ref);

178

}

179

180

public interface FileSet {

181

public void setDir(File dir);

182

public void setIncludes(String includes);

183

public void setExcludes(String excludes);

184

}

185

186

// Build Exception Types

187

public class BuildException extends RuntimeException {

188

public BuildException(String message);

189

public BuildException(String message, Throwable cause);

190

public Location getLocation();

191

}

192

193

// Project Types

194

public class Project {

195

public void setProperty(String name, String value);

196

public String getProperty(String name);

197

public void log(String message);

198

public File getBaseDir();

199

}

200

```