Sunday, December 2, 2012

Ubuntu, openjdk-7-jdk, ant, subversion, git, chromium and the command line

Attention: This is old stuff. New build instructions here

The objective today is to build the photodb application and the trunk version of the TomEE/OpenEJB server from scratch with a brand new Ubuntu box. For this demo, I will use a virtual machine with 2GB of RAM.

Installing the OS
Install all the tools we need. Copy and paste these lines to a terminal.

sudo apt-get install -y openjdk-7-jdk ant subversion git chromium-browser && \
mkdir -p ~/dev/bin && \
cd ~/dev/bin && \
wget http://www.apache.org/dist/maven/maven-3/3.0.4/binaries/\
apache-maven-3.0.4-bin.tar.gz && \
tar -xvzf apache-maven-3.0.4-bin.tar.gz && \
sed -i '$ a\' ~/.bashrc && \
sed -i '$ a\#photodb export' ~/.bashrc && \
sed -i '$ a\export M2_HOME=$HOME/dev/bin/apache-maven-3.0.4' \
~/.bashrc && \
sed -i '$ a\export PATH=$M2_HOME/bin:$PATH' ~/.bashrc && \
export M2_HOME=$HOME/dev/bin/apache-maven-3.0.4 && \
export PATH=$M2_HOME/bin:$PATH && \
mkdir -p ~/dev/ws && \
cd ~/dev/ws && git clone https://github.com/tveronezi/\
photodb.git && \
cd photodb && \
git checkout b319d23aba888aa3059f953c5c551e0dda1bd346 && \
cd ~/dev/ws/photodb && \
make start-tomee && \
sleep 20 && \
chromium-browser http://localhost:8080/photodb/

The commands above will:
  1. Install all the binaries we need;
  2. Download and install Maven 3;
  3. Clone the photodb source code from git;
  4. Start the TomEE server.

Sit back and enjoy the output lines going by. It will take some time to complete the execution of all these commands (About one hour in my VM), but this is just one time thing. Maven downloads about 1GB of binaries for us. It also builds our application and the Apache TomEE/OpenEJB server locally.

See the screenshots of this process bellow.

Open a terminal

Copy and paste the commands

Installing the binaries

Installing Apache Maven

"svn co" of the Apache TomEE/OpenEJB source code

Building the TomEE server

Building our application

Starting the server.

The script will open the "index.html" page
We have some handy commands to start, stop and update your application.

  • "make kill-tomee" kills the TomEE server instance.
  • "make start-tomee" kills any running instance of TomEE, runs "mvn clean install -DskipTests=true" (20 seconds in my mv) and restarts the TomEE server (5 seconds in my vm).
  • "make up-static" replaces the JS code in the server.
  • "make run-jasmine" runs the JS unit tests.
  • "make clean" runs "mvn clean" and updates the TomEE/OpenEJB source code. If you run "make start-tomee" after "make clean", the script will rebuild the TomEE/OpenEJB server (12 minutes in my vm).
Lets test our application. Copy and paste these commands to a terminal.

cd ~/Pictures/ && \
wget https://dl.dropbox.com/u/1459144/posts/pele.jpg && \
nautilus pele.jpg 


Drag the picture to the browser

Photo uploaded!

Do you want to join the fun?
Learn more about the TomEE/OpenEJB server: http://tomee.apache.org/
Clone the photodb source-code: https://github.com/tveronezi/photodb

No comments:

Post a Comment