Sunday, November 02, 2008

Be a Productive Developer on Ubuntu

Ubuntu is the most efficient operating system I came across for Java, C/C++ development. I'm going to share some tips, tricks and standards that I'm using to be more productive on Ubuntu.
3P (Third-party) software.
As a developer we need lot of third-party software to host, run link our softwares, as a example Web servers, Application servers, DB servers and frameworks. Normal practice is to install software here and there and it is a nightmare to find the location or the correct version when required. As a solution I use '/opt' folder as my 3P installation root and use '/opt/category/vendor/software/version' as the installation folder. As a example if I want to install Derby I install it in /opt/db/apache/derby folder. There can be several versions of the same software in side the folder so I use two symbolic links 'default' and 'latest'. Latest point to the latest version and default point to the most frequently use version. Most of the time default point to the latest.
Checkout folder
My root folder to checkout source code is ~/worksapce. All development work goes under the workspace.
Test folder
Testing done under the ~/testspace. Most of the test space have only symbolic links to the workspace binaries. As a example I have a symbolic link ~/testspace/synapse-1.2 that links to ~/workspace/apache/synapse-trunk/target/synapse-1.2-bin.
Document Folder
Documentation done under ~/docspace/.
Build Shell Script
Normally a project will have a Maven, Ant or a Make file to build. Addition to that I use a shell script to do my custom needs to make me more efficient. A sample shell script I use for synapse development,
#!/bin/bash
mvn clean assembly:assembly -Drelease -Dmaven.test.skip=true-o
SOURCE_PATH=/home/asankaa/workspace/synapse-1.2 DEST_PATH=/home/asankaa/workspace/synapse-1.2-src/target/synapse-1.2-dir.dir/synapse-1.2 TEMP_LIB=~/temp/lib QUICKFIX_HOME=/opt/quickfixj/latest ACTIVEMQ_HOME=/opt/apache-activemq/latest QPID_HOME=/opt/qpid/latest AXIOM_SNP=/home/asankaa/workspace/axiom-SNAPSHOT echo "Copy custom configuration" rm -rf $DEST_PATH/repository cp -rf $SOURCE_PATH/repository $DEST_PATH echo "Copy activemq lib" cp $ACTIVEMQ_HOME/lib/activemq-core-5.1.0.jar $DEST_PATH/lib cp $ACTIVEMQ_HOME/lib/geronimo-j2ee-management_1.0_spec-1.0.jar $DEST_PATH/lib echo "Copy quickfix lib" #cp $QUICKFIX_HOME/lib/slf4j-api-1.3.0.jar $DEST_PATH/lib #cp $QUICKFIX_HOME/lib/slf4j-jdk14-1.3.0.jar $DEST_PATH/lib cp $QUICKFIX_HOME/lib/mina-core-1.1.0.jar $DEST_PATH/lib cp $QUICKFIX_HOME/quickfixj-core.jar $DEST_PATH/lib cp $QUICKFIX_HOME/quickfixj-msg-*.jar $DEST_PATH/lib echo "Replace axiom-SNAPSHOT" rm $DEST_PATH/lib/axiom-*.jar cp $AXIOM_SNP/lib/axiom-*.jar $DEST_PATH/lib echo "Copy qpid lib" cp $QPID_HOME/lib/geronimo-jms_1.1_spec-1.0.jar $DEST_PATH/lib cp $QPID_HOME/lib/qpid-client-1.0-incubating-M2.jar $DEST_PATH/lib cp $QPID_HOME/lib/qpid-common-1.0-incubating-M2.jar $DEST_PATH/lib #these two added newly if qf dosent work need to remove cp $QPID_HOME/lib/slf4j-api-1.4.0.jar $DEST_PATH/lib cp $QPID_HOME/lib/slf4j-log4j12-1.4.0.jar $DEST_PATH/lib

Startup Scripts
Create startup script for each project that will do a svn update first, open the IDE with the project and create the required environment for the project.
Command Scripts
Create startup scripts for most commonly used software and keep them under ~/share/bin. By adding the ~/share/bin to the global path environment variable can execute the commands from any location.
Other commonly use complex comands can put into the shell scripts and keep inside this folder. As an example I use two scripts to find a PID and kill a process with a specific name, psgrep and pskill.
#!/bin/bash
#psgrep

processname=$1
ps -ef | egrep ${processname} | egrep -v "(grep)|(psgrep)|(pskill)"

#!/bin/bash
#pskill
processname=$1
killoptions=$2
kill ${killoptions} `psgrep ${processname} | awk '{print $2}'`
Panels
Ubuntu comes with standard four panels (desktops) I usually rename them to Home, Dev, Test, Tools. Home to run the email client, IM and other common softwares, Dev to open the IDE and the development tools, Test to open test tools and test bench for the softwares, Tools to run the 3P tools like web servers and databases.
Configuration
Configuration files that reuse stores under ~/etc/ and make symbolic links to the config files when required.
Logs
Default log folder is ~/log so it is easy to find a log and purge the log files.
Notes
Tomboi notes and XPad is the quick and dirty note pad to compile notes and architecture spikes.

0 comments: