Development Environment Setup Walkthrough (2.5.x-2.8.x)
Information
This is a walkthrough for setting up a Sakai development environment on a laptop or desktop. These instructions will also work for setting up a development server though I suggest slightly beefier settings for memory. This is currently tailored for Sakai 2.5 - 2.8. Once you have a Sakai development environment setup you should be able to program your own Sakai tools or modify existing tools.
Notes for developers using Sakai 2.4.x-
Developers who are using Sakai 2.4.x or lower should use the Development Environment Setup Walkthrough (2.2.x-2.4.x)
Notes for developers using Sakai 2.9.x+
Developers who are using Sakai 2.9.x or higher (trunk after Sept 2011) should use the Development Environment Setup Walkthrough
Notes for windows users
change the "/" to "\" for all directory paths except those specified in the maven build.properties file
add the drive letter (C:) to your paths
use %VARIABLE% instead of $VARIABLE with environment variables
set your environment variables in Control Panel -> System -> Advanced -> Environment Variables
Zach Thomas has created a screencast which walks developers through setting up their Sakai 2.5 development environment
http://aeroplanesoftware.com/wordpress/wp-content/uploads/2008/01/developing-for-sakai-getting-started960x540.mov
http://aeroplanesoftware.com/wordpress/wp-content/uploads/2008/02/developing-for-sakai-setting-up-eclipse960x540.mov
All of sakai and related programs should be installed in an opt directory which you will need full write access to, put this directory anywhere you want, this document will assume you have placed it in your root directory
Install/Verify you have Java 1.5
Install/Verify you have MySQL 4.1
Setup Sakai DB (schema) and user
Create the sakai database and sakai user (password=ironchef)
Run the following from a command line prompt:
mysql -uroot -pmysqlpwd1Note: You can also do the following if you prefer to be prompted for the password: mysql -uroot -p
Then run these commands from the mysql prompt (one command per line):
create database sakai default character set utf8; grant all privileges on sakai.* to 'sakai'@'localhost' identified by 'ironchef'; flush privileges; quit[Optional] Download and install mysql query browser
You do not have to do anything with query browser now
Download and setup Maven 2.0.6+ stable package
Install/Verify you have Subversion
Download and setup tomcat 5.5.17+ (stable only)
Download and setup MySQL Connector/J stable
Use Subversion to download sakai cafe trunk
Change to the /opt directory
svn checkout https://source.sakaiproject.org/svn/cafe/trunk/ cafe_trunk
If you want a version other than this one, browse the tags and branches at https://source.sakaiproject.org/svn/cafe/
subversion will create a "trunk" directory for you,
you can use any directory name you like, just add a name after the checkout location:
svn checkout https://source.sakaiproject.org/svn/cafe/trunk/ cafe-trunk
Checkout will take about 5-10 minutes
The directory created by subversion will be referred to as <sakai-src> directory
Setup sakai.properties file
Create sakai directory in $CATALINA_HOME
$CATALINA_HOME should be /opt/tomcat if you have been following these instructions
Note: There were previously two configuration files, sakai.properties and placeholder.properties. These have now been combined into sakai.properties. You can attempt to manually combine the two files from a previous version, but it's better to start with the sample included with the sakai source in the reference directory.
Copy sakai.properties from <sakai-src>/reference/docs to $CATALINA_HOME/sakai
Note: This file may not be in your checkout if you have acquired one of the older versions of cafe - you can fetch it manually from here https://source.sakaiproject.org/svn/reference/trunk/docs/sakai.properties.
Make sure you get the sakai.properties for the version of Sakai you are using (e.g. Sakai 2.4.x):
http://source.sakaiproject.org/svn/reference/branches/sakai_2-4-x/docs/sakai.properties
Edit the sakai.properties file for a MySQL dev environment. Starting at the section # DATABASE CONFIGURATION:
Set BaseDataSource username
Set username@javax.sql.BaseDataSource=sakai
Set BaseDataSource password
Set password@javax.sql.BaseDataSource=ironchef
Find the section: ## HSQLDB settings and comment out 7+ lines in it
## HSQLDB settings - on by default #vendor@org.sakaiproject.service.framework.sql.SqlService=hsqldb #driverClassName@javax.sql.BaseDataSource=org.hsqldb.jdbcDriver #hibernate.dialect=org.hibernate.dialect.HSQLDialect #validationQuery@javax.sql.BaseDataSource=select 1 from SYSTEM_USERS # two hsqldb storage options: first for in-memory (no persistence between runs), second for disk based #url@javax.sql.BaseDataSource=jdbc:hsqldb:. #url@javax.sql.BaseDataSource=jdbc:hsqldb:${sakai.home}/db/sakai.dbFind the section: ## MySQL settings and uncomment the 6+ lines in it
## MySQL settings - make sure to alter as appropriate vendor@org.sakaiproject.db.api.SqlService=mysql driverClassName@javax.sql.BaseDataSource=com.mysql.jdbc.Driver hibernate.dialect=org.hibernate.dialect.MySQLDialect url@javax.sql.BaseDataSource=jdbc:mysql://127.0.0.1:3306/sakai?useUnicode=true&characterEncoding=UTF-8 validationQuery@javax.sql.BaseDataSource=select 1 from DUAL defaultTransactionIsolationString@javax.sql.BaseDataSource=TRANSACTION_READ_COMMITTED
Note that this line may be incorrect in the default file, it should read as shown:
vendor@org.sakaiproject.db.api.SqlService=mysql
Save the changes to the file
Create maven settings.xml file
Use Maven to build Sakai
Open a command line shell
Change directory to /opt/<sakai-src>
Execute mvn -Pcafe clean install to build Sakai using maven
Note: The build will take an extra 5-10 minutes to download dependencies the first time
Execute mvn -Pcafe sakai:deploy to deploy Sakai to your tomcat using maven
Unlike in maven1, the maven2 Sakai plugin downloads automatically (this allows you to deploy the parts of projects to the right locations in tomcat)
Partial builds are supported by the maven2 build system
You can now do a "mvn clean install sakai:deploy" from any subdirectory and build just that codeOnce you have downloded the jars you can run maven off-line with mvn -o clean install sakai:deploy
Start Tomcat and check to make sure Sakai runs
Start tomcat using $CATALINA_HOME/bin/startup
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 $CATALINA_HOME/bin/shutdown
Add Eclipse Web Tools Project (WTP)
Add subclipse to Eclipse
Add Maven Eclipse Plugin to Eclipse
Import Sakai source code into Eclipse