views:

100

answers:

1

I have a maven project that loads an xslt file and executes the transformation along with other processing on the result. Normally when the user runs the application, the user provides the xslt file path to be loaded. But I include some default xslt files bundled inside my application that the user can use without loading any external xslt file. I do this by adding them to src/main/resources/xslt. My problem is that I want to run tests against those xslt files in testing phase. How can I achieve this? Should I copy the src/main/resources/xslt contents to target/somewhere and load these in my test classes code? Which plugin is used for that?

+2  A: 

My problem is that I want to run tests against those xslt files in testing phase. How can I achieve this?

There is nothing to do, target/classes is on the class path of tests. More precisely, the class path for tests is:

  • first target/test-classes
  • then target/classes
  • then dependencies

So resources from src/main/resources (which are copied into target/classes) are visible from tests.

Pascal Thivent
Yep.. after posting the question I explicitly tried to do that and it works. I just was under the impression that it is a convention that src/* is only for generation, processing and compilation and that any phase after that should only look into target/* paths to do its work. Isnt that true?
Paralife
@Paralife Your resources are copied into `target/classes` (and test resources are copied into `target/test-classes`). I've clarified this. Does it answer the question?
Pascal Thivent
Ah ok. I didnt understand that they are copied. I just though that src/main/resources is visible from tests directly. I see it now. Thanks.
Paralife
Btw the convention that I assume in my previous comment is true or false?
Paralife
@Paralife: Somehow, yes, most things are done on the content of `target`.
Pascal Thivent