summaryrefslogtreecommitdiff
path: root/src/main/java/org/apache/maven/plugin/nar/NarProperties.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/apache/maven/plugin/nar/NarProperties.java')
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarProperties.java77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarProperties.java b/src/main/java/org/apache/maven/plugin/nar/NarProperties.java
new file mode 100644
index 0000000..2e4b7ba
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugin/nar/NarProperties.java
@@ -0,0 +1,77 @@
+package org.apache.maven.plugin.nar;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.PropertyUtils;
+
+public class NarProperties {
+
+ private final static String AOL_PROPERTIES = "aol.properties";
+ private Properties properties;
+ private static NarProperties instance;
+
+ private NarProperties(MavenProject project) throws MojoFailureException {
+
+ Properties defaults = PropertyUtils.loadProperties( NarUtil.class.getResourceAsStream( AOL_PROPERTIES ) );
+ if ( defaults == null )
+ {
+ throw new MojoFailureException( "NAR: Could not load default properties file: '"+AOL_PROPERTIES+"'." );
+ }
+
+ properties = new Properties(defaults);
+ FileInputStream fis = null;
+ try
+ {
+ if (project != null) {
+ fis = new FileInputStream(project.getBasedir()+File.separator+AOL_PROPERTIES);
+ properties.load( fis );
+ }
+ }
+ catch (FileNotFoundException e)
+ {
+ // ignore (FIXME)
+ }
+ catch (IOException e)
+ {
+ // ignore (FIXME)
+ }
+ finally
+ {
+ try
+ {
+ if ( fis != null )
+ {
+ fis.close();
+ }
+ }
+ catch ( IOException e )
+ {
+ // ignore
+ }
+ }
+
+ }
+
+ /**
+ * Retrieve the NarProperties
+ * @param project may be null
+ * @return
+ * @throws MojoFailureException
+ */
+ public static NarProperties getInstance(MavenProject project) throws MojoFailureException {
+ if (instance == null) {
+ instance = new NarProperties(project);
+ }
+ return instance;
+ }
+
+ public String getProperty(String key) {
+ return properties.getProperty(key);
+ }
+}