Set up multiple Sakai versions
Setting up multiple Sakai versions
We've all had to maintain an older version of a product in production and attempt to upgrade to the latest, greatest.
Here are some tips and tricks for setting up and developing with multiple versions of Sakai on your desktop.
This document assumes that you already have a working version of Sakai on your desktop. The following steps corresponds to those on Development Environment Setup Walkthrough. Most of the tools needed should already be installed.
If you are installing a single instance of sakai on your desktop, please follow the steps in the Development Environment Setup Walkthrough.
<Sakai Version> is the version of Sakai
Verify you have Java 1.5
- To check: Run java -version on the command line
Verify you have MySQL 4.1
- To check: Run mysql --help on the command line
Setup Sakai DB (schema) and user
- Create a new database instance relating to the sakai version. ex. sakai25
- The user and password can be the same(user=sakai and password=ironchef)
- Run the following from a command line prompt:
mysql -uroot -pmysqlpwd1
- Then run these commands from the mysql prompt (one command per line):
create database sakai25 default character set utf8; grant all privileges on sakai.* to 'sakai25'@'localhost' identified by 'ironchef'; flush privileges; quit
Download and setup Maven 2.0.6+ stable package
- if your current version of sakai is using Maven 1.0.x, then follow the steps in the Development Environment Setup Walkthrough.
Verify you have Subversion
- To check: Run svn --version on the command line
setup tomcat 5.5.17+ (stable only)
- It is recommended that after the initial setup of tomcat, that a clean copy of tomcat be created.
- Hopefully there is a clean copy of tomcat on your desktop.
- If so copy this to /opt and rename it to identify the sakai version ex. /opt/tomcat-5.5_25
otherwise, download install the same version of tomcat and set up base on the instructions in Development Environment Setup Walkthrough. - Remove all sakai subdirectories under components, webapps, shared, common
- This allows a developer to return to initial setup if the tomcat get trashed....
Setup MySQL Connector/J stable
- This should already be set up
Use Subversion to download sakai cafe trunk
- follow the instructions in the Development Environment Setup Walkthrough.
Setup sakai.properties file
- Copy the sakai directory from the current tomcat copy the the new tomcat created in step 6.
- Make any modification to this sakai.properties file for this version.
- change the data base instance to point to the one created in step 3.
Example
url@javax.sql.BaseDataSource=jdbc:mysql://127.0.0.1:3306/sakai25?useUnicode=true&characterEncoding=UTF-8
Create maven settings.xml file
- Create a new xml file for this Sakai Version in your user home directory in the .m2 directory called settings25.xml
- Note: This is probably c:\documents and settings\<username> in Windows
- Download a sample settings.xml file (setup for windows users)
- Add the following lines pointing to tomcat created in step 6:
Example
<settings xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<profiles>
<profile>
<id>tomcat5x</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<appserver.id>tomcat5x</appserver.id>
<appserver.home>/opt/tomcat-5.5_25</appserver.home>
<maven.tomcat.home>/opt/tomcat-5.5_25</maven.tomcat.home>
<sakai.appserver.home>/opt/tomcat-5.5_25</sakai.appserver.home>
<surefire.reportFormat>plain</surefire.reportFormat>
<surefire.useFile>false</surefire.useFile>
</properties>
</profile>
</profiles>
</settings>- Note: Unfortunately, Sakai does not use the standard appserver.home so you have to specify a sakai.appserver.home
- Note: The sakai.appserver.home must be C:\opt\tomcat <Sakai Version> for windows users
- Note: Do not include trailing / or \ slashes in the directory paths
- Create a new xml file for this Sakai Version in your user home directory in the .m2 directory called settings25.xml
Use Maven to build Sakai
- follow the instructions in the Development Environment Setup Walkthrough.
Create batch files to start, stop, and debug tomcat
- For Windows users, create a directory and add this to your path. ex. C:\bat
- Note: Remove any references to the existing $CATALINA_HOME from the path, it may cause confusion in the scripts
- From your $CATALINA_HOME/bin directory, copy startup.(bat-sh) to /bat
- Rename it to startup <Sakai Version> .(bat-sh) ex. startup25.bat
- Edit startup<Sakai Version>
- Add the following lines:
set JAVA_OPTS=-server -XX:+UseParallelGC -Xmx768m -XX:MaxPermSize=160m -Djava.awt.headless=true set cd=c:\opt\tomcat-5.5-<Sakai Version> set CATALINA_HOME=%cd%
- Then from your $CATALINA_HOME/bin directory, copy shutdown.(bat-sh) to /bat
- Rename it to shutdown <Sakai Version> .(bat-sh) ex. shutdown25.bat
- Add the following lines:
set cd=c:\opt\tomcat-5.5-<Sakai Version> set CATALINA_HOME=%cd%
- Repeat these steps for the current tomcat instance
- For Windows users, create a directory and add this to your path. ex. C:\bat
Start Tomcat and check to make sure Sakai runs
- Start Tomcat
- Open a command line shell
- Change directory to /bat
- Type startup <Sakai Version> .(bat-sh) ex. startup25.bat
- Allow 1 minute+ for tomcat to start up
- Open http://localhost:8080/ to verify tomcat is running
- Open http://localhost:8080/portal to verify sakai is running
- Login to sakai as username:admin, password:admin
- Shutdown Tomcat using by typing shutdown <Sakai Version> .(bat-sh) ex. shutdown25.bat
Install Eclipse 3.2+ stable
- This should already be set up.
- Otherwise, follow the instructions in the Development Environment Setup Walkthrough. for more info
- Note: If you already have eclipse 3.1.x installed, your best best is to start over with a fresh install rather than attempting to upgrade
- Note: If you have not installed eclipse already, you should download the WebTools Platform: All-in-one package for Eclipse 3.3+ which includes Eclipse and all of the necessary WebTools packages, this is much faster and easier than downloading them separately, you can skip the WebTools step if you do this, here are instructions to install the Eclipse WebTools
Add Eclipse Web Tools Project (WTP)
- This should already be set up
Add subclipse to Eclipse
- This should already be set up
Add SpringIDE to Eclipse
- This should already be set up
Import Sakai source code into Eclipse
- Startup eclipse if it is not running
- Create a new workspace for the new Sakai Version
- Click on File -> Switch Workspace
- Enter "WS-Sakai*<Sakai Version>*" ex. WS-Sakai25 in place of the default "workspace" directory
- Click OK (eclipse will restart)
- The following steps should be done in the WS-Sakai workspace
- Add Maven Repository libraries to classpath
- Select Window -> Preferences -> Java -> Build Path -> Classpath Variables
- Add M2_REPO classpath variable with the path to the local maven repository (Sakai 2.5 or higher)
- The path should be: $USER_HOME/.m2/repository
- Switch to the Java perspective (Window -> Open Perspective -> Java)
- Make sure you are in the package explorer
- Turn off Automatic builds
- Select Project and uncheck Build automatically
- Select File -> Import -> Existing Projects into Workspace
- Enter the full path to the sakai source directory for the root directory
- This should be /opt/cafe-2.2.x if you followed the steps in this document
- Click Deselect All to unselect all projects
- Select the following projects (you only need most of the APIs, a few utils, and all of the db projects)
alias-api
announcement-api
archive-api
authz-api
component-api
content-api
courier-api
cm-api
db-api
db-impl
db-util
entity-api
email-api
event-api
jsf
message-api
master
site-api
site-manage-api
tool-api
user-api
user-util
util-api
util-util
velocity- NOTE: You can just import all the projects also, this tends to work fine for me
- Click Finish to import the selected projects
- This will take awhile, probably 5+ minutes
- Create a working set for Sakai (optional)
- You do not have to create a working set, these are here in case you want to
- Switch to the Java perspective
- In the Package Explorer pane click the drop-down arrow menu and choose Select Working Set
- Click the New button from the Select Working Set Dialog window
- Choose Java for the Working Set Type and click Next
- Enter Sakai as the name for your Working Set
- Select the imported Sakai projects and click Finish
- Build Sakai in Eclipse
- Initially you will get build failures on almost every Sakai project, this is because they are building in the default order and their dependencies are in a different order, this has been partially addressed in Sakai 2.2
- Clean all Sakai projects
- Select Project -> Clean
- Select Clean all projects
- Check Start a build immediately
- Click OK
- Build All (Project -> Build All)
- Do this if using working sets:
Build the Sakai working set (Select Project -> Build Working Set -> Sakai) - Repeat this step until no errors remain (should be no more than 3-4 times)
- There will be hundreds of warnings, do not worry about these
- Do this if using working sets:
- Turn back on Automatic builds
- Select Project and check Build automatically