Maven JMeter plugin

Last Updated on Jeudi, 4 novembre 2010 06:14 Written by Henri Gomez Jeudi, 4 novembre 2010 06:13

While playing with JMeter Maven plugin, I got some problems :

First the official Jakarta plugin is pretty old and no more maintened.

So you should get a new one, from GoogleCode
This project moved to GitHub

Great project but it miss 2 dependencies, commons-logging and soap
Without commons-logging your tests may fail and you could see :

Error in NonGUIDriver java.lang.NullPointerException
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] There were test errors

The fix is easy, get the plugin project and add the following dependencies in it :

		<dependency>
			<groupId>soap</groupId>
			<artifactId>soap</artifactId>
			<version>2.3.1</version>
		</dependency>

		<dependency>
			<groupId>commons-logging</groupId>
			<artifactId>commons-logging</artifactId>
			<version>1.1.1</version>
		</dependency>

Just rebuild and install (or deploy), this updated plugin, may be changing it’s version from 1.0 to 1.1-SNAPSHOT to avoid conflict with current one.

Full pom.xml is here :

<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>org.apache.jmeter</groupId>
	<artifactId>maven-jmeter-plugin</artifactId>
	<packaging>maven-plugin</packaging>
	<version>1.0</version>
	<name>Maven JMeter Plugin</name>
	<url>http://jakarta.apache.org/jmeter</url>

	<dependencies>
		<dependency>
			<groupId>ant</groupId>
			<artifactId>ant</artifactId>
			<version>1.6</version>
		</dependency>
		<dependency>
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
			<version>1.2</version>
		</dependency>
		<dependency>
			<groupId>org.apache.maven</groupId>
			<artifactId>maven-plugin-api</artifactId>
			<version>2.0</version>
		</dependency>
		<dependency>
			<groupId>org.apache.maven</groupId>
			<artifactId>maven-project</artifactId>
			<version>2.0.9</version>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>3.8.1</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.jmeter</groupId>
			<artifactId>jmeter</artifactId>
			<version>2.3</version>
		</dependency>

		<dependency>
			<groupId>soap</groupId>
			<artifactId>soap</artifactId>
			<version>2.3.1</version>
		</dependency>

		<dependency>
			<groupId>commons-logging</groupId>
			<artifactId>commons-logging</artifactId>
			<version>1.1.1</version>
		</dependency>

		<dependency>
			<groupId>org.apache.jmeter</groupId>
			<artifactId>jmeter</artifactId>
			<version>2.3</version>
		</dependency>
		<dependency>
			<groupId>org.apache.maven.wagon</groupId>
			<artifactId>wagon-webdav</artifactId>
			<version>1.0-beta-2</version>
		</dependency>
	</dependencies>
	<distributionManagement>
		<repository>
			<id>central</id>
			<name>Gestalt Central Repo</name>
			<url>dav://artifactory.int.gestalt-llc.com:8080/archiva/repository/repo</url>
		</repository>

	</distributionManagement>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.0.2</version>
				<configuration>
					<source>1.5</source>
					<target>1.5</target>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>2.3</version>
			</plugin>
		</plugins>
	</build>
</project>

I hope this plugin will soon include these fixes and update JMeter to its latest version, 2.4 :)

Learn More

How to build Maven 3 from the trunk (and being on the leading edge)

Last Updated on Vendredi, 30 octobre 2009 07:00 Written by Henri Gomez Vendredi, 30 octobre 2009 07:00

Jason asked me to write a little article on how to build Maven 3, from the trunk.

Pre requisites
  • a decent operating system
  • subversion command line tools (ie: svn)
  • java 5
  • tar
  • maven 2.1 or higher
Prepare the landing zone

Create a directory to keep your works on maven, ie followthetrunk.

On my MBP, my home directory is under /Users/henri and I’ll create the followthetrunk on my Documents subdir.

cd /Users/henri/Documents
mkdir followthetrunk
cd followthetrunk
Get the source

Get the latest maven 3 sources from trunk with your subversion client.

svn co http://svn.apache.org/repos/asf/maven/maven-3/trunk/ maven-3

svn client will grab the sources :

A    maven-3/maven-embedder/src/examples/simple-project/src/test/java/org/apache
A    maven-3/maven-embedder/src/examples/simple-project/src/test/java/org/apache/maven
A    maven-3/maven-embedder/src/examples/simple-project/src/test/java/org/apache/maven/embedder
A    maven-3/maven-embedder/src/examples/simple-project/src/test/java/org/apache/maven/embedder/AppTest.java
A    maven-3/maven-embedder/src/examples/simple-project/src/main
A    maven-3/maven-embedder/src/examples/simple-project/src/main/java
A    maven-3/maven-embedder/src/examples/simple-project/src/main/java/org
A    maven-3/maven-embedder/src/examples/simple-project/src/main/java/org/apache
A    maven-3/maven-embedder/src/examples/simple-project/src/main/java/org/apache/maven
A    maven-3/maven-embedder/src/examples/simple-project/src/main/java/org/apache/maven/embedder
A    maven-3/maven-embedder/src/examples/simple-project/src/main/java/org/apache/maven/embedder/App.java
A    maven-3/maven-embedder/src/examples/simple-project/pom.xml
A    maven-3/maven-embedder/pom.xml
A    maven-3/maven-ant-tasks-2.1.0-SNAPSHOT.jar
 U   maven-3
Checked out revision 831368.

Note the revision number will probably be different when you’ll do the checkout

Check the source are here :

cd maven-3
ls

You should see :

README.bootstrap.txt			maven-artifact				maven-plugin-api
README.txt				maven-compat				maven-repository
apache-maven				maven-core				maven-settings
build.xml				maven-embedder				pom.xml
doap_Maven.rdf				maven-model				src
maven-ant-tasks-2.1.0-SNAPSHOT.jar	maven-model-builder			target
Build

