Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.kuali.maven.plugins.externals;
 
 import java.io.File;
 import java.util.List;
 
Recursively examine the file system for Maven poms starting at basedir. Any pom.xml files located have formatting applied to them.

Goal:
formatpoms
Aggregator:
public class FormatPomsMojo extends AbstractMojo {
	MojoHelper helper = MojoHelper.getInstance();
The filename to include when examining the file system for Maven pom's

Parameter:
expression="${externals.pom}" default-value="pom.xml"
	private String pom;

Directories to ignore when examining the file system

Parameter:
expression="${externals.ignoreDirectories}" default-value="src,target,.svn,.git"
Directories to ignore when examining the file system

Parameter:
expression="${externals.basedir}" default-value="${project.basedir}"
	private File basedir;

The Maven project object

Parameter:
expression="${project}"
Readonly:
	public void execute() throws MojoExecutionException {
		int count = 0;
		for (File pom : poms) {
			String xml = .read(pom);
			String formattedXML = .format(xml);
			if (!xml.equals(formattedXML)) {
				count++;
				.write(pomformattedXML);
				getLog().info("Formatting applied to " + pom.getAbsolutePath());
			}
		}
		getLog().info("Formatted " + count + " poms");
	}
	public String getPom() {
		return ;
	}
	public void setPom(String pom) {
		this. = pom;
	}
	}
	public void setIgnoreDirectories(String ignoreDirectories) {
		this. = ignoreDirectories;
	}
	public MavenProject getProject() {
		return ;
	}
	public File getBasedir() {
		return ;
	}
	public void setBasedir(File basedir) {
		this. = basedir;
	}
New to GrepCode? Check out our FAQ X