Maven 2: A brief introduction

The DRAGOS database management system is build using Maven 2. Thus a short introduction into Maven 2 is given in the following.

Basically, Maven 2 is life cycle oriented. Thus, for each life cycle step a corresponding goal exists.

Life CycleMaven goalDescription
BuildcompileCompiles the entire project
TesttestRuns the test suite to find errors
InstallinstallInstalls the project in the local repository
DeploydeployDeploys the project on the server repository
DocumentationsiteGenerates the project documentation
Clean UpcleanRemoves everything generated by the previous goals

Except the last to goals, every of these goal ensures that previous goals do not fail. For example, if the goal deploy is used the project must compile correctly, pass the test suite, and is installed in the local repository.

Besides these life cycle oriented goals, Maven 2 still supports plug-ins, which can be called immediately. Some useful plug-in goals are the following:

Plug-in GoalDescription
eclipse:eclipseGenerates all files which are required to import the
project into Eclipse.

Reproducible builds via profiles

One of the major advantages of Maven 2 is the ability to produce reproducible builds. For this the different properties which are used by DRAGOS are defined in the POM itself (and not in different files as with Maven 1). To override these values every developer should use profiles.

A simple example for a profile is shown below:

<profiles>
  <profile>
    <id>nightly-build</id>
    <properties>
      <dragos.testcase.transactionmanager>
        i3.dragos.core.services.transactions.localmgr.LocalTransactionManager
      </dragos.testcase.transactionmanager>
      <dragos.testcase.transactionmanager.testnested>
        true
      </dragos.testcase.transactionmanager.testnested>
      <dragos.testcase.transactionmanager.testsemantics>
        true
      </dragos.testcase.transactionmanager.testsemantics>
      <dragos.test.override>
        false
      </dragos.test.override>
      <dragos.testcase.dburl>
        jdbc:postgresql://grasgxl@localhost/dragos-nightly-build
      </dragos.testcase.dburl>
    </properties>
  </profile>
</profiles>

Profiles are defined in the file profiles.xml which is located in the project's root directory. The file can defined an arbitrary number of profiles, which are identified by their id. In the previous example the profile nightly-build is defined, which is used by dragos-db-psql to execute the nightly builds. In contrast to the original properties defined in the POM of dragos-db-psql only the property dragos.testcase.dburl was modified. Thus, instead of redefining all properties a simpler profile can be used:

<profiles>
  <profile>
    <id>nightly-build</id>
    <properties>
      <dragos.testcase.dburl>
        jdbc:postgresql://grasgxl@localhost/dragos-nightly-build
      </dragos.testcase.dburl>
    </properties>
  </profile>
</profiles>

By default, the properties defined in the POM are used. To use the previously defined profile, Maven 2 has to be called as follows:

mvn -P nightly-build <goal>

If more than one profile should be used a comma-separated listed can be used.

Continuous Integration

DRAGOS uses Continuum to detect errors between the different projects as early as possible. In addition, our Continuum installation ensures that you always get the latest working version of DRAGOS.

Our Continuum installation allows you to monitor the current status of the different DRAGOS projects. In addition, you can force a build of your project if necessary.

Deploying your build

For deploying either your build or the generated web site you must define which user name and SSH authentication should be used. You do this by creating the file $HOME/.m2/settings.xml similar to this one:

<settings>

  <servers>
    <server>
      <id>i3</id>
      <username>maven</username>
      <privateKey>your_home/.ssh/id_rsa</privateKey>
    </server>

    <server>
      <id>www-i3</id>
      <username>www-data</username>
      <password>???</password>
    </server>
  </servers>

</settings>

Further references

For more information on Maven read the following documents: