Resolving maven iTest plugin classpath dependency issues

I came accross an issue with using Renjin script engine in iTest plugin. Turns out that during initialization (i.e. ScriptEngineManager().getEngineByName("Renjin")), Renjin was swallowing an exception where a resource file it requires on the classpath was not found.

org.renjin.base.BaseFrame#load(Context context) uses Google Guava Commons IO to load the file "org/renjin/baseNamespace": Resources.getResource("org/renjin/baseNamespace");

The Resources class throws an exception when baseNamespace is not found. This was causing ScriptEngineManager to return null. The reason why Resources.getResource() cannot find the file is that Maven does not isolate plugins from the Maven classpath. Maven includes a copy of Google Guava, causing Renjin to default to that one, which is loaded in the parent classloader of the project.
Resources.gerResouces() does: Resources.class.getClassLoader().getResource(resourceName);

This means the resource will be searched using the parent classloader of the project, which does not have references to Renjin libraries.

A workaround is to place the Renjin libraries on the plugin classpath by adding a dependencies entry to the iTest plugin definition:

<build>
	<plugins>
		<plugin>
			<groupId>org.codehaus.fabric3</groupId>
			<artifactId>fabric3-itest-plugin</artifactId>
			<version>${fabric3.version}</version>
			<dependencies>
				<dependency>
					<groupId>org.renjin</groupId>
					<artifactId>renjin-script-engine</artifactId>
					<version>0.7.0-RC6</version>
				</dependency>
			</dependencies>
			<configuration>
				<runtimeVersion>${fabric3.version}</runtimeVersion>
				<shared>
					<dependency>
						<groupId>org.renjin</groupId>
						<artifactId>renjin-script-engine</artifactId>
						<version>0.7.0-RC6</version>
					</dependency>
				</shared>
				<systemConfig>
					<![CDATA[
					<config xmlns="urn:fabric3.org">
					<domain autowire="on"/>
					</config>
					]]>
				</systemConfig>
			</configuration>
			<executions>
				<execution>
					<goals>
						<goal>test</goal>
					</goals>
				</execution>
			</executions>
		</plugin>
	</plugins>
</build>

And also adding the bedatadriven repository to a pluginRepositories section in the pom:

<pluginRepositories>
	<pluginRepository>
		<id>bedatadriven</id>
		<name>bedatadriven public repo</name>
		<url>http://nexus.bedatadriven.com/content/groups/public/</url>
	</pluginRepository>
</pluginRepositories>