From fa50256fae31ad8499ade311a4bfa4dc446a2ada Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Sun, 20 Jun 2010 21:51:40 +0200 Subject: maven jar assambler plugin + configuration loading fix. --- pom.xml | 49 ++++++++++++++++------ .../com/jogamp/hungryharry/FeedAggregator.java | 15 ++++++- 2 files changed, 49 insertions(+), 15 deletions(-) diff --git a/pom.xml b/pom.xml index 9e0018b..34ff8d6 100644 --- a/pom.xml +++ b/pom.xml @@ -1,12 +1,13 @@ + - 4.0.0 - com.jogamp - HungryHarry - jar - 1.0-SNAPSHOT - HungryHarry - http://maven.apache.org + 4.0.0 + com.jogamp.hungryharry + HungryHarry + jar + SNAPSHOT + HungryHarry + http://maven.apache.org @@ -18,15 +19,37 @@ true + + maven-assembly-plugin + + + jar-with-dependencies + + + + com.jogamp.hungryharry.FeedAggregator + + + + + + make-my-jar-with-dependencies + package + + single + + + + - - junit - junit - 4.8.1 - test - + + junit + junit + 4.8.1 + test + net.java.dev.rome rome diff --git a/src/main/java/com/jogamp/hungryharry/FeedAggregator.java b/src/main/java/com/jogamp/hungryharry/FeedAggregator.java index 7d2ea1d..2f5ec27 100644 --- a/src/main/java/com/jogamp/hungryharry/FeedAggregator.java +++ b/src/main/java/com/jogamp/hungryharry/FeedAggregator.java @@ -9,7 +9,9 @@ import com.sun.syndication.io.SyndFeedOutput; import com.sun.syndication.feed.synd.SyndEntry; import com.sun.syndication.fetcher.FetcherException; import com.sun.syndication.io.FeedException; +import java.io.FileNotFoundException; import java.io.IOException; +import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; @@ -26,6 +28,7 @@ import freemarker.template.DefaultObjectWrapper; import freemarker.template.Template; import freemarker.template.TemplateException; import java.io.File; +import java.io.FileInputStream; import java.io.FileWriter; import java.io.Writer; import java.util.Comparator; @@ -64,6 +67,8 @@ public class FeedAggregator { config = readConfiguration(); } catch (JAXBException ex) { throw new RuntimeException("can not read configuration", ex); + } catch (FileNotFoundException ex) { + throw new RuntimeException("can not read configuration", ex); } List feeds = config.feed; @@ -176,9 +181,15 @@ public class FeedAggregator { return entries; } - private Config readConfiguration() throws JAXBException { + private Config readConfiguration() throws JAXBException, FileNotFoundException { Unmarshaller unmarshaller = JAXBContext.newInstance(Config.class).createUnmarshaller(); - Object obj = unmarshaller.unmarshal(getClass().getResourceAsStream(configFile)); + LOG.info("reading config file: " + configFile); + InputStream is = getClass().getResourceAsStream(configFile); + if(is == null) { + is = new FileInputStream(configFile); + } + + Object obj = unmarshaller.unmarshal(is); return (Config) obj; } -- cgit v1.2.3