Monday, August 30, 2010

Almost there...

This is my last fall semester as a college student.

Wow.

Wednesday, August 4, 2010

Automated Generation of Javadocs for Open Source Android Applications

While Java is not my favorite language, it has its benefits. With one Android application already posted on the market and another application in development, I decided to start using Javadocs a little more seriously. The process of generating Javadocs is not that complicated using Eclipse, but that is not the solution I wanted. My goal was to automate the generation and posting of the docs as the source code changed.


My shared web host was suitable for hosting the html files, but not running javadoc to actually generate new documents. The solution I came up with was to automatically download the latest code from my public repository, generate the javadocs, and then upload the html files to my shared host. The computer I executed this code on was a Linux virtual server that I have sitting around. The process was actually very simple:
  1. Clean up any files from the previous run of the script
  2. Download the latest source code from the svn repository using svn export. It is notable that you can use svn export with Github since they support accessing repositories using the SVN protocol. Awesome!
  3. Generate the javadocs based off of the freshly downloaded code using the desired parameters.
  4. Copy the newly generated javadocs to the desired server. For my purposes, secure copy was the best solution. With my server's public key installed on the shared host, I was able to log into the remote box without prompting for a user name and password.
The final step in the process is to simply run the script nightly with a cron job and the javadocs will always be up to date. Since I was generating documents for Android applications it was important that the Android jar file be located on the server and the javadoc command be made aware of its location. Without this jar file, the generated javadocs would be incomplete. It is necessary that the Java code can actually be compiled on the computer where the javadoc command is run.

Here is the bash script with the file paths changed to protect the innocent:

#!/bin/bash
cd /path/to/files/docs/
rm -rf ampted.svn
rm -rf ampted

svn export http://ampted.googlecode.com/svn/trunk/
mv trunk ampted.svn

JAVADOCHEADER='<a target="_top" href="http://www.amptedapp.com/">Android Mobile Physical Therapy Exercise Documenter</a>'
JAVADOCFOOTER="Generated on `date`"
javadoc -private -header "$JAVADOCHEADER" -footer "$JAVADOCFOOTER" -d /path/to/files/docs/ampted/ -sourcepath /path/to/files/docs/ampted.svn/android/src/ -subpackages com.AMPTedApp -classpath /path/to/files/lib/android.jar

scp -r /path/to/files/docs/ampted remoteuser@example.com:/path/to/remote/files/docs/

This process has one point where it could definitely be improved and that is that it always overwrites the javadocs even if the source code did not change. If a check was added that compared the commit number of the previously generated documentation and only generate and upload a new copy if it is newer. This wasted effort is not a major concern for small projects, but may need to be fixed as my projects grow in size.

You can see the docs for AMPTed, which is a project that is in the very early stages of development, at http://javadocs.amptedapp.com/

Nothing to do, so what will I accomplish?

There are two and a half weeks before my last fall semester starts and I have very little to do. I have a few things on my calendar, but generally it is empty. So, what I am going to do with all of this free time? Simple, write lots and lots of code. Actually, my plan is to work on several projects while I still have the time. It just happens to be that most of these projects involve me writing code.


The main projects that I will be working on include creating DPX Answers for DyKnow Panel Extractor, creating the foundation for AMPTed App, fixing bugs and making small improvements to OpenNoteSecure, and implementing the NAESC Conference registration website. These are high level items on my to-do-list. I plan on making a low level to-do-list that will help me get my ideas organized.

It is a rare for me to have this much free time, so I plan on putting myself to work and making some major progress. I've already managed to code quite a bit, including some major improvements to other projects that are not on the above list. I just need to find a nice quiet place to sit down and start working and not move until I have a plan of action.

Powered By Blogger