1 package org.codehaus.mojo.properties; 2 3 4 import org.apache.maven.plugin.AbstractMojo; 5 import org.apache.maven.plugin.MojoExecutionException; 6 import org.apache.maven.project.MavenProject; 7 8 import java.io.File; 9 import java.io.FileInputStream; 10 11 /** 12 * Reads property files as Project properties 13 * 14 * @author <a href="mailto:zarars@gmail.com">Zarar Siddiqi</a> 15 * @version $Id$ 16 * @goal read-project-properties 17 */ 18 public class ReadPropertiesMojo 19 extends AbstractMojo 20 { 21 22 /** 23 * @parameter default-value="${project}" 24 * @required 25 * @readonly 26 */ 27 private MavenProject project; 28 29 /** 30 * @parameter 31 * @required 32 */ 33 private File[] files; 34 35 public void execute() 36 throws MojoExecutionException { 37 for (int i = 0; i < files.length; i++) { 38 File file = files[i]; 39 try { 40 FileInputStream stream = new FileInputStream(file); 41 if (getLog().isDebugEnabled()) { 42 getLog().debug("Loading property file: " + file); 43 } 44 project.getProperties().load(stream);; 45 stream.close(); 46 } catch (Exception e) { 47 throw new MojoExecutionException("Error: ", e); 48 } 49 } 50 } 51 } 52