Thank you Rene, your suggestion worked! At least I have a solution 
now--probably better than using classpath anyway.

To answer your question, the .properties files are not available on the 
classpath at runtime if they are in the libs dir, they have to be in classes.

I still plan to submit a JIRA issue. At the very least, the Gradle 
documentation should clarify the intended behavior in this case.

Cheers,

- Darren

-----Original Message-----
From: Rene Groeschke [mailto:[email protected]] 
Sent: Friday, January 07, 2011 5:33 PM
To: [email protected]
Subject: Re: [gradle-user] Adding individual files to a WAR classpath

Am 07.01.11 23:06, schrieb Darren Evenson:
> Hi,
>
> I am using the war plugin for a project, and I am trying to add some files to 
> the war file's WEB-INF/classes directory. The files I'm targeting exist 
> within the project, but outside the webAppDirName for the war. I do not want 
> to add the entire directory tree since there are subdirectories that should 
> not be included. My war task config looks like:
>
> war {
>     classpath fileTree(dir: 'src/conf', include: '*') }
>
> The files in src/conf are .properties files (ie, not .zip or .jar). These 
> files end up in the WEB-INF/lib directory of the war file, not the 
> WEB-INF/classes dir.  The docs for the war task say:
>
> Any JAR or ZIP files in this classpath are included in the WEB-INF/lib 
> directory. Any directories in this classpath are included in the 
> WEB-INF/classes directory.
>
> It doesn't say what happens to files that are not JAR or ZIP files. But it 
> appears *any* file added to the classpath ends up in the WEB-INF/lib 
> directory.  I get the same results with any of the following two variations:
>
> war {
>           classpath fileTree(dir: 'src/conf', include: '*').files }
>
> war {
>           fileTree(dir: 'src/conf', include: '*').each {
>                    classpath it
>           }
> }
>
> The following variation works in that it puts the files under 
> WEB-INF/classes, but it includes the subdirectories as well.
>
> war {
>           classpath 'src/conf'
> }
>
> The behavior is consistent in that whenever I specify the directory (without 
> restricting it from being recursive), the files (including subdirectories) 
> end up in WEB-INF/classes. In all cases when I restrict the file selection to 
> just the base directory (not rescursive), then they end up in WEB-INF/lib.
>
> Am I correct in thinking this is a bug? I plan to create a JIRA issue for 
> this, but I wanted to run it by this group first for input.
I'm not sure if this is intended behaviour or not. But out of curiosity, why do 
you need those files in WEB-INF/classes instead of WEB-INF/lib?
As a workaround you can get your *.properties files (without including
subdirs) to WEB-INF/classes with

-------------
war {
    from('src/conf'){
        into("WEB-INF/classes")
        include "*.properties"
    }
}
-------------

regards,
René


--
------------------------------------
Rene Groeschke

[email protected]
http://www.breskeby.com
http://twitter.com/breskeby
------------------------------------


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to