Java EE Continuous Integration powered by Maven & Glassfish
Can you compile, deploy and test your Java EE projects with just
1 line of command? Check it out.
I have no time for documentations lately, but I prefer to give
you a chance to early adopt my build script and take your own
conclusions. Following the steps below, you will have my Java EE 5
application running in your Glassfish v2.1 server - including test data
populated in the MySql database.
What the script do is:
- Compile, do unit tests and pack the href="http://kenai.com/projects/puj/pages/Home">Arena-PUJ Project.
- Deploy the RESTful web-service. (
- Populate the MySql with the test data.
- Execute the integration tests
- Deploy the DWR web application (
commands powered by Shell Script and the href="http://maven.apache.org/plugins/maven-antrun-plugin/">
. You can href="http://kenai.com/projects/puj/sources/arena/show">checkout
the project with all artifacts and ask me if you have any suggestion or
doubts. Have fun :)
Important: the current version of the
script only works on UNIX-like machines because it uses
Shell Scripts. I created and tested the script on the Ubuntu OS and I
interest time to translate it for a DOS
*.bat). So if you are using Windows, sorry but your
blog reading finishes here. If you are a Windows user and you would like
to contribue with a BAT file, please send that to me and you will
receive the proper credits - it may be a good contribution to my href="http://kenai.com/projects/puj/pages/Home">pet project.
No, you can't skip these non pleasant steps, but at least you
need to do it just once.
Check if you have all software you need:
- Java 6.x
- MySql 5.x
v2.1 * the ones living in the future can try the latest
and please do contribute with the href="https://glassfish.dev.java.net/quality/">FishCat if you find
After installing everything, startup the database and the
application server. Open a terminal and type:
sudo service mysql start
* By default MySql will be already
running as service, so you probably can skip the first step.
Creating the passwords file and the
For portability and obvious security reason, I couldn't type the
password direct on the script, so I let the users to use their own local
passwords. Due to that reason you have one more boring step to proceed:
to create a passwords file and save it as
containing the following property values:
Known limitations: the current Java code of
Arena-PUJ only works for IMAP secure SMTP servers. I plan to review the
code making it more generic, but for now it is guarantee to work only
with a GMail-like SMTP server. I couldn't find an elegant way of using
the AntRun plugin with the Shell Script, so I hard coded the
in the script. Despite that, if you invoke it by line command, you can
pass an argument with the name of the passwords file - I just couldn't
get it working smoothly with the Maven plugin :(. The project should
work with other databases, since I am not using any MySql specific trick
in the domain model - but I never tried and I can't guarantee if it will
really be portable for other DBs. You need at least to update the
deployment descriptors if you plan to test it on other Java EE Servers
and the persistence.xml if you will use other Database - and please tell
my if you want to try it, I am very interested about the results.
Building and deploying
After installing the software and creating your configuration
file, the good news: your job is done, now it is time for my magic
script to show its strengths. Open a terminal and type the following
hg clone https://hg.kenai.com/hg/puj~arena
mvn clean install
Now you take a coffe, watch the screen and smile - it is time to
see why Glassfish is my preferred Application Server :)
Integrating with Hudson
The built system presented here is a pure Maven Script so it is
piece of cake to create a Hudson job to run the script. You can href="http://fgaucho.dyndns.org:8080/hudson/job/arena-puj/">see
here the build history of the Arena-PUJ.
If you know me you know how I hate manual configuration steps and
other traps the big commercial projects impose in our lives. To make my
own and small project clean and easy is the minimum my slim ego requires
to continue with me - but I have just few spare hours a week to push
this pet project to a higher level so I appreciate any enhancements and
suggestions you can bring to me. It is a new project and I am pretty
sure it will get much better in the near future. All commands in the
build script can be done through the Glassfish Administration Console -
it contains no magic secrets actually.
This beautiful piece of configuration was made better due to the
tips and discussions in the Brazilian Java Community and always with the
friendly support from the Glassfish's team. My best thanks for all of
you and a special kudo to href="http://www.linkedin.com/in/marciocorreia">M