Morphex's blogologue (Life, technology, music, politics, business, mental health and more)

This is the blog of Morten W. Petersen, aka. morphex in various places. I blog about my life, and what I find interesting and/or important. This is a personal blog without any editor or a lot of oversight so treat it as such. :)

My email is morphex@gmail.com.

I am leavingnorway.info.

An OGG/Vorbis player, implemented in Javascript.

My Kiva bragging page
My shared (open source) code on GitHub

Morphex's Blogodex

News
Me on Instagram
Slashdot

Zope hosting by Nidelven IT

Morten Petersen on Linkedin

Morten Petersen on Facebook

Morten Petersen on SoundCloud

Morten Petersen on MixCloud

Blogologue on Twitter



Older entries



Atom - Subscribe - Categories

Facebook icon Share on Facebook Google+ icon Share on Google+ Twitter icon Share on Twitter LinkedIn icon Share on LinkedIn

Automating builds using Maven, writing XHTML & refactoring in Java

In my efforts to write a tool for exporting Tweets from Twitter for safe-keeping in Java, I came a bit closer to the goal to create such an archive today, when I managed to automate the build of the app a bit, and make the app create something that resembles the desired end-result.

Earlier I had to download jar files from projects that my project depended on, but with the following commit:

https://github.com/morphex/twitter-exporter/commit/ed8303638...

One jar is built, and it is run using the command

java -cp ./twitter-exporter-1.0-SNAPSHOT-jar-with-dependencies.jar org.morphex.app.App

I would like run the app in an even simpler way, but it is a big improvement from downloading jar files manually and including them on the "java -cp" command.

I was initially thinking I'd keep things as simple as possible and avoid unnecessary dependencies and systems, but seeing that there are collections of Java classes with useful features, features you'd expect to be in the Java core, it is great to be able to include these using some lines in the pom.xml Maven file.

Secondly I refactored the code a bit, so that the main App class was able to write an XHTML file containing a number of tweets:

https://github.com/morphex/twitter-exporter/commit/093545931...

You can download the generated output here:

http://blogologue.com/test.html.bin

I had to call the file test.html.bin to fool the application server into treating it as a binary file, as UTF16-LE is the encoding of the file and I guess the application server uses UTF-8. Renaming it to test.html and opening it in Firefox should work.

StringEscapeUtils.escapeXml10 is a nice tool, and something you'd assume would be so necessary and standard that it would be included with Java by default. Seeing this is the way it is, I guess there is really no way around using a tool like Maven to build projects.


[Permalink] [By morphex] [A Java-based tool to export tweets from Twitter for safe keeping (Atom feed)] [05 Apr 19:36 Europe/Oslo]