summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-06-20 21:51:40 +0200
committerMichael Bien <[email protected]>2010-06-20 21:51:40 +0200
commitfa50256fae31ad8499ade311a4bfa4dc446a2ada (patch)
treea8eb8522b77558ce376d694e80775be227406d52
parent116a6c13ca44efce27b228d96eb607f0c112763c (diff)
maven jar assambler plugin + configuration loading fix.
-rw-r--r--pom.xml49
-rw-r--r--src/main/java/com/jogamp/hungryharry/FeedAggregator.java15
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 @@
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>com.jogamp</groupId>
- <artifactId>HungryHarry</artifactId>
- <packaging>jar</packaging>
- <version>1.0-SNAPSHOT</version>
- <name>HungryHarry</name>
- <url>http://maven.apache.org</url>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>com.jogamp.hungryharry</groupId>
+ <artifactId>HungryHarry</artifactId>
+ <packaging>jar</packaging>
+ <version>SNAPSHOT</version>
+ <name>HungryHarry</name>
+ <url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
@@ -18,15 +19,37 @@
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ <archive>
+ <manifest>
+ <mainClass>com.jogamp.hungryharry.FeedAggregator</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-my-jar-with-dependencies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
<dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.8.1</version>
- <scope>test</scope>
- </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>net.java.dev.rome</groupId>
<artifactId>rome</artifactId>
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<Config.Feed> 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;
}