« Back to Development...

Development Environment (Mac OS X)

Tags: development

This article will discuss the setup of a development environment on Mac OS X.

Prerequisites #

  • Basic knowledge of the Terminal application. If you are not yet familiar with the Terminal application, take a look at some of the great articles on http://www.macdevcenter.com. At minimum, skim through the first of the 5-part series An Introduction to Tiger Terminal (Parts 1, 2, 3, 4, and 5) and other articles about the Terminal application.
  • Installation of the latest version of XCode, currently at v2.5 for pre-Lepoard (OS X 10.5) and v3.0 for Leopard.

Java Environment #

XCode should have installed various version of the JVM and JDK at /System/Library/Frameworks/JavaVM.framework/Versions as well as Jikes 1.2.2 at /usr/bin/jikes. If for some reason you want to compile your code using JDK 1.4.x rather than 1.5+, you will need to compile Jikes 1.21 yourself. From hereon in, the assumption will be that you are using JDK 1.5 and Jikes 1.2.2.

Open the Terminal application and add your JAVA_HOME to your /.profile file:

 echo 'export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home"' >> ~/.profile

Close the Terminal window and open a new one. This will guarantee the .profile initialization file gets read. If you type java -version, you should see something like the following:

 [liferay@Hesed 11:34:16 ~] $ java -version
 java version "1.5.0_07"
 Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-164)
 Java HotSpot(TM) Client VM (build 1.5.0_07-87, mixed mode, sharing)

Also, verify your jikes version with jikes -version:

 [liferay@Hesed 11:34:20 ~] $ jikes -version
 Jikes Compiler - Version 1.22 - 3 October 2004
 Copyright (C) IBM Corporation 1997-2003, 2004.
 - Licensed Materials - Program Property of IBM - All Rights Reserved.
 Originally written by Philippe Charles and David Shields of IBM Research,
 Jikes is now maintained and refined by the Jikes Project at:
 <http://ibm.com/developerworks/opensource/jikes>
 Please consult this URL for more information and for reporting problems.

Download Ant 1.7.0 and unzip it on your Desktop. In your Terminal, change to your /usr/local directory, move Ant into this directory, and change the owner of the ant directory to the root user:

 cd /usr/local
 sudo mv ~/Desktop/apache-ant-1.7.0 .
 sudo chown root:wheel apache-ant-1.7.0

Add Ant to your PATH in the /.profile:

 echo 'export PATH=/apache-ant-1.7.0/bin:$PATH' >> ~/.profile

Close the Terminal window and open a new one. If you type ant -version, you should see something like the following:

 [liferay@Hesed 11:50:14 ~] $ ant -version
 Apache Ant version 1.7.0 compiled on December 13 2006

Liferay Environment #

Now that you have all the basic tools, let's get Liferay and the Extension Environment. You will want to download and unzip the following to your Desktop:

  • Latest Liferay bundle with Tomcat (for JDK 5.0) from http://www.liferay.com/web/guest/downloads
  • Latest Liferay source code from http://www.liferay.com/web/guest/downloads/additional

In your home directory, create a new directory called "liferay" and move these two directories into it (in my case, my source directory was unzipped as "liferay-portal-src-4.3.3 Folder" and my Tomcat bundle was unzipped as "liferay-portal-tomcat-5.5-jdk5-4.3.3 Folder"):

 cd ~
 mkdir liferay
 mv ~/Desktop/liferay-portal-src-4.3.3\ Folder ~/liferay/portal
 mv ~/Desktop/liferay-portal-tomcat-5.5-jdk5-4.3.3\ Folder ~/liferay/tomcat

In the process, you have also renamed the source directory to be /liferay/portal and the Tomcat directory as /liferay/tomcat. Go to the directory /liferay/portal, setup the location of your Extension Environment, and build it:

 cd ~/liferay/portal
 echo 'lp.ext.dir=/Users/'`whoami`'/liferay/ext' >> release.`whoami`.properties
 ant start build-ext

You should see a long dump of information and, assuming you are successful, everything should be done in a few minutes. Go into your Extension Environment, specify your deployment directory, and deploy a new copy of Liferay into the Tomat bundle:

 cd ~/liferay/ext
 echo 'app.server.tomcat.dir=/Users/'`whoami`'/liferay/tomcat' >> app.server.`whoami`.properties
 ant clean deploy

