Development environment setup

From UFP-UV Sakai Wiki

Jump to: navigation, search

Contents


Local developer machine

This is for PCs used by developers for programming.

Eclipse

  1. Download latest stable [1] for J2EE Developers release.
  2. Download eclipse plugins using the Update Manager:
  3. Import Formatter code styles into Preferences:

SVN

  • Install TortoiseSVN from SVN homepage for adding explorer context-menu SVN capabilities

Firefox

  1. Install lattest FireFox release
  2. Install the following extensions, usefull for debugging:
    • Tamper Data: View and modify HTTP/HTTPS headers
    • Web Developer: Adds a menu and a toolbar with various web tools
    • TortoiseSVN Menu: Add TortoiseSVN commands to link context menus
    • Html Validator: Adds HTML validation to the View Page Source of the browser
    • FireBug: Web Debugging Evolved
    • Selenium IDE: Record, edit and play Selenium tests

WinMerge

  1. Install WinMerge
    • Go to Tools\Filters to create a new filter
    • Copy/paste the following filter and save it - use it in future merges:
## This is a directory/file filter for WinMerge
name: Sakai (UFP) Source Filter
desc: Suppresses OSP and Providers, '.svn' folders, '.class' files, '.bin' folders, 'target' folders
 
## This is an inclusive (loose) filter
## (it lets through everything not specified)
def: include
 
## Filters for filenames begin with f:
f: \.class$ ## Java class files
 
## Filters for directories begin with d:
d: \\osp$ ## OSP tools
d: \\providers$ ## Providers
 
d: \\bin$ ## Java compiled (eclipse dir)
d: \\bin\*$ ## Java compiled (eclipse dir)
d: \\target$ ## Java compiled maven dir)
d: \\target\*$ ## Java compiled (maven dir)
d: \\.svn$ ## SVN control directory
d: \\.svn\*$ ## SVN control directory 

Local deployment machine

This is for setting up a deployment machine for debug purposes.

Create a local SVN repository

#!/bin/sh
#
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
#
function start_svn
{
echo "Starting SVN daemon..."
svnserve -d
if [ "$?" = 0 ]
then
echo "Done"
else
errornum="$?"
echo "An error occurred while starting SVN daemon. Exiting with error $errornum"
exit "$errornum"
fi
}
#
function stop_svn
{
echo "Shutting down SVN daemon..."
while [ ! -z $(pgrep svnserve) ]
do
for pid in $(pgrep svnserve)
do
kill $pid
done
done
if [ "$?" = 0 ]
then
echo "Done"
else
errornum="$?"
echo "An error occurred while shutting down SVN daemon. Exiting with error $errornum"
exit "$errornum"
fi
}
#
case $1 in
"start")
start_svn
;;
"stop")
stop_svn
;;
"restart")
stop_svn
sleep 1
start_svn
;;
*)
;;
esac
  • Add to desired runlevels:
# example: add to runlevel , under priority 80
ln -s /etc/init.d/svnserve /etc/rc5.d/S80svnserve

Use multiple Sakai deployments aware folders/scripts

This will assume that three different deployment types are needed:

  • preprod: for testing code before deployment into production
  • test: for testing different releases/tags
  • mini: for development purposes

Basically, this requires (for each deployment type):

  • different sakai home folders
  • different tomcat folders
  • different sakai source code folders
  • different maven batch scripts
Setup folder tree on disk

Create the following structure on disk:

  • /services/
    • bin/
    • sakaihome-preprod/
    • sakaihome-test/
    • sakaihome-mini/
    • tomcat-preprod/
    • tomcat-test/
    • tomcat-mini/
    • sakai-src/
      • preprod/
        • contrib/
          • master/ (link to ../current/master)
          • (in-house sakai tools)
        • contrib-ext/
          • master/ (link to ../current/master)
          • (3rd-party sakai tools)
        • current/ (link to sakai-ufp_2-2-x)
        • sakai-ufp_2-1-2
        • sakai-ufp_2-2-x
      • test/
        • (analogous)
      • mini/
        • (analogous)
Configure Maven
  • Edit ~build.properties to look like:
maven.repo.remote=http://source.sakaiproject.org/maven/
#maven.tomcat.home=/servicos/tomcat/ <-- MUST BE COMMENTED OUT!!!
maven.compile.source=1.4
maven.compile.target=1.4
maven.proxy.host=(your proxy server host)
maven.proxy.port=(your proxy server port)
  • Add /services/bin to the PATH variable
  • Remove maven from PATH and create in /services/bin the files maven-preprod, maven-test and maven-mini. Their content is similar to the following maven-mini file (replace path to maven and tomcat appropriate tomcat folder):
