Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2011-2013 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.opensource.org/licenses/ecl2.php Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 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();
 	POMUtils pomUtils = new POMUtils();

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,overlays,.svn,.git"
 
The base directory that is recursively scanned for Maven pom's

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

The Maven project object

Parameter:
expression="${project}"
Readonly:
 
 	private MavenProject project;
 
 	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