I have a problem with maven I am hoping someone knows the best solution to. As is typical with Java projects using maven, I have separate src/java
and src/test
trees and they compiles to build/classes
and build/test-classes
, respectively. When I build a distribution jar, maven zips up build/classes
into the jar (along with LICENSE.txt
and any resources). This much I know and appreciate.
However, my project uses JUnit for testing, so I have *Test
classes, one for each class under test. And my project provides *TestCase
base classes for other test classes to extend. The test case classes add functionality to junit.framework.TestCase
. These live under the src/test
tree since they are only used for testing, and they are dependent on junit-3.8.1.jar
. Of course, they compile to build/test-classes
.
But since the dist
goal only packages up build/classes
, the test case classes do not become part of my distribution jar. And I want to package them for distribition. Oops.
For now, I've moved the test case classes from src/test
to src/java
so that maven will bundle them in the distribution jar, but I feel awkward doing that.
Is there some way to teach maven to pull src/test/**/*TestCase.java
classes from build/test-classes
into the distribution jar, but no other test classes?
2 comments:
Perhaps some postGoal:
< postGoal name="test:compile" >...< /postGoal >
with ant's copy task:
< copy >...< /copy >
inside would do?
--
cr
Right. Better wording from me would have been, "Is there some ELEGANT way to do this". :-) I can hack the Maven goal, to be sure, just as you suggest, but I was hoping for something cleaner. Perhaps there is nothing cleaner though. Hrm.
Post a Comment