On 10/01/2012, at 12:20 AM, Farrukh Najmi wrote:

>>> I am trying to use javascript-maven-plugin. It seems cool though the 
>>> documentation seems to be fairly minimal.
>> Really? Are you looking at http://mojo.codehaus.org/javascript-maven-tools/ ?
> 
> I did see all the docs at above site. I am an experienced developer but I 
> still cannot figure out how I can have a js module be consumed by a separate 
> war module based on available docs. Thus I am thinking that the docs could 
> potentially be improved in this regard.
Could I get you to please raise a JIRA for this?

http://jira.codehaus.org/browse/MJS

>> 
>> Also, the project produced by the JS RIA archetype should help in terms of 
>> documentation (1).
> 
> I did generate a project using the archtype and it did not help in explaining 
> how to consume the generated project in a separate war project as a 
> dependency.
> I am currently using the maven-dependency-plugin in my war project like this:
> 
>             <plugin>
>                 <artifactId>maven-dependency-plugin</artifactId>
>                 <executions>                    
>                     <execution>
>                         <id>copy-js-deps</id>
>                         <phase>generate-sources</phase>
>                         <goals>
>                             <goal>copy-dependencies</goal>
>                         </goals>
>                         <configuration>
>                             <includeTypes>js</includeTypes>
>                             
> <outputDirectory>${basedir}/target/classes/js</outputDirectory>
>                         </configuration>
>                     </execution>
>                     
>                 </executions>
>             </plugin>
> 
> Is this the best way?
May be. :-)

Incidentally, if you were building a single page HTML/CSS/JS app and wanted to 
deploy that as a war then your assembly descriptor may look like the following:

<assembly>
        <id>www</id>
        <formats>
                <format>war</format>
        </formats>
        <fileSets>
                <fileSet>
                        <directory>${basedir}/src/main/webapp</directory>
                        <outputDirectory>/</outputDirectory>
                </fileSet>
        </fileSets>
</assembly>

> 
> Also, I have js script files referenced in FreeMarker templates in the war 
> project like this:
> ...
> 
> This requires that I use maven-resource-plugin using snippet below to filter 
> the FreeMarker templates in my project to fix the versions for the js file 
> dependencies. Is there a better way? 
> 
>         <resources>
>             <resource>
>                 <directory>src/main/resources</directory>
>                 <filtering>true</filtering>
>             </resource>
>         </resources>
> 
> Again this could be a topic to address in the docs.
MJS is really heavily focused on writing "single page HTML apps" (RIAs) and 
libraries. It can probably be used as a hybrid approach with server side 
templating, but I don't have strong thoughts on the best practices there yet.

> 
>>> Can someone please tell me:
>>> How do I consume a module of <type>js</type> produced by 
>>> javascript-maven-plugin in a module of <type>war</type>
>> The trick here is to use the assembly plugin. You need to have a 
>> <type>js</type> module and then have an assembly.xml that produces a war 
>> artifact.
>>> Which modules need the javascript-maven-plugin build extension. Is it just 
>>> the js module or also the war module?
>> You can have a separate war module if you want. However using an assembly 
>> requires just the one module to produce the js.
> 
> I definitely have a need for separate war module because that is how my large 
> project is structured and I do not want to change that.
Perhaps have a js or -www.zip producing module (the latter to bundle images 
etc. if required) and consume that zip from your war module. You then declare 
the module as a dependency and include it explicitly in the manner you 
illustrate above.

> 
>>> Is there any other resource on using the javascript-maven-plugin in a large 
>>> multi-module project
>> The javascript-maven-tools project has a number of js modules itself (2) and 
>> is a reasonable example. I've personally used javascript-maven-plugin in a 
>> multi module js/war/ear project. It should look and behave no differently to 
>> any other Maven module.
> 
> 
> I guess what I was thinking was that I would simply add the js project as a 
> dependency of my war project and maven build would take care of copying the 
> .js file for my project and its dependencies to the correct places in the war 
> without my doing anything. Is this the correct expectation?
That should work. Your js project, given the automatic inclusion of 
webminifier, will produce a single .js file or a -www.zip file. You should then 
be able to bring in that dependency to your war project. The files will end up 
in your war module's target/classes folder.


> 
> A little more explicit help on how to consume a js project in a separate war 
> project would be very helpful still if you could spare the time. And I think 
> including such info in the 
> http://mojo.codehaus.org/javascript-maven-tools/index.html page would be a 
> terrific. 
This is a use-case that I've not really focused on so far. In essence though, 
having typed this through now, I think what you're needing to do is think of 
your JS code as a js library to your war module.

> 
>> 
>>> Any ETA for when javascript-maven-plugin 2.0.0 will be released
>> I've pushed for the two remaining snapshot project dependencies it has (js 
>> import and web minifier) to go 1.0. Looks as though the voting is going well 
>> and I should be able to release them next week.
>> 
>> The only thing then is what to do about m2e integration. We've been working 
>> on a high degree of compatibility with m2e but, quite honestly, we're 
>> finding this a challenge. We might abandon the m2e integration for the 
>> release of 2.0.0 as it is becoming a stopper for us.
> 
> +1 for deferring m2e integration. There are many folks who have no need for 
> m2e. The project would get more usage and generate more feedback with a 
> release 2.0.0.
The two other projects have now gone 1.0. I am waiting on another committer to 
come back from holiday before making a call on this. 2.0 should be released 
within the next couple of weeks though.

> Best wishes for the release and warm appreciation for this good work.
Thanks!

Reply via email to