or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

build-config.mdcore-model.mddependencies.mdindex.mdmodel-merging.mdprofiles.mdproject-metadata.mdrepositories.mdutility-classes.mdxml-io.md

utility-classes.mddocs/

0

# Utility Classes

1

2

Supporting classes for Maven Model including file set management, build extensions, prerequisites, and pattern matching functionality.

3

4

## Capabilities

5

6

### Extension

7

8

Represents a build extension that adds functionality to the Maven build process.

9

10

```java { .api }

11

public class Extension {

12

public String getGroupId();

13

public void setGroupId(String groupId);

14

public String getArtifactId();

15

public void setArtifactId(String artifactId);

16

public String getVersion();

17

public void setVersion(String version);

18

19

// Utility methods

20

public Extension clone();

21

public InputLocation getLocation(Object key);

22

public void setLocation(Object key, InputLocation location);

23

}

24

```

25

26

**Usage Example:**

27

28

```java

29

Extension extension = new Extension();

30

extension.setGroupId("org.apache.maven.wagon");

31

extension.setArtifactId("wagon-ssh");

32

extension.setVersion("3.4.3");

33

34

build.addExtension(extension);

35

```

36

37

### Prerequisites

38

39

Defines the minimum Maven version required to build the project.

40

41

```java { .api }

42

public class Prerequisites {

43

public String getMaven();

44

public void setMaven(String maven);

45

46

// Utility methods

47

public Prerequisites clone();

48

public InputLocation getLocation(Object key);

49

public void setLocation(Object key, InputLocation location);

50

}

51

```

52

53

**Usage Example:**

54

55

```java

56

Prerequisites prereq = new Prerequisites();

57

prereq.setMaven("3.6.0");

58

59

model.setPrerequisites(prereq);

60

```

61

62

### FileSet

63

64

Represents a set of files with include and exclude patterns, extending PatternSet functionality with directory specification.

65

66

```java { .api }

67

public class FileSet extends PatternSet {

68

public String getDirectory();

69

public void setDirectory(String directory);

70

71

// Inherited from PatternSet:

72

public List<String> getIncludes();

73

public void setIncludes(List<String> includes);

74

public void addInclude(String include);

75

public void removeInclude(String include);

76

public List<String> getExcludes();

77

public void setExcludes(List<String> excludes);

78

public void addExclude(String exclude);

79

public void removeExclude(String exclude);

80

81

// Utility methods

82

public FileSet clone();

83

public InputLocation getLocation(Object key);

84

public void setLocation(Object key, InputLocation location);

85

}

86

```

87

88

**Usage Example:**

89

90

```java

91

FileSet testResources = new FileSet();

92

testResources.setDirectory("src/test/resources");

93

testResources.addInclude("**/*.properties");

94

testResources.addInclude("**/*.xml");

95

testResources.addExclude("**/local-*.properties");

96

97

// Used in Resource objects

98

Resource resource = new Resource();

99

// FileSet properties are inherited by Resource

100

```

101

102

### PatternSet

103

104

Base class for defining include and exclude patterns for file matching.

105

106

```java { .api }

107

public class PatternSet {

108

public List<String> getIncludes();

109

public void setIncludes(List<String> includes);

110

public void addInclude(String include);

111

public void removeInclude(String include);

112

public List<String> getExcludes();

113

public void setExcludes(List<String> excludes);

114

public void addExclude(String exclude);

115

public void removeExclude(String exclude);

116

117

// Utility methods

118

public PatternSet clone();

119

public InputLocation getLocation(Object key);

120

public void setLocation(Object key, InputLocation location);

121

}

122

```

123

124

**Usage Example:**

125

126

```java

127

PatternSet patterns = new PatternSet();

128

patterns.addInclude("**/*.java");

129

patterns.addInclude("**/*.properties");

130

patterns.addExclude("**/*Test.java");

131

patterns.addExclude("**/target/**");

132

```

133

134

### Relocation

135

136

Provides information about artifact relocation when an artifact has moved to a new location.

137

138

```java { .api }

139

public class Relocation {

140

public String getGroupId();

141

public void setGroupId(String groupId);

142

public String getArtifactId();

143

public void setArtifactId(String artifactId);

144

public String getVersion();

145

public void setVersion(String version);

146

public String getMessage();

147

public void setMessage(String message);

148

149

// Utility methods

150

public Relocation clone();

151

public InputLocation getLocation(Object key);

152

public void setLocation(Object key, InputLocation location);

153

}

154

```

155

156

**Usage Example:**

157

158

```java

159

Relocation relocation = new Relocation();

160

relocation.setGroupId("org.apache.maven");

161

relocation.setArtifactId("maven-model");

162

relocation.setVersion("3.9.0");

163

relocation.setMessage("This artifact has been relocated to org.apache.maven:maven-model");

164

165

// Used in DistributionManagement

166

DistributionManagement distMgmt = new DistributionManagement();

167

distMgmt.setRelocation(relocation);

168

```

169

170

### InputLocationTracker

171

172

Interface implemented by model classes to support XML location tracking for error reporting and IDE integration.

173

174

```java { .api }

175

public interface InputLocationTracker {

176

/**

177

* Gets the location of the specified element in the original XML.

178

* @param key the element key

179

* @return the input location or null if not tracked

180

*/

181

InputLocation getLocation(Object key);

182

183

/**

184

* Sets the location of the specified element.

185

* @param key the element key

186

* @param location the input location

187

*/

188

void setLocation(Object key, InputLocation location);

189

190

/**

191

* Gets all tracked locations.

192

* @return map of all element locations

193

*/

194

Map<Object, InputLocation> getLocations();

195

196

/**

197

* Sets all tracked locations.

198

* @param locations map of element locations

199

*/

200

void setLocations(Map<Object, InputLocation> locations);

201

}

202

```

203

204

## Pattern Matching Examples

205

206

### Common Include Patterns

207

208

```java

209

// Include all Java source files

210

patterns.addInclude("**/*.java");

211

212

// Include all resource files

213

patterns.addInclude("**/*.properties");

214

patterns.addInclude("**/*.xml");

215

patterns.addInclude("**/*.json");

216

217

// Include files in specific directories

218

patterns.addInclude("src/main/resources/**");

219

patterns.addInclude("config/**/*.conf");

220

```

221

222

### Common Exclude Patterns

223

224

```java

225

// Exclude test files

226

patterns.addExclude("**/*Test.java");

227

patterns.addExclude("**/*Tests.java");

228

patterns.addExclude("**/Test*.java");

229

230

// Exclude build output

231

patterns.addExclude("**/target/**");

232

patterns.addExclude("**/build/**");

233

234

// Exclude hidden files and directories

235

patterns.addExclude("**/.*");

236

patterns.addExclude("**/.*/**");

237

238

// Exclude temporary files

239

patterns.addExclude("**/*.tmp");

240

patterns.addExclude("**/*.bak");

241

```

242

243

### Resource Management with FileSet

244

245

```java

246

// Test resources with filtering

247

Resource testResource = new Resource();

248

testResource.setDirectory("src/test/resources");

249

testResource.addInclude("**/*.properties");

250

testResource.addInclude("**/*.yml");

251

testResource.setFiltering(true);

252

253

// Exclude environment-specific files

254

testResource.addExclude("**/prod-*.properties");

255

testResource.addExclude("**/local-*.yml");

256

257

build.addTestResource(testResource);

258

```