You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by ma...@lhsystems.com on 2006/12/01 13:51:36 UTC

Putting resources to somewhere else

Dear Users,

I would like maven to put my resources not into the jar file, but next
to classes in a resources directory, so my structure would be:

Component +
          - lib +
                - mycomponent.jar
          - resources +
                      - myresource.xml

Etc.

Could anybody help how to tell the resource processor plugin where to
put it? I could tell only relative path within target/classes, but not
relative to output directory.

Thanks,
Marton Szabo   

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


Re: Putting resources to somewhere else

Posted by Wendy Smoak <ws...@gmail.com>.
On 12/4/06, Aaron Digulla <di...@hepe.com> wrote:

> Is there a simple way to have the resources next to the Java classes (ie. in
> src/main/java)? When developing with Hibernate, it's tedious to switch back
> and forth between the directories.
>
> I've checked the docs for the plugin but there is no example to do this.
> This made me think it might be dangerous to do (side effects, etc).

If you prefer to keep your non-Java resources under src/main/java,
then use <resources> to pick them up.

This pom has an example:
http://svn.apache.org/repos/asf/struts/struts1/trunk/core/pom.xml

You can also do it by adding a <resource> for src/main/java and
excluding **/*.java to get everything but the Java sources.  (That
might pick up Javadoc package summaries, though.)

The only thing to keep in mind is that once you specify any
<resources>, you're responsible for specifying *all* of them.  (For
example, the 'default' of src/main/resources has to be stated
explicitly in addition to anything under src/main/java.)

-- 
Wendy

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


Re: Putting resources to somewhere else

Posted by Aaron Digulla <di...@hepe.com>.

Wendy Smoak-3 wrote:
> 
> You can use <resources> in the
> pom to identify things to copy into the jar.
> 
Is there a simple way to have the resources next to the Java classes (ie. in
src/main/java)? When developing with Hibernate, it's tedious to switch back
and forth between the directories.

I've checked the docs for the plugin but there is no example to do this.
This made me think it might be dangerous to do (side effects, etc).
-- 
View this message in context: http://www.nabble.com/Putting-resources-to-somewhere-else-tf2737507s177.html#a7672996
Sent from the Maven - Users mailing list archive at Nabble.com.


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


RE: Putting resources to somewhere else

Posted by ru...@thomson.com.
In order to stop Maven from putting your resources into your jar you
need to override the default targetpath directory for the resources.
This is done in the POM in the <resources> section. If you take a look
at what I have below...this is telling maven to output any files found
in the src/main/resources to target/resources. This way...the maven pkg
cmd won't add them to your jar.  As you can see I also have maven setup
to exclude certain sub folders in there because I customize maven to
only filter files found in the filtered folder and only put files found
in the packaged folder into the jar. I then use assemblies as Wendy
described to create the structure similar to what you listed below. If
you want more details on how I set all this up you can email me
directly.

Ie.     <resources>
            <resource>
                <targetPath>../resources</targetPath>
                <filtering>false</filtering>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>filtered/**</exclude>
                    <exclude>packaged/**</exclude>                    
                    <exclude>dir.info</exclude>
                </excludes>
            </resource>
            <resource>

-----Original Message-----
From: Wendy Smoak [mailto:wsmoak@gmail.com] 
Sent: Friday, December 01, 2006 8:46 AM
To: Maven Users List
Subject: Re: Putting resources to somewhere else

On 12/1/06, marton.szabo.sp@lhsystems.com
<ma...@lhsystems.com>

> I would like maven to put my resources not into the jar file, but next
> to classes in a resources directory, so my structure would be:
>
> Component +
>           - lib +
>                 - mycomponent.jar
>           - resources +
>                       - myresource.xml
>
> Etc.
>
> Could anybody help how to tell the resource processor plugin where to
> put it? I could tell only relative path within target/classes, but not
> relative to output directory.

If you want to build something that contains jars and other files,
look at the assembly plugin:

http://maven.apache.org/plugins/maven-assembly-plugin/
(The current version is actually 2.1, not 2.2 as it says.)

Otherwise, whatever you put in src/main/resources will be mirrored in
the jar.  So if you want something at the "top level" of the jar, put
it directly in src/main/resources.  Then create the desired directory
structure from there.  It will overlay (or sit beside) the classes
compiled from code in src/main/java.  You can use <resources> in the
pom to identify things to copy into the jar.

-- 
Wendy

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


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


Re: Putting resources to somewhere else

Posted by Wendy Smoak <ws...@gmail.com>.
On 12/1/06, marton.szabo.sp@lhsystems.com <ma...@lhsystems.com>

> I would like maven to put my resources not into the jar file, but next
> to classes in a resources directory, so my structure would be:
>
> Component +
>           - lib +
>                 - mycomponent.jar
>           - resources +
>                       - myresource.xml
>
> Etc.
>
> Could anybody help how to tell the resource processor plugin where to
> put it? I could tell only relative path within target/classes, but not
> relative to output directory.

If you want to build something that contains jars and other files,
look at the assembly plugin:

http://maven.apache.org/plugins/maven-assembly-plugin/
(The current version is actually 2.1, not 2.2 as it says.)

Otherwise, whatever you put in src/main/resources will be mirrored in
the jar.  So if you want something at the "top level" of the jar, put
it directly in src/main/resources.  Then create the desired directory
structure from there.  It will overlay (or sit beside) the classes
compiled from code in src/main/java.  You can use <resources> in the
pom to identify things to copy into the jar.

-- 
Wendy

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