Skip to content
keeeeenw edited this page Jun 26, 2013 · 7 revisions

summary Directions for installing Macademia.

Install Homebrew (Mac only)

(for reference: http://mxcl.github.io/homebrew/)

  • Homebrew can help you install and manage tools on Mac. We will use Homebrew to install the software we need for grails and database.
  • Alternatively, you can use MacPort or Fink. We recommend you install only one managing tool. Having multiple managing tool may cause some problem.
  • To install Homebrew open up the your terminal and type:
    • ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
  • Try running brew doctor command to see if any warning is generated.
    • Look through the warnings and try to resolve some of them.
    • If you have MacPort in your system, you may need to disable MacPort temperately by using the following command:
      • sudo mv /opt/local ~/macports
    • You may need to install or update Git using brew install git or brew upgrade git.

Install grails

For Macs using Homebrew:

  • In your terminal, run the following command:

    brew update

    brew install grails

  • Add the following two lines to the ".profile" file in your home directory. You may have to create the file if doesn't exist. You can use any editor you would like, but make sure it is in "plain text" mode. TextEdit ships with the Mac. Terminal tools such as Nano works great for starters.

    export GRAILS_HOME=/usr/local/Cellar/grails/2.2.2/libexec

    export JAVA_HOME=/Library/Java/Home

    • You may use the following command to open up Nano text editor inside the terminal:

      cd ~

      nano .profile

      • The cd~ command changes your current directory to your home directory.

      • After you add the two lines, we can use keyboard combination "control+X" to quit the editor.

      • The editor will ask whether you want to save the file, type "Y".

    • You can check to make sure this worked properly by opening a terminal and typing echo $GRAILS_HOME. You should see the information you entered.

    • You should also check whether the grails executable command is working by typing grails in the terminal

    • Note: In order to show your .profile file if it exists and it is hidden, type the following in terminal:

      defaults write com.apple.finder AppleShowAllFiles TRUE

      killall Finder

      To Hide again, just change TRUE to FALSE

    • Typing ls -la in terminal can also list the hidden file(s) in the current directory.

    • For other operating systems, see this guide: http://www.grails.org/Installation

Install MongoDB

  • Installing MongoDB using Homebrew on the Mac is simple. Type the following command in your terminal:

    brew update

    brew install mongodb

  • For other operating systems, see this reference: http://docs.mongodb.org/manual/installation/

Configure MongoDB

  • In a new terminal window type the following commands. Change 'research' into your own username if you installed MongoDB on your own computer. You also need to enter your login password.

    sudo mkdir -p /data/db

    sudo chown -R research /data/

  • Use the following command to start MongoDB. You should keep the terminal window running when you are developing.

    mongod

Install PostgreSQL

  • Installing PostgreSQL using Homebrew on the Mac is simple. Type the following command in your terminal:

    brew update

    brew install postgresql

  • This link gives you more detailed steps: http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x

  • If you have used an older version of PostgreSQL, you may need to uninstall the old version. Go the link above for details.

  • Notice that Homebrew does not create a "postgres" user. Initially, you can access the database using the same user account under which you ran brew install postgresql. For example, in our lab machine, we can use account "research" and its login password to access the postgreSQL database.

Configure PostgreSQL

  • For your reference, the scripts installed by Homebrew are under /usr/local/opt/postgresql/bin. The installation path used by Homebrew is different from the path used by tools such as MacPort.

  • Initialize the server, type the following command in the terminal (You only need to do this once)

    initdb /usr/local/var/postgres

  • Start the server, type the following command in the terminal

    pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

  • To stop the server you can use

    pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log stop

  • Create user “grails” with password “grails”:

    sudo -u research /usr/local/opt/postgresql/bin/createuser -P grails -s

    • Change 'research' into your own username if you installed PostgreSQL on your own computer using Homebrew

    • First, the prompt may ask you to enter the password for user 'research' (or your login username if you are using your computer).

    • Then you should enter 'grails' as the password for the new role.

  • Create the following the database by typing in the following commands in terminal

    /usr/local/opt/postgresql/bin/createdb -Ugrails macademia_test_research

    /usr/local/opt/postgresql/bin/createdb -Ugrails macademia_dev_research

    /usr/local/opt/postgresql/bin/createdb -Ugrails macademia_prod_research

Setup Intellij

  • Download (http://download.jetbrains.com/idea/ideaIU-12.1.3.dmg) and install Intellij. You want the ultimate edition.

  • Start up IntelliJ. You'll need to answer some configuration questions:

    • For now we'll use the evaluation license (or ask Shilad for the license).

    • You need to select the subversion and Git VCS plugin.

    • Select all the Web / J2EE plugins.

    • Only select the tomcat and Resin app server plugins.

    • Select all the HTML / Javascript plugins.

    • Select all the "Other" plugins.

    • The first time you create a Java or grails project you'll need to specify a path to a Java Compiler. Choose "a new JCS," and use the path you specified for JAVA_HOME in your .profile.

Check out Macademia

  • Setup Github repository.

    • We will use the repository on Github for our project, you can sign up an account on Github (https://github.com/).

    • After registering an account, go to https://github.com/shilad/macademia and the page shows you the files in the original repository.

    • If you work for the Macademia team, you should switch to appropriate branch for development.

    • To contribute to the project, you should fork your own repository by clicking the 'fork' button on the upper right corner of the same web page. To lean more about forking, go to https://help.github.com/articles/fork-a-repo

    • Notice that when a repository is cloned, its origin is set to your own forked repository instead of the original repository.

  • Check out Macademia on Intellij

    • Open Intellij and click "check out from version control."

    • Choose Github.

    • Intellij will ask for your Github username and password.

    • Use https://github.com/your_github_user_name/macademia.git for 'Git Repository URL'. You need to change "your_github_user_name" in the url into your actual username on Github.

    • You can specify your own 'Parent Directory' and 'Directory Name' on your local machine.

    • Click 'clone' and intellij will clone the repository from your forked repository.

  • Configure the project

    • After checking out, Intellij will ask you if you want to create a grails application for the checked out files, click "yes".

    • Then click on "Create project from existing source". Give it a project name and location.

    • Intellij should identify the folder as Grails project. You can click "Next".

    • It may ask for a JDK, click the "+" and select your JAVA_HOME directory: /Library/Java/Home.

    • Then it will ask you to choose the Grails SDK. It will be under /usr/local/Cellar/grails/2.2.2/libexec if you used Homebrew to install grails.

    • Click 'finish'.

  • Initialize the grails project (very important steps!):

    • run grails clean: tools > run grails target, type clean as the Command line.

    • We are currently supporting Grails 2.2.2. Ask Shilad before you upgrade to a higher version of Grails.

    • To run grails upgrade: tools > run grails target, type upgrade as the Command line. You will have to click on the scrolling text in the console and type "y" to continue the upgrade command.

    • You need the MacademiaConfig.groovy file to connect to the databases. If the file does not exist in grails-app/config, copy MacademiaConfig.example.groovy (in grails-app/config), paste a copy in to the same location and rename it MacademiaConfig.groovy.

    • In MacademiaConfig.groovy, uncomment the part dataSource.mongoDbUrl = '127.0.0.1' and whole switch statement. You should leave macademia.uniqueDbToken = 'shilad' commented.

Load production data into the system (For Macademia Team only):

  • Before loading the data, you should make sure MongoDB and PostgreSQL are both running

    • Type mongod in a new terminal window and keep it there

    • Type pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start to start PostgreSQL

  • In the terminal, go to the 'Macademia' directory under the directory you checked the project out to (your_project/Macademia/) and type

    ./scripts/restoreDb.sh

    • You will need to ask Shilad for the account and password.

    • This command will run a bash script to retrieve data from the production server and insert into the database

  • (Optional) You need to ask Shilad to run the syncImages.sh script for you to retrieve the profile pictures

  • Finally, unzip nbrviz.zip into the same directory (your_project/Macademia/db)

Intellij Issues

  • At this point, you should be able to compile and run the project. If you have any problem, make sure you have ran grails clean and grails upgrade. Both MongoDB and PostreSQL database should be running when you are loading the data or running the website locally. You also need to make sure you are entering the correct password for different accounts we are using.

  • If Intellij starts to not use your java SDK (ie, all your classes don't work, even the word "String" is unlined with red"), simply go to File > project structure and change the project SDK (probably select java sdk, then "current sdk" from the drop down folder)

Setting up the Grails Compass / CSS plugin

  • Macademia uses a CSS framework called Compass. In Compass, you write in a "super-css" language called SCSS: http://sass-lang.com/. Compass compiles your scss into css code.
  • Macademia's scss files live in src/stylesheets
  • We use the grails compass-sass plugin. To install it:
    • brew install jruby
    • jgem install compass
    • Right now the compass plugin seems broken, so we need to run the compass compiler by hand:
    • In a new terminal, run the following in your Macademia directory: jruby -S compass watch --sass-dir ./src/stylesheets --css-dir ./web-app/css --output-style compact --images-dir web-app/images --relative-assets --no-line-comments
    • Leave this terminal / command open. It will immediately compile your changes to scss files into css files.