+# Build the development version of scm-manager together
+# with the latest development version of the scm-autologin-plugin.
+# (c) 2013 by Clemens Rabe <email@example.com>
+# Only do this on Ubuntu
+DISTRIBUTION=$(lsb_release -i -s)
+if [ "$DISTRIBUTION" != "Ubuntu" ]; then
+ echo "Sorry, but this script only works on Ubuntu systems!"
+if [ "$UID" == "0" ]; then
+ echo "Please don't execute this script as root!"
+# Get the base directory of this script
+BASEDIR=$(dirname $( dirname $( readlink -f $0 )))
+echo "Installing additional Ubuntu packages. You might be asked for your password to run"
+echo " sudo apt-get install maven mercurial"
+sudo apt-get install maven mercurial
+# Find a nice directory to use
+echo "Please enter the directory to use for the build. This directory should be empty"
+echo "and the individual software modules will be cloned into it."
+echo "Just press [enter] if you agree with the following directory, or specify one:"
+echo -n " Target directory [$ROOT]:"
+if [ -n "$NEWROOT" ]; then
+# Create the directory if necessary
+mkdir -p $ROOT &> /dev/null
+ echo "ERROR: Can't create directory $ROOT."
+hg clone https://bitbucket.org/sdorra/scm-manager
+hg clone https://bitbucket.org/seeraven/scm-autologin-plugin
+# Copy the rebuild scripts
+cp $BASEDIR/dist/build/rebuildScmManager.sh scm-manager/
+cp $BASEDIR/dist/build/rebuildAutoLoginPlugin.sh scm-autologin-plugin/
+# Create an eclipse workspace and project files
+mvn eclipse:configure-workspace -Declipse.workspace=$(readlink -f ../workspace)
+mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true
+mkdir -p scm-autologin-plugin-dist
+# hg update feature_ownUserType
+mvn scmp:install -DscmHome=../scm-autologin-plugin-dist
+# Copy the stuff together into one target directory
+mkdir -p dist/scm-manager
+cp scm-manager/scm-server/target/scm-server-app.tar.gz dist/scm-manager
+cp scm-manager/scm-server/target/scm-server-app.zip dist/scm-manager
+cp scm-manager/scm-webapp/target/scm-webapp.war dist/scm-manager
+mkdir -p dist/scm-autologin-plugin
+mv scm-autologin-plugin-dist/plugins/* dist/scm-autologin-plugin
+cp scm-autologin-plugin/target/*.scmp dist/scmp
+# Copy the dist directory into the scm-environment dist directory
+rm -f $BASEDIR/dist/scm-manager/*
+rm -rf $BASEDIR/dist/scm-autologin-plugin/*
+rm -f $BASEDIR/dist/scmp/*
+cp dist/scm-manager/scm-server-app.tar.gz $BASEDIR/dist/scm-manager/
+cp -a dist/scm-autologin-plugin/* $BASEDIR/dist/scm-autologin-plugin/
+cp -a dist/scmp $BASEDIR/dist/scmp
+echo "Finished building SCM-Manager and the scm-autologin-plugin."
+echo "The created elements are located in the directory $ROOT/dist:"
+echo " $ROOT/dist/scm-manager : The SCM-Manager standalone and webapp WAR files."
+echo " $ROOT/dist/scm-autologin-plugin : The AutoLogin plugin."
+echo " $ROOT/dist/scmp : The AutoLogin plugin as a package."
+echo "In addition, an eclipse workspace was created under $ROOT/workspace."
+echo "To open this version of SCM-Manager in eclipse, perform the following steps:"
+echo " - Start eclipse and select the workspace $ROOT/workspace."
+echo " - Open the menu File -> Import..."
+echo " - Select General->Existing Projects into Workspace"
+echo " - Choose the directory $ROOT/scm-manager as the root directory."
+echo " - Click on Finish."
+echo "To rebuild the elements look for rebuild scripts in the source directories!"