1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.codehaus.mojo.properties;
17
18 import java.io.File;
19 import java.io.IOException;
20 import java.io.OutputStream;
21 import java.util.Properties;
22
23 import org.apache.commons.io.FileUtils;
24 import org.apache.commons.io.IOUtils;
25 import org.apache.maven.plugin.AbstractMojo;
26 import org.apache.maven.plugin.MojoExecutionException;
27 import org.apache.maven.project.MavenProject;
28
29
30
31
32
33 public abstract class AbstractWritePropertiesMojo extends AbstractMojo {
34
35
36
37
38
39
40 protected MavenProject project;
41
42
43
44
45
46
47
48
49 protected File outputFile;
50
51 protected void writeProperties(Properties properties, File file) throws MojoExecutionException {
52 OutputStream out = null;
53 try {
54 out = FileUtils.openOutputStream(outputFile);
55 properties.store(out, "Properties");
56 } catch (IOException e) {
57 throw new MojoExecutionException("Error creating properties file", e);
58 } finally {
59 IOUtils.closeQuietly(out);
60 }
61 }
62 }