#!/bin/sh
if [ $# -lt 1 ]; then
        echo 1>&2 $0 requires arguments! 
        exit 127
fi
/opt/maven-1.0.2/bin/maven -Dmaven.tomcat.home=/services/tomcat-mini/ $1
  • Make the previous three files executable with: chmod +x /services/tomcat-mini (similar for preprod and test)


Configure Tomcat start/stop scripts

For the three possible deployments (preprod, test and mini) a file like the one below must be created in /etc/init.d/ (sample for mini):

#!/bin/sh
#
# Startup script for Tomcat, the Apache Servlet Engine
#
# chkconfig: 345 80 20
# description: Tomcat is the Apache Servlet Engine
# processname: tomcat
# pidfile: /var/run/tomcat.pid
#
# Mike Millson <mmillson@meritonlinesystems.com>
#
# version 1.02 - Clear work directory on shutdown per John Turner suggestion.
# version 1.01 - Cross between Red Hat Tomcat RPM and Chris Bush scripts
 
# Tomcat name :)
TOMCAT_PROG=tomcat
 
# if TOMCAT_USER is not set, use tomcat like Apache HTTP server
if [ -z "$TOMCAT_USER" ]; then
 TOMCAT_USER="tomcat"
fi
 
RETVAL=0
 
# Set Tomcat environment.
#export JAVA_HOME=/usr/java/j2sdk1.4.2_09
#export JAVA_VERSION=1.4
export JAVA_HOME=/usr/java/jdk1.5.0_06
export JAVA_VERSION=1.5
export MOZ_SRC=$JAVA_HOME/lib/
export JSSE_HOME=$JAVA_HOME/jre/lib/ext
#export JDK_HOME=/usr/java/j2sdk1.4.2_09
export JDK_HOME=/usr/java/jdk1.5.0_06
export CATALINA_HOME=/servicos/tomcat-mini
#export CATALINA_OPTS="-Dbuild.compiler.emacs=true"
export ANT_HOME=/home/tomcat/apache-ant
#CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib:$CATALINA_HOME/common/lib/jasper-compiler.jar:$CATALINA_HOME/common/lib/jasper-runtime.jar:$CATALINA_HOME/common/lib/serv
let-api.jar:$CATALINA_HOME/common/lib/pg74.215.jdbc3.jar:$CATALINA_HOME/common/lib/commons-pool-1.2.jar:$CATALINA_HOME/common/lib/commons-dbcp-1.2.1.jar
#export PATH=$PATH:/usr/java/j2sdk1.4.2_09/bin
export PATH=$PATH:/usr/java/jdk1.5.0_06/bin
export PATH=$PATH:/home/tomcat/apache-ant/bin
 
# start and stop functions
start() {
    export JAVA_OPTS="-server -Xms256M -Xmx256M -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:NewSize=64m -XX:MaxPermSize=128m -XX:PermSize=128m -XX:MaxTenuringThres
hold=3 -XX:CMSInitiatingOccupancyFraction=75 -XX:MinHeapFreeRatio=18 -XX:+UsePerfData -Dfile.encoding=UTF-8 -Dsakai.home=/servicos/sakaihome-mini/ -Djava.awt.headless=true"
    export JPDA_TRANSPORT=dt_socket
    export JPDA_ADDRESS=9000
    echo -n "Starting tomcat MINI: "
    chown -R $TOMCAT_USER:$TOMCAT_USER /servicos/tomcat-mini/*.*
    #su -m -s /bin/bash -c '/servicos/tomcat-mini/bin/startup.sh' tomcat
    su -m -s /bin/bash -c '/servicos/tomcat-mini/bin/catalina.sh jpda start' tomcat
    #/servicos/tomcat-mini/bin/catalina.sh jpda start
 
    RETVAL=$?
    echo
 [ $RETVAL = 0 ] && touch /var/lock/subsys/tomcat
    return $RETVAL
}
 
stop() {
    echo -n "Stopping tomcat MINI: "
    su -mc '/servicos/tomcat-mini/bin/shutdown.sh' tomcat
    #su -mc '/servicos/tomcat-mini/bin/shutdown.sh' root
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && rm -f /var/lock/subsys/tomcat /var/run/tomcat.pid
    rm -rf /servicos/tomcat-mini/work/*
}
 
status(){
    netstat -ln | grep :8005 >& /dev/null
    RETVAL=$?
    if [ $RETVAL -eq 0 ]
      then
        echo "Tomcat MINI is running"
      else
        echo "Tomcat MINI is stopped"
    fi
}
 
# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status
        ;;
  restart)
        stop
# Ugly hack
# We should really make sure tomcat
# is stopped before leaving stop
        sleep 2
        start
        ;;
  *)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
 
exit $RETVAL
How does it works

If working with code in mini:

  • go to source folder /services/sakai-src/mini/contrib/tool-A
  • execute a maven-mini sakai: this will clean, build and deploy to the appropriate /services/tomcat-mini folder
  • execute /etc/init.d/tomcat-mini start to start tomcat "mini"
  • execute /etc/init.d/tomcat-mini stop to stop tomcat "mini"
Personal tools