Hi Levi,
On Oct 3, 2008, at 4:11 PM, Levi Hoogenberg wrote:
Hello,
I noticed that the Resources task copies resource files to the
classes/test-classes directories. What's the reasoning behind this?
I never had the need to do this in my Ant projects (neither for
testing, packaging, nor running an exploded web application).
The JavaPlugin add two task instances of type Resource. One has the
name 'resources' and copies files from src/main/resources to build/
classes. The other has the name 'testResources' and copies files from
src/main/testResources to build/test-classes. One use case for the
latter is that you need resource files in your tests which should not
be part of the production code. The other use case is that if you can
overwrite resource of your production code. When running the tests,
build/test-classes has precedence over build/classes.
I have done it like this also in my Ant builds. Maven also works like
this. See below for the reasons.
The reason I'm asking is that after running all of my tests from
the command line, the copied resources take precedence over the
original resource files in Eclipse (I'm configuring src/main/
resources as class folders, not as source folders) and the only way
for me to get Eclipse to pick up my changes is to clean all of my
projects. I'd rather avoid this :)
As I understand it the following happens in your case. Your Eclipse
classpath contains src/main/resources and build/classes. In your set
up build/classes has a higher precedence than src/main/resources.
Gradle copies the resources into build/classes as part of the build
and any changes you do to src/main/resources don't have any effect.
Defining src/main/resources as a source folder would solve the
problem? I guess you don't like this for performance reasons as you
have mentioned below? Another solution would be to change the
classpath order of the classpath folders.
How is the build/test-classes stuff you mentioned above related to this?
Another disadvantage is that copying resources starts take a long
time as soon as you're having a lot of them or when they are large,
although that may not be the best argument given today's computers :)
A not uncommon use case is that you don't use the src/main/resources
folder as it is, but apply transformation to it. For example Gradle
supports the use of filters. You can substitute placeholders in the
source-resource files with values defined at build time (e.g. version
number).
- Hans
--
Hans Dockter
Gradle Project lead
http://www.gradle.org
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email