Model for Maven POM (Project Object Model)
—
Supporting classes for Maven Model including file set management, build extensions, prerequisites, and pattern matching functionality.
Represents a build extension that adds functionality to the Maven build process.
public class Extension {
public String getGroupId();
public void setGroupId(String groupId);
public String getArtifactId();
public void setArtifactId(String artifactId);
public String getVersion();
public void setVersion(String version);
// Utility methods
public Extension clone();
public InputLocation getLocation(Object key);
public void setLocation(Object key, InputLocation location);
}Usage Example:
Extension extension = new Extension();
extension.setGroupId("org.apache.maven.wagon");
extension.setArtifactId("wagon-ssh");
extension.setVersion("3.4.3");
build.addExtension(extension);Defines the minimum Maven version required to build the project.
public class Prerequisites {
public String getMaven();
public void setMaven(String maven);
// Utility methods
public Prerequisites clone();
public InputLocation getLocation(Object key);
public void setLocation(Object key, InputLocation location);
}Usage Example:
Prerequisites prereq = new Prerequisites();
prereq.setMaven("3.6.0");
model.setPrerequisites(prereq);Represents a set of files with include and exclude patterns, extending PatternSet functionality with directory specification.
public class FileSet extends PatternSet {
public String getDirectory();
public void setDirectory(String directory);
// Inherited from PatternSet:
public List<String> getIncludes();
public void setIncludes(List<String> includes);
public void addInclude(String include);
public void removeInclude(String include);
public List<String> getExcludes();
public void setExcludes(List<String> excludes);
public void addExclude(String exclude);
public void removeExclude(String exclude);
// Utility methods
public FileSet clone();
public InputLocation getLocation(Object key);
public void setLocation(Object key, InputLocation location);
}Usage Example:
FileSet testResources = new FileSet();
testResources.setDirectory("src/test/resources");
testResources.addInclude("**/*.properties");
testResources.addInclude("**/*.xml");
testResources.addExclude("**/local-*.properties");
// Used in Resource objects
Resource resource = new Resource();
// FileSet properties are inherited by ResourceBase class for defining include and exclude patterns for file matching.
public class PatternSet {
public List<String> getIncludes();
public void setIncludes(List<String> includes);
public void addInclude(String include);
public void removeInclude(String include);
public List<String> getExcludes();
public void setExcludes(List<String> excludes);
public void addExclude(String exclude);
public void removeExclude(String exclude);
// Utility methods
public PatternSet clone();
public InputLocation getLocation(Object key);
public void setLocation(Object key, InputLocation location);
}Usage Example:
PatternSet patterns = new PatternSet();
patterns.addInclude("**/*.java");
patterns.addInclude("**/*.properties");
patterns.addExclude("**/*Test.java");
patterns.addExclude("**/target/**");Provides information about artifact relocation when an artifact has moved to a new location.
public class Relocation {
public String getGroupId();
public void setGroupId(String groupId);
public String getArtifactId();
public void setArtifactId(String artifactId);
public String getVersion();
public void setVersion(String version);
public String getMessage();
public void setMessage(String message);
// Utility methods
public Relocation clone();
public InputLocation getLocation(Object key);
public void setLocation(Object key, InputLocation location);
}Usage Example:
Relocation relocation = new Relocation();
relocation.setGroupId("org.apache.maven");
relocation.setArtifactId("maven-model");
relocation.setVersion("3.9.0");
relocation.setMessage("This artifact has been relocated to org.apache.maven:maven-model");
// Used in DistributionManagement
DistributionManagement distMgmt = new DistributionManagement();
distMgmt.setRelocation(relocation);Interface implemented by model classes to support XML location tracking for error reporting and IDE integration.
public interface InputLocationTracker {
/**
* Gets the location of the specified element in the original XML.
* @param key the element key
* @return the input location or null if not tracked
*/
InputLocation getLocation(Object key);
/**
* Sets the location of the specified element.
* @param key the element key
* @param location the input location
*/
void setLocation(Object key, InputLocation location);
/**
* Gets all tracked locations.
* @return map of all element locations
*/
Map<Object, InputLocation> getLocations();
/**
* Sets all tracked locations.
* @param locations map of element locations
*/
void setLocations(Map<Object, InputLocation> locations);
}// Include all Java source files
patterns.addInclude("**/*.java");
// Include all resource files
patterns.addInclude("**/*.properties");
patterns.addInclude("**/*.xml");
patterns.addInclude("**/*.json");
// Include files in specific directories
patterns.addInclude("src/main/resources/**");
patterns.addInclude("config/**/*.conf");// Exclude test files
patterns.addExclude("**/*Test.java");
patterns.addExclude("**/*Tests.java");
patterns.addExclude("**/Test*.java");
// Exclude build output
patterns.addExclude("**/target/**");
patterns.addExclude("**/build/**");
// Exclude hidden files and directories
patterns.addExclude("**/.*");
patterns.addExclude("**/.*/**");
// Exclude temporary files
patterns.addExclude("**/*.tmp");
patterns.addExclude("**/*.bak");// Test resources with filtering
Resource testResource = new Resource();
testResource.setDirectory("src/test/resources");
testResource.addInclude("**/*.properties");
testResource.addInclude("**/*.yml");
testResource.setFiltering(true);
// Exclude environment-specific files
testResource.addExclude("**/prod-*.properties");
testResource.addExclude("**/local-*.yml");
build.addTestResource(testResource);Install with Tessl CLI
npx tessl i tessl/maven-org-apache-maven--maven-model