The build is really easy if you have maven 2.1 or higher installed.

mvn clean install

You should see the build log and …

[INFO] [install:install]
[INFO] Installing /Users/henri/Documents/followthetrunk/maven-3/apache-maven/target/apache-maven-3.0-SNAPSHOT.jar to /Users/henri/.m2/repository/org/apache/maven/apache-maven/3.0-SNAPSHOT/apache-maven-3.0-SNAPSHOT.jar
[INFO] Installing /Users/henri/Documents/followthetrunk/maven-3/apache-maven/target/apache-maven-3.0-SNAPSHOT-bin.zip to /Users/henri/.m2/repository/org/apache/maven/apache-maven/3.0-SNAPSHOT/apache-maven-3.0-SNAPSHOT-bin.zip
[INFO] Installing /Users/henri/Documents/followthetrunk/maven-3/apache-maven/target/apache-maven-3.0-SNAPSHOT-bin.tar.gz to /Users/henri/.m2/repository/org/apache/maven/apache-maven/3.0-SNAPSHOT/apache-maven-3.0-SNAPSHOT-bin.tar.gz
[INFO]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] ------------------------------------------------------------------------
[INFO] Apache Maven 3.x ...................................... SUCCESS [4.065s]
[INFO] Maven Model ........................................... SUCCESS [5.458s]
[INFO] Maven Settings ........................................ SUCCESS [0.946s]
[INFO] Maven Artifact ........................................ SUCCESS [2.119s]
[INFO] Maven Plugin API ...................................... SUCCESS [1.212s]
[INFO] Maven Model Builder ................................... SUCCESS [3.510s]
[INFO] Maven Core ............................................ SUCCESS [16.065s]
[INFO] Maven Compat .......................................... SUCCESS [11.807s]
[INFO] Maven Embedder ........................................ SUCCESS [1.035s]
[INFO] Maven Distribution .................................... SUCCESS [4.967s]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 52 seconds
[INFO] Finished at: Fri Oct 30 17:55:49 CET 2009
[INFO] Final Memory: 56M/81M
[INFO] ------------------------------------------------------------------------

Here we are, your maven 3 build from the trunk is ready to use, present in your .m2 repository under org/apache/maven/apache-maven/3.0-SNAPSHOT, ie :

/Users/henri/.m2/repository/org/apache/maven/apache-maven/3.0-SNAPSHOT/apache-maven-3.0-SNAPSHOT-bin.tar.gz
Want to make a try ?

Of course :)

cd ..
tar xvzf /Users/henri/.m2/repository/org/apache/maven/apache-maven/3.0-SNAPSHOT/apache-maven-3.0-SNAPSHOT-bin.tar.gz

Check everything is at the right place

ls -l apache-maven-3.0-SNAPSHOT/
total 40
-rw-r--r--   1 henri  staff  11358 30 oct 17:16 LICENSE.txt
-rw-r--r--   1 henri  staff    909 30 oct 17:16 NOTICE.txt
-rw-r--r--   1 henri  staff   2597 30 oct 17:16 README.txt
drwxr-xr-x  10 henri  staff    340 30 oct 17:24 bin
drwxr-xr-x   3 henri  staff    102 30 oct 17:24 boot
drwxr-xr-x   3 henri  staff    102 30 oct 17:16 conf
drwxr-xr-x  25 henri  staff    850 30 oct 17:24 lib

Add the new maven 3.0-SNAPSHOT to path

export PATH=/Users/henri/Documents/followthetrunk/apache-maven-3.0-SNAPSHOT/bin:$PATH

And try it

mvn -v

You should see the long awaited version number (in my case from r831368)

Apache Maven 3.0-SNAPSHOT (r831368; 2009-10-30 17:21:17+0100)
Java version: 1.6.0_15
Java home: /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
Default locale: fr_FR, platform encoding: MacRoman
OS name: "mac os x" version: "10.6.1" arch: "x86_64" Family: "mac"

That’s all folks :)

Next article will cover how to build m2eclipse with your whole new Maven 3.0.

Learn More

Bundelisation d'un jar existant

Last Updated on Mardi, 17 février 2009 06:25 Written by Henri Gomez Mardi, 17 février 2009 06:25

Je cherchais depuis quelques temps une méthode simple pour bundleiser certains de nos artifact maven en bundle osgi.

Le problème ne se pose pas pour les projets sur lesquels nous avons les sources en insérant le plugin dans le cycle existant via :

<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">

<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
</plugin>

Cependant dès qu’on utilise des artifacts externes et sans sources, comme les jars jt400 ou mqseries, on a plusieurs possibilités

Inserer le MANIFEST dans un jar existant, délicat opération manuelle.
Utiliser eclipse pour refaire un plugin depuis un jar existant. Simple mais ne peut être industrialisé.
Utiliser le plugin maven-bundle-plugin.

C’est cette troisième voie que j’ai utilisé et de manière très simple :

- on définit un projet bundle
- on ajoute la dépendance à l’artifact que l’on souhaite bundliser
- on utilise maven-bundle-plugin avec Embed-Dependency en précisant inline=true

<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>com.mycorp</groupId>
<artifactId>net.sf.jt400</artifactId>
<packaging>bundle</packaging>
<name>net.sf.jt400</name>
<version>6.4.0</version>
<description>Bundle OSGI de JT400</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<export-Package>com.ibm.as400.*</export-Package>
<embed-Dependency>com.ibm.as400.*;scope=compile;inline=true</embed-Dependency>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>net.sf.jt400</groupId>
<artifactId>jt400-full</artifactId>
<version>6.4</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Learn More
Designed by RocketTheme
WordPress is Free Software released under the GNU/GPL License.