Sakai and Eclipse Recipe

Although Sakai tools can be created using just a text editor and basic Java tools, an Integrated Development Environment (IDE) such as Eclipse is strongly recommended.

Creating a Project

Components and Modules distributed with Sakai have their own Eclipse projects. These can be brought into Eclipse using the Project Import function. If you are cloning one of these modules, or have source code that you'd like to bring into Eclipse for the first time, use these steps:

  1. Launch Eclipse from your Start menu.
  2. Create a new project from File -> New.
  3. Select Java Project.
  4. Give your project a name, perhaps based on your app-name.
  5. Select "Create at External Location"
  6. Point at "c:\dev\sakai2\app-name".
  7. Eclipse should detect your source dir.

Using Eclipse gives you some advantages:

  • Syntax checking
  • External reference checking
  • Code generation

However, you still need to use Maven:

  • Compiles against Tomcat classpath
  • Deploys code to Tomcat.

Importing a JAR into an Eclipse Project

Much of the code you develop for Sakai will use existing JARs. These JARs should be imported from your local Maven repository. For example, the following steps import the Sakai Session JAR:

  1. Left click on your Eclipse project and select Properties from the menu.
  2. Select "Java Build Path"
  3. Click "Add External JARs" button.
  4. Add the JAR from: "~/.maven/repository/sakaiproject/jars/sakai-session-2.0.0"

Since Eclipse uses a different build path than Maven and Tomcat, you need to include an dependency in your project.xml file:

Add the following XML fragment to your project.xml file:

<dependency>
	<groupId>sakaiproject</groupId>
	<artifactId>sakai-session</artifactId>
	<version>2.0.0</version>
</dependency>

You must have perfect agreement between version numbers in your dependencies and the project where they are created. Here is how the Session module is declared:

<project>
	<pomVersion>3</pomVersion>
	<name>Sakai Session API</name>
	<groupId>sakaiproject</groupId>
	<id>sakai-session</id>
	<currentVersion>2.0.0</currentVersion>
	...
</project>
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Oct 05, 2005

    David Haines says:

    The maven build process was updated at the end of September to have the value of...

    The maven build process was updated at the end of September to have the value of the sakai version in dependencies automatically map to a value set in a master project.properties file. If you are doing development with code from the trunk then the above Maven dependencies should already be ${sakai.version} rather than a particular version. If you are requiring dependencies from 2.0.1 or earlier then you do need to be sure that you are specifying a particular version.