Building and installing GateIn from the source code

Another way to install GateIn is by getting the source code from the JBoss SVN repository and then compiling it to generate the build artifacts as you found in the binary package.

The goal of building GateIn from the source code is to have the possibility to freely customize it. Another useful reason for building from source is that you simply want to contribute to the project and test your fixes before applying the patch on the issue tracker.

Note

Notice that this book is based on GateIn 3.2.0, which has its source code based on the SVN repository. From GateIn 3.3.x the source code is based on a GitHub repository. For more information about how to build from GitHub, please see https://github.com/gatein/gatein-portal.

Getting ready

Let's first see if you have installed in your machine the following needed components:

  • Java Development Kit (JDK) 1.6
  • Subversion client (SVN)
  • Apache Maven 3.x

Let's check your environment for the see following required tools:

  1. You can test and install JDK 1.6 following the Getting ready section of the Installing GateIn from a binary package recipe.
  2. To test if the SVN client is installed in your machine run the following command line:
    svn --version
    

    If the SVN client is correctly installed you should see output similar to the following:

    svn, version 1.6.17 (r1128011)
       compiled Aug 25 2011, 17:31:03
    Copyright (C) 2000-2009 CollabNet.
    Subversion is open source software, see http://subversion.apache.org/
    

    If the svn command is not found in the scope of your operating system, then you can install it by following the instructions available on the official website, depending on your operating system, at http://subversion.apache.org/packages.html.

  3. Once the SVN client is installed, the next step is to test if Apache Maven is installed on your machine, by running the following command line:
    mvn --version
    

    After running the command, you should see an output similar to the following:

    Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
    Maven home: /Users/piergiorgiolucidi/tools/apache-maven-3.0.4
    Java version: 1.6.0_29, vendor: Apple Inc.
    Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    Default locale: it_IT, platform encoding: MacRoman
    OS name: "mac os x", version: "10.6.8", arch: "x86_64", family: "mac"
    

    If the mvn command is not found in your machine then it could mean either of the following two things:

    • You have to configure the PATH environment variable
    • You have to install Apache Maven from scratch

    We are going to assume that maven is not installed. In this way, we will describe both the cases:

    • Download the Apache Maven binary at http://maven.apache.org/download.html.
    • Extract the binary package and follow the specific instructions that are described in the web page according to your operating system.

      Notice that you have to set two environment variables to allow Maven to work correctly, so please be sure to set the PATH and M2 variables before continuing. For instance, for a Linux-based operating system, you should have a snippet in your profile configuration file similar to the following:

      export M2_HOME="/Users/piergiorgiolucidi/tools/apache-maven-3.0.4"
      export M2=$M2_HOME/bin
      export MAVEN_OPTS="-Xms512m -Xmx1024m -Xss1024k -XX:MaxPermSize=256m -XX:NewSize=256m"
      export PATH=$M2:$PATH
      
  4. Finally, check if you have installed the latest stable release of Apache Maven before continuing the recipe.

How to do it...

Now we are ready to check out the source code. For this book, we will consider the current latest stable version of GateIn Portal, which is version 3.2.0.

  1. Check out the code on your machine by executing the following comman line:
    svn checkout http://anonsvn.jboss.org/repos/gatein/portal/tags/3.2.0-GA/ gatein-portal-3.2.0
    
  2. Once you have finished the download, you will find a new subfolder gatein-portal-3.2.0 in the folder where you have executed the command that contains all the source code of the project.
  3. Now we are ready to build the project using Apache Maven. For this step, we have some parameters to set:
    • Which type of bundle you have
    • Whether the build process must download the application server distribution
    • The path of the root folder of your application server distributions (if you have an existing distribution package)
    • The name of the folder related to the application server distribution to use for building
  4. Let's assume that you want to build GateIn with the Tomcat 6 bundle and, considering that the Tomcat distribution is stored in the /Applications/Apache Tomcat/apache-tomcat-6.0.32 folder, you have to execute the following command line from the root folder of the project that contains the main pom.xml file:
    mvn clean install -DskipTests -Ppkg-tomcat -Dexo.projects.directory.dependencies=/Applications/Apache Tomcat -Dexo.projects.app.tomcat.version=apache-tomcat-6.0.32
    

    Upon completion, you should see the following output:

    [INFO] -------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] -------------------------------------------
    

    The binary artifacts will be available on your machine inside the /gatein-portal-3.2.0/packaging/tomcat/pkg/tc6/target/tomcat6 folder.

How it works...

As you have seen, the GateIn packaging process relies upon Apache Maven to execute the build process of the project. However, Maven allows you to manage the entire lifecycle process of the project and its own children modules by starting a command from a parent Project Object Model (POM).

In this recipe, we have invoked two Maven phases to execute the build process of the project—the clean phase and the install phase.

The clean phase will remove all the compiled artifacts created by prior builds to initialize the build state of the project. Typically, the final result of the clean goal is that the target folder will be removed for each submodule of the project.

The install phase will start the complete Maven lifecycle executing all the phases up to install. The details of this execution process are as follows:

  1. Validate
  2. Compile
  3. Test
  4. Package
  5. Integration-test
  6. Verify
  7. Install

Each phase is responsible for specific goals that need to be processed before the next phase.

The parameter skipTests used in the previous Maven command allows skipping the execution of tests from the lifecycle process. This means that when Maven is executing, the entire process will skip the execution of the test phase for each module.

So if you want to contribute to the project or you are customizing the product for your needs, you will probably want to remove this parameter. This is because if you want to be sure that your own implementation correctly works with all the other modules included in GateIn, you probably want to execute all the tests included in the project.

See also

  • The Installing GateIn from a binary package recipe
  • The Running GateIn on your machine recipe
  • The Setting up the development environment recipe
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.188.238