searls/jasmine-maven-plugin — pull request #70 by m0rjc (2012-03-20 16:37:19+00:00)
Title: Make resources on the Maven Test Classpath available to the Test Runner

Requirement
------------------

We have Javascript code distributed amongst many Maven artefacts, for example an artefact dedicated to the Sencha Ext-JS framework, and artefact containing our own Ext-JS controls.
We use Web Fragments which place resources in META-INF/resources and, for testing use, we have artefacts such as a sinon.jar which contains sinon.js.

When running unit tests we want to be able to run and test code that depends on code in other Maven artefacts.

Solution
------------

We have extended the TestMojo by intercepting HttpUnit's WebRequest to recognise a certain URL pattern. If the pattern is seen then an URLClassLoader is used to find the resource.

Inside our POMs we have changed our preloadSources to have:

````xml

http://maven.test.dependencies/META-INF/resources/extjs/ext-all-dev.js
http://maven.test.dependencies/META-INF/resources/U4/src/u4.js
http://maven.test.dependencies/sinon.js

````

The special name "maven.test.dependencies" can be changed using a configuration option "fakeServerHostName" if you desire.

The dependencies are defined in the POM in the normal way, for example

````xml

org.sinon
sinon
1.3.1
test

````

The code will pull in Test, Compile and Runtime dependencies as well as the target/*/classes directories of the current project.