diff options
author | Mark Donszelmann <duns@macserver.donszelmann.org> | 2010-10-26 00:39:07 +0200 |
---|---|---|
committer | Mark Donszelmann <duns@macserver.donszelmann.org> | 2010-10-26 00:39:07 +0200 |
commit | 9af270beb1414531363aa1fcb6cba7565ca0075a (patch) | |
tree | 3f7beb686b56789c1a535f185d33b74a49b074e7 /src/main/java/org/apache/maven/plugin/nar/NarProperties.java | |
parent | 7482bfe33dc8db7ccc1b02d80f6c3b6dbac601ca (diff) | |
download | maven-nar-plugin-9af270beb1414531363aa1fcb6cba7565ca0075a.tar.gz maven-nar-plugin-9af270beb1414531363aa1fcb6cba7565ca0075a.tar.bz2 maven-nar-plugin-9af270beb1414531363aa1fcb6cba7565ca0075a.tar.xz maven-nar-plugin-9af270beb1414531363aa1fcb6cba7565ca0075a.zip |
Fixed NAR-165
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.java | 77 |
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); + } +} |