Once again, you should see a print out of a lot of the build process and everything should be done in a minute or so. Before starting Tomcat, you will want to make sure the shell files have the appropriate permissions:

 cd ~/liferay/tomcat/bin
 chmod 755 *.sh

Now is time to start Tomcat:

 ./startup.sh

Tomcat would have started up and be running in the background. Let's monitor the logs with the tail command:

 tail -f ../logs/catalina.out

If all has worked thus far, you should be seeing the logging of Liferay running, resulting in something like the following:

 INFO: Server startup in 55925 ms

To test it out, open your favorite browser (mine is Safari) and go to the URL http://localhost:8080. You can log in with the Administrator credentials:

 Login: test@liferay.com
 Password: test

After you are done with Liferay, you need to shut it down. Go back to the Terminal window where you had been tailing your catalina.out file, stop it with the keystroke CTRL-C, and shutdown the server with the following command:

 ./shutdown.sh

MySQL #

Download the MySQL database.

After installation of the MySQL database and the startup script you need to start the terminal and run following commands to create a new database and add a new user (only development).

$mysql -u root

mysql> \r mysql
mysql> create user lportal identified by 'lportal';
mysql> create database lportal character set utf8 COLLATE utf8_general_ci;
mysql> GRANT ALL ON lportal.* TO 'lportal'@'%';
mysql> flush privileges;
mysql> \q

When this is done you need to create a new file within the ext module within the sql directory.

 $cd ~/liferay/ext/sql
 $cp  sql.properties  sql.`whoami`.properties

Now you need to configure the new created file. Example configuration is shown below (I've added a user property that is used to connect to the database).

#
    # Set the database name used by the SQL scripts.
    #
    database.name=lportal
    
    # Set the username
    
    database.user=lportal

    #
    # Set the database server types to build SQL scripts for.
    #
    database.types=mysql

    #
    # Set the suffix to load the minimal database scripts.
    #
    minimal.suffix=

    mysql.executable=/bin/bash
    mysql.arg.line=-c "/usr/local/mysql/bin/mysql -u${database.user} < create${minimal.suffix}/create${minimal.suffix}-mysql.sql"
    mysql.log=mysql.log

The last thing is to run the ant script that will create the tables.

$cd ~/liferay/ext/sql
$ant

TODO describe how to configure the properties to point to the new database...

For Leopard-related caveats, see Development Environment (Mac OS X)#Notes on Leopard / Mac OS X 10.5 below.

Eclipse IDE #

TODO...

IEs4osx #

It is possible to run Internet Explorer on Intel Macs using a port of IEs4Linux known as IEs4osx. This is how you would go about the installation:

  1. If running Tiger, install X11 onto your computer.
  2. Install Darwine by copying the Darwine folder into your /Applications directory.
  3. Double click install ies4osx.
  4. Select the versions of IE you want to install (I just use IE 6).
  5. Done.

Notes on Leopard / Mac OS X 10.5 #

  • MySQL. There is now a Leopard-compatible version of MySQL preferences pane. It comes as a separate download from the MySQL installer for Leopard.
  • Home directory. Apple seems to have commandeered the /home directory for its own purposes; trying to create directories (e.g., /home/liferay/deploy for hot deploy directory) there will cause errors. Please configure Liferay to use a different directory; you'll need to change settings for the Lucene index, autodeploy directory, and jackrabbit file store.
0 Attachments
17423 Views
Average (0 Votes)
Comments

Showing 1 Comment

Amy Mead
7/10/10 12:50 PM

Couple of things.. I have not been able to complete this process yet. I have run into a couple of stumbling blocks.

1) In the Liferay environment section, I think you have to create a directory call ~/liferay/ext, correct. The instructions assume that it exists.

2) When I executed the:
ant start built-ext

It seemed to be working fine, but it ended with the following error:

BUILD FAILED
Target "built-ext" does not exist in the project "portal".

3) I installed Xcode on Leopard to get Jikes, however setting the environment variables for Java didn't seem to matter from a compiler perspective. I assumed it would be using jikes, however I watched the ant build process and it was using javac. Here is my JAVA_HOME

JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home­

4) With regard to:

cd ~/liferay/ext
echo 'app.server.tomcat.dir=/Users/'`whoami`'/liferay/tomcat' >> app.server.`whoami`.properties
ant clean deploy

I assume the 'ant start build-ext' has to work correctly because when I ran this command, it could not find the build.xml file to complete.