You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by David Harkness <dh...@google.com> on 2008/01/12 00:13:29 UTC

Packaging HTML/JavaScript files into WAR from outside project

Greetings all,

I've used Maven on a couple projects -- just enough to get by and
build a webapp -- and I've got an issue I can't find a solution to. I
have a non-maven project (Shindig in Apache incubator) that contains
implementations in various languages (Java and PHP so far). They all
share common HTML and JavaScript files in parallel directories, and
the Java implementation is Mavenized:

  shindig/
    html/
    javascript/
    java/
      pom.xml
      src/
        main/
          webapp/
    php/

When building the java webapp, I'd like some HTML and JS files to be
packaged into the WAR, but those files live in the "html" and
"javascript" directories instead of in "java/src/main/webapp". What's
the appropriate plugin to use in this case?

On a side note, there are other JavaScript files from those same
directories that get packaged into "WEB-INF/classes" since they need
to be available as resources to the Java code and not as files via
HTTP. This works great, and I want something similar that makes them
available via HTTP instead of to the Java code.

Thanks,
Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Packaging HTML/JavaScript files into WAR from outside project

Posted by Insitu <ab...@oqube.com>.
>
> When building the java webapp, I'd like some HTML and JS files to be
> packaged into the WAR, but those files live in the "html" and
> "javascript" directories instead of in "java/src/main/webapp". What's
> the appropriate plugin to use in this case?
>

Hello,
Don't know if it's possible, but the "preferred maven way" I think
would be to package them into separate maven projects, of war type,
and use the implicit mechanism of war overlays: just add wars as
dependencies in your main war and you'll get everything packed
in. 

Alternatively, you could use maven-dependency-plugin
(http://maven.apache.org/plugins/maven-dependency-plugin/) to retrieve
your artifacts and unpack them if you don't/cannot pack them as war.

Finally, you can add supplementary web-resources I think, to the war
plugin, that will get packaged with the artifact (see
http://maven.apache.org/plugins/maven-war-plugin/war-mojo.html#webResources).

Regards,
-- 
Arnaud Bailly, PhD
OQube - Software Engineering
http://www.oqube.com


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Packaging HTML/JavaScript files into WAR from outside project

Posted by Manos Batsis <ma...@geekologue.com>.
David Harkness wrote:

> When building the java webapp, I'd like some HTML and JS files to be
> packaged into the WAR, but those files live in the "html" and
> "javascript" directories instead of in "java/src/main/webapp". What's
> the appropriate plugin to use in this case?
> 
> On a side note, there are other JavaScript files from those same
> directories that get packaged into "WEB-INF/classes" since they need
> to be available as resources to the Java code and not as files via
> HTTP. This works great, and I want something similar that makes them
> available via HTTP instead of to the Java code.

Check out our maven-jstools-plugin [1], see "Packaging JS" [2]. Using 
that as a normal (i.e non-plugin) dependency in your java webapp will 
allow you to make HTTP requests to JS files or other static resources 
(images, html etc.). This works through a highly configurable servlet 
filter [3].

This will also work for your "html" and "javascript" directories, if you 
tell maven to treat them as resources.

[1] http://dev.abiss.gr/mvn-jstools/
[2] http://dev.abiss.gr/mvn-jstools/js-packaging.html
[3] 
http://dev.abiss.gr/mvn-jstools/apidocs/gr/abiss/mvn/plugins/jstools/web/JavascriptDependencyFilter.html

hth,

Manos

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org