Maven-specific information

This topic provides some advanced information related to building with Maven 2.

Maven profiles

It is sometimes required to distinguish between running the builds on a developer's machine and running them inside Polarion. For this, Maven's concept of profiles can be used (more information is available athttp://maven.apache.org/guides/introduction/introduction-to-profiles.html ). There are several ways to define profiles, but here is the use of global profiles defined in C:/Polarion/maven/settings.xml. Just add new profiles to the ones already there):

<profile>
    <id>development</id>
    <properties>
        <somePathProperty>FOLDER_ON_DEVELOPERS_MACHINE</somePathProperty>
    </properties>
    <id>polarion</id>
    <properties>
        <somePathProperty>FOLDER_ON_POLARION_MACHINE</somePathProperty>
    </properties>
</profile>

If developer runs this in stand-alone Maven with argument -P development, then the build will have a property somePathProperty pointing to a folder on developer's machine. If it is run inside Polarion, and build property polarion.build.maven.active.profiles is set to polarion, then the somePathProperty property will point to a folder on the Polarion server.

Maven proxy

To minimize connections to the central Maven repository (by other means than by using potentially dangerous polarion.build.shared.local.repository), it is recommended to use Maven proxy (see http://maven-proxy.codehaus.org/). If you have trouble installing the proxy, check http://codeforfun.wordpress.com/2006/05/24/maven-proxy/ and http://codeforfun.wordpress.com/2006/09/11/maven-proxy-details/ for information. Once you have the proxy installed, just edit C:/Polarion/maven/settings.xml and add a new <mirror> section. For example:

<settings>
  <localRepository>C:/Polarion/data/maven-repo</localRepository>
  <mirrors>
    <mirror>
      <mirrorOf>central</mirrorOf>
      <id>central-mirror</id>
      <name>Mirror of Central Repo</name>
      <url>http://PROXY_HOST:PROXY_PORT/PROXY_PREFIX/repository</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>polarion-bundled</id>
      <repositories>
        <repository>
          <id>polarion-bundled</id>
          <url>file:///C:/Polarion/maven/repository</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>polarion-bundled</id>
          <url>file:///C:/Polarion/maven/repository</url>
        </pluginRepository>
      </pluginRepositories>
    </profile>
    <profile>
      <id>polarion-shared</id>
      <repositories>
        <repository>
          <id>polarion-shared</id>
          <url>file:///C:/Polarion/data/shared-maven-repo</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>polarion-shared</id>
          <url>file:///C:/Polarion/data/shared-maven-repo</url>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>polarion-bundled</activeProfile>
    <activeProfile>polarion-shared</activeProfile>
  </activeProfiles>
</settings>

For more information about mirrors see http://maven.apache.org/guides/mini/guide-mirror-settings.html.

Maven repositories

One local and two remote repositories are configured:

  • Local repository at C:/Polarion/data/maven-repo is used by calculations and can be emptied at will. (Builds each have their own located in their job's working directory. Build property polarion.build.shared.local.repository can be set to true to have this for builds as well, but be warned that it may have undesirable side effects.)

  • Remote repository polarion-bundled (at C:/Polarion/maven/repository) contains some bundled third party plugins and projects (as well as plugins and projects required for Polarion to work) to minimize connections to Maven's central repository.

  • Remote repository polarion-shared (at C:/Polarion/data/shared-maven-repo) is fully under user's control and is intended for deployment of projects (this is configured by default to be the default deployment repository - see build properties polarion.build.default.deploy.repository.id and polarion.build.default.deploy.repository.url). It is also accessible via http://YOUR_SERVER_URL/maven2/.

Comparison with stand-alone Maven

There is no difference (except for additional configuration which can change the behavior) between running stand-alone Maven 2 tool and running a build with external Maven.

Embedded Maven is significantly different because it is a development version in a frozen state, and is carefully balanced to work with bundled plugins. Using it for builds is discouraged.

Under the hood

Maven 2 is a core piece of the Polarion build management system. All builds and calculations are routed through it. Embedded Maven is version 2.1, bundled external Maven is version 2.0 (installed at C:/Polarion/maven/distribution).

If something fails and it is not clear why, then it is recommended to go to the working directory of the build's job, find pom.xml (even if the build was not a Maven build) and see what is inside that could cause something to go wrong.

Plugin registry is at C:/Polarion/maven/plugin-registry.xml, settings are at C:/Polarion/maven/settings.xml. Both files can be freely changed, or other files can be used (see build properties polarion.build.maven.settings.* and polarion.build.maven.plugin.registry.*).

Import Test Case run during Builds

When tests are run during a standard Maven build, they can be automatically imported as a Test Run when properties in .polarion\builder\build.properties are set. It is possible to fill some Test Run fields from an xUnit file name using regular expressions (regex).

For information, see Test Management Reference