Globalyzer Maven Support
Lingoport provides the ability to run Globalyzer from within the Maven build tool to allow you
to integrate Globalyzer functionality into your build/integration
process. This help tells you how to enable Globalyzer with Maven, describes the available
tasks, and gives example usages.
Enabling Globalyzer for Maven
All Globalyzer Ant tasks are available in
Maven through the Maven AntRun
plugin.
To use Globalyzer from Maven,
you will need to define a project property with the id
globalyzer.install.path
that points to the directory where the Globalyzer Client has been
installed. The following listing gives an example of defining this
on a Windows machine with the Globalyzer Client installed to the
default location:
<!-- Define installation
location --> <properties>
<globalyzer.install.dir>C:/Program Files/Lingoport/Globalyzer
4.2</globalyzer.install.dir> </properties>
The following tasks are defined for the Globalyzer Ant
library, but can be executed by the Maven AntRun plugin:
- globalyzer-list-projects
- globalyzer-list-scans
- globalyzer-list-rulesets
- globalyzer-list-reports
- globalyzer-scan
- globalyzer-scan-history
- globalyzer-scan-diff
- globalyzer-delete-scan-results
- globalyzer-delete-project
- globalyzer-run-report
- globalyzer-export
- globalyzer-import
The AntRun plugin is defined using a <build> element as
follows:
<taskdef
name="globalyzer-export" <build> <plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions> ...... </executions> </plugin>
</plugins> </build>
Important Note: If you are going to run Globalyzer
Ant tasks from a directory other than the Globalyzer
Client program directory
(where you installed Globalyzer), you must
use the logfile or logurl attribute with all
ant globalyzer tasks so that they have access to Globalyzer's
log4j.properties file. See the Command
Line Client help for more information on using this option as well
as on changing the Globalyzer data directory from its [userhome]./globalyzer
default location by using the datadir attribute.
To run one of these Globalyzer tasks, you must first add a
taskdef
element to the AntRun plugin section to associate the task with its
corresponding class, as in the example below for the
globalyzer-export
task:
<taskdef
name="globalyzer-export"
classname="com.lingoport.scanner.ui.ant.GlobalyzerExportScanTask"
classpathref="globalyzer.install.path"/>
It is recommended that you import these definitions from the
provided file globalyzer-typedefs.xml, as shown here:
<taskdef
file="${globalyzer.install.dir}/globalyzer-typedefs.xml"
format="xml"/>
The Globalyzer Ant tasks are defined in the AntRun plugin
<execution> element. For example:
<execution>
<id>globalyzer-list-projects</id>
<phase>compile</phase> <configuration>
<tasks> <property name="globalyzer.install.dir"
value="${globalyzer.install.dir}/"/> <path
id="globalyzer.install.path"> <fileset
dir="${globalyzer.install.dir}" includes="**/*.jar"/>
</path> <taskdef
file="${globalyzer.install.dir}/globalyzer-typedefs.xml"
format="xml"/> <globalyzer-list-projects
classpathref="globalyzer.install.path" />
</tasks> </configuration>
<goals><goal>run</goal></goals>
</execution>
For help on Globalyzer Ant tasks please see Globalyzer
Ant Client.
Globalyzer Maven Task Example
Following is an example Maven pom.xml file with Globalyzer
Maven AntRun plugin Ant tasks:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>globalyzer-maven</groupId>
<artifactId>maven-examples</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Maven examples of calling Globalyzer CLI function from
maven using Ant plugin</name>
<url>http://maven.apache.org</url>
<!-- Define installation location -->
<properties>
<globalyzer.install.dir>D:/Globalyzer
4.2</globalyzer.install.dir> </properties>
<!-- Define Maven Ant plugin that executes Globalyzer
Ant tasks --> <build>
<plugins> <plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>globalyzer-list-projects</id>
<phase>compile</phase>
<configuration>
<tasks>
<property name="globalyzer.install.dir"
value="${globalyzer.install.dir}/"/>
<path id="globalyzer.install.path">
<fileset dir="${globalyzer.install.dir}"
includes="**/*.jar"/> </path>
<taskdef
file="${globalyzer.install.dir}/globalyzer-typedefs.xml"
format="xml"/>
<globalyzer-list-projects
classpathref="globalyzer.install.path" />
</tasks>
</configuration>
<goals><goal>run</goal></goals>
</execution>
<execution>
<id>globalyzer-delete-scan-results</id>
<phase>compile</phase>
<configuration>
<tasks>
<property name="globalyzer.install.dir"
value="${globalyzer.install.dir}/"/>
<path id="globalyzer.install.path">
<fileset dir="${globalyzer.install.dir}"
includes="**/*.jar"/> </path>
<taskdef
file="${globalyzer.install.dir}/globalyzer-typedefs.xml"
format="xml"/>
<globalyzer-delete-scan-results
project-name="SmokeProject" classpathref="globalyzer.install.path"
/> </tasks>
</configuration>
<goals><goal>run</goal></goals>
</execution>
<execution>
<id>globalyzer-scan</id>
<phase>compile</phase>
<configuration>
<tasks>
<property name="globalyzer.install.dir"
value="${globalyzer.install.dir}/"/>
<path id="globalyzer.install.path">
<fileset dir="${globalyzer.install.dir}"
includes="**/*.jar"/> </path>
<taskdef
file="${globalyzer.install.dir}/globalyzer-typedefs.xml"
format="xml"/> <globalyzer-scan
project-name="SmokeProject" verbose="true"
server="http://lingoport.server/gzserver"
user="user@lingoport.com" password="password"
classpathref="globalyzer.install.path">
<jvmarg value="-Xmx512m" />
</globalyzer-scan>
</tasks>
</configuration>
<goals><goal>run</goal></goals>
</execution>
</executions>
</plugin> </plugins>
</build> </project>
|