You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Peter Horlock <pe...@googlemail.com> on 2008/05/13 18:21:32 UTC

war plugin - images / css

Hi,

I am using a default maven project layout:

src/resources/images <!-- jpg files -->
src/resources/styles <!-- css files -->

using the tomcat plugin which uses the resources plugin, it puts those files
into this war structure: (
http://maven.apache.org/plugins/maven-war-plugin/usage.html ):

`-- WEB-INF
     `-- classes
         |-- com
         |   `-- ideal
         |       `-- projects
         |           `-- SampleAction.class
         `-- images
             `-- sampleimage.jpg
         `-- styles
             `-- basic.css


Don't you think that's weird?! how can I access files under
WEB-INF/classes?!
I tried:  <link href="classes/styles/basic.css" (eventhough I don't like the
structure) -
but this didn't work.

So in short, my questions are:
1. where should my images, css, javascript and so on be - under /, WEB-INF,
or WEB-INF/classes.
If under WEB-INF/classes, how can I access them there?
2. How can I change Maven so that it puts the files where they should be?

Thanks in advance,

Peter ( really confused... ;-)

Re: war plugin - images / css

Posted by Jan Torben Heuer <jt...@mail2003.dnsalias.org>.
Peter Horlock wrote:

> Hi,
> 
> I am using a default maven project layout:
> 
> src/resources/images <!-- jpg files -->
> src/resources/styles <!-- css files -->
> 
> using the tomcat plugin which uses the resources plugin, it puts those
> files into this war structure: (
> http://maven.apache.org/plugins/maven-war-plugin/usage.html ):
> 
> `-- WEB-INF
>      `-- classes
>          |-- com
>          |   `-- ideal
>          |       `-- projects
>          |           `-- SampleAction.class
>          `-- images
>              `-- sampleimage.jpg
>          `-- styles
>              `-- basic.css
> 
> 
> Don't you think that's weird?! how can I access files under
> WEB-INF/classes?!
> I tried:  <link href="classes/styles/basic.css" (eventhough I don't like
> the structure) -
> but this didn't work.

Try
http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html


Jan


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


RE: war plugin - images / css

Posted by "Beelen, M. - SPLXL" <Ma...@klm.com>.
Peter,

I hope I can solve some of you confusion.
The rule I always use to determine where to put a file is to look at who
will load a certain file.

If the file is being loaded by a classload, the it should be under
/src/main/resources.
They will be copied to WEB-INF/classes when you build your project.

If a file is needed by the ApplicationServer, then the file should be
onder /src/main/webapp/WEB-INF.
These would include: web.xml and possible some optional files like:
.tld-files, tile-definitions, spring-servlet-config.xml-files, .... 

When a file is being loaded directly from a browser (images, .js-files
and .css-files) then those should be located under /src/main/webapp/

Resulting in something like
/src/main
/src/main/java
/src/main/resources/
/src/main/resources/ResourceBundle_en.properties
/src/main/resources/ResourceBundle_fr.properties
/src/main/webapp/
/src/main/webapp/index.html
/src/main/webapp/css/style.css
/src/main/webapp/images/logo.gif
/src/main/webapp/script/site.js
/src/main/webapp/WEB-INF/
/src/main/webapp/WEB-INF/web.xml

I hope this helps.

With kind regards,
  Marco Beelen






 

-----Original Message-----
From: Peter Horlock [mailto:peter.horlock@googlemail.com] 
Sent: Wednesday, May 14, 2008 3:51 PM
To: Maven Users List
Subject: Re: war plugin - images / css

Hi,

in the example provided the language properties seem to be under
resources, not under webapp:

http://jamwiki.svn.sourceforge.net/viewvc/jamwiki/wiki/trunk/jamwiki-war
/src/main/resources/ApplicationResources_ja.properties?revision=2200&vie
w=markup

Now I am confused :-(


Thanks in advance,

Peter
**********************************************************************
For information, services and offers, please visit our web site:
http://www.klm.com. This e-mail and any attachment may contain
confidential and privileged material intended for the addressee
only. If you are not the addressee, you are notified that no part
of the e-mail or any attachment may be disclosed, copied or
distributed, and that any other action related to this e-mail or
attachment is strictly prohibited, and may be unlawful. If you have
received this e-mail by error, please notify the sender immediately
by return e-mail, and delete this message. 

Koninklijke Luchtvaart Maatschappij NV (KLM), its subsidiaries
and/or its employees shall not be liable for the incorrect or
incomplete transmission of this e-mail or any attachments, nor
responsible for any delay in receipt.
Koninklijke Luchtvaart Maatschappij N.V. (also known as KLM Royal
Dutch Airlines) is registered in Amstelveen, The Netherlands, with
registered number 33014286 
**********************************************************************

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


Re: war plugin - images / css

Posted by Peter Horlock <pe...@googlemail.com>.
Hi,

in the example provided the language properties seem to be under resources,
not under webapp:

http://jamwiki.svn.sourceforge.net/viewvc/jamwiki/wiki/trunk/jamwiki-war/src/main/resources/ApplicationResources_ja.properties?revision=2200&view=markup

Now I am confused :-(


Thanks in advance,

Peter

Re: war plugin - images / css

Posted by Michael <sg...@gmx.net>.
Peter Horlock wrote:
>> resources are only for non-Java files visible to the classloader.
> 
> Can you give an example for a suitable file? What about xml, xsd files for
> example?
>> your "web" resources should always be unter src/main/webapp!
> What about language property files?
> under src/main/webapp/WEB-INF/classes
> or resources/?

Any file is suitable if it was to be visible to the WebAppClassLoader.

Examples:
.properties
or other files accessed with #getServletContext().getResourceAsStream()

Files with have to available to the Browser. should always be in 
src/main/webapp.

This is a good example: 
http://jamwiki.svn.sourceforge.net/viewvc/jamwiki/wiki/trunk/jamwiki-war/src/main/

Mike
-- 
<NO> OOXML - Say NO To Microsoft Office broken standard
http://www.noooxml.org

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


Re: war plugin - images / css

Posted by Peter Horlock <pe...@googlemail.com>.
>resources are only for non-Java files visible to the classloader.

Can you give an example for a suitable file? What about xml, xsd files for
example?
>your "web" resources should always be unter src/main/webapp!
What about language property files?
under src/main/webapp/WEB-INF/classes
or resources/?


Is there any page were I could read about the exact rules?

Thanks in advance,

Peter

Re: war plugin - images / css

Posted by Michael <sg...@gmx.net>.
Peter Horlock wrote:
> Hi,
> 
> I am using a default maven project layout:
> 
> src/resources/images <!-- jpg files -->
> src/resources/styles <!-- css files -->

This the the wrong way to go!

resources are only for non-Java files visible to the classloader.
your "web" resources should always be unter src/main/webapp!


-- 
<NO> OOXML - Say NO To Microsoft Office broken standard
http://www.noooxml.org

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