I’m primarily a JS developer in the process of learning Maven as I move from a Rails house to a Java shop. The folks at Codehaus have been a huge help in providing a Maven archetype to guide folks like me in understanding how we can leverage Maven to manage dependencies in our codebase:
http://mojo.codehaus.org/javascript-maven-tools/javascript-ria-archetype/index.html
I mostly understand what they’re doing now, but there’s one piece they don’t explain and I can’t figure out where the magic happens.
In the index.html file of their sample RIA app, there’s only one line in the HTML to include all the JavaScript:
<script type="text/javascript" src="${index.js}"></script>
When I run > mvn jetty:run on the command line as they suggest to launch the test webapp, the ${index.js} value is getting replaced with ALL the JS files up the entire dependency tree that are required for the app to function.
Which is great, but I just don’t know what part of the process is DOING it. Can anyone more familiar with this architecture explain it to me? Thanks so much!
Dave Newton got me on the right track in his comment to my question. The answer is described in the documentation here:
http://mojo.codehaus.org/js-import-maven-plugin/usage.html
The
JS Import Maven Pluginthat has the artifactId ofjavascript-maven-pluginunder extensions in the POM of the Codehaus sample RIA app is responsible for taking the#{index.js}string in the index.html file, descending the dependency tree starting with the index.js file, and automatically injecting all dependencies into the HTML. The exact mechanism the plugin uses for discovering the JS dependencies is described in the usage documentation linked above.