• Home
  • RSS Feed
  • Log in


Using FitNesse with the Maven 2 classpath
Posted by Marco Mulder mid-morning: December 16th, 2008

When working with Maven 2 and FitNesse, it is desirable to use the Maven classpath in FitNesse. The FitNesse Maven plugin can do this for running tests in a build, but not for using FitNesse interactively.

While googling for a solution, the first hit that I got which addresses this problem is a blog by my fellow Xebian Erik Pragt. A drawback of his approach is that it does not handle transitive dependencies. Therefore, I found the need to write my own script. It uses a technology that is a little less groovy than what Erik used. But that did not stop me for wanting to share it with you, so here it is:

#!/bin/bash

CLASSPATH_PAGE=FitNesseRoot/MyTests/content.txt
echo "!contents" > $CLASSPATH_PAGE
echo >> $CLASSPATH_PAGE

# First add the output folder of the fitnesse project to the classpath
echo "!path target/classes"  >> $CLASSPATH_PAGE

# Then add the output folders of the other projects
for i in `ls ../*/target/classes | grep "target/classes:" | tr ":" " "`
do
    echo "!path ${i}" >> $CLASSPATH_PAGE
done
echo >> $CLASSPATH_PAGE

# Then output the jars on the maven classpath
mvn dependency:build-classpath | grep -v INFO | grep -v Downloading \
    | tr ":" "\n" | sed "s/^/-path /" | sed "s/.*\.m2\/repository/!path \${MAVEN_REPO}/" \
    >> $CLASSPATH_PAGE

Before using it, please note the following:

  • The script generates a page with classpath entries on a location specified by CLASSPATH_PAGE. You have to change the CLASSPATH_PAGE to your own page.
  • The generated classpath assumes that Java system property MAVEN_REPO is set. This can be done by updating the FitNesse run.sh script to include -DMAVEN_REPO=`echo ~/.m2/repository/`.

I tried to translate it to a Windows script but ran into the problem that the Maven classpath was bigger than the Windows limitation of 8192 characters. If you find a solution for this (other than using Cygwin), please share it!

Share

Filed under Java | 2 Comments »



2 Responses to “Using FitNesse with the Maven 2 classpath”



    Erik Pragt Says:
    Posted at: December 16, 2008 at 10:32 am

    Hi Marco,

    Nice solution! I fixed the transitive dependencies in my script by removing the script, and creating a Groovy Maven plugin for it. I never published it, since it was so small.

    Nice work. And for your classpath issue: how about dropping some dependencies??

    Erik

    Reply


    Nils-H Says:
    Posted at: December 16, 2008 at 11:52 pm

    A couple of similar attempts:

    http://brodwall.com/johannes/blog/2008/03/19/some-fitnesse-tricks-classpath-and-debugging/

    http://boss.bekk.no/fitnesse-pom-widget/

    Reply


Leave a Reply

Click here to cancel reply.


Xebia Sites

  • Xebia Corporate
  • Xebia France
  • Xebia India
  • Xebia Sweden

Categories

  • Java (311)
  • Agile (181)
  • General (136)
  • Scrum (67)
  • Architecture (64)
  • Testing (59)
  • Performance (46)
  • Middleware (56)
    • Deployment (38)
  • Xebia Labs (39)
  • SOA (31)
  • Podcast (31)
  • Project Management (28)
  • Tools (26)
  • Uncategorized (20)
  • lean architecture (20)
  • Quality Assurance (17)
  • Articles (13)
  • Requirements Management (13)
  • Virtualization (19)

Tag Cloud

    Scala SOA Frameworks Flex lean architecture Lean XML Moving to India Architecture Grails Java Xebia Scrum ACT Concurrency Control lean architectuur Spring product owner agile architectuur Javascript Agile TDD JPA implementation patterns Eclipse Oracle JPA Hibernate Groovy Ajax Maven

Archives

  • February 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • June 2011
  • May 2011
  • April 2011
  • March 2011
Avatars by Sterling Adventures