You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Dhruva Reddy <dr...@sapient.com> on 2008/01/04 01:58:07 UTC

Managing Test and Production Resources with Maven 2

I am working on a web application with JUnit 3 tests.  We have resources
which are different for running within the application (within the
container) and within JUnit tests (outside the container).  An example
is persistence.xml (the configuration file for Hibernate Entity
Manager).  The production version (residing in
src/main/resources/META-INF) specifies a DataSource to be accessed
through JNDI, while the test version (src/test/resources/META-INF)
specifies a straight JDBC connection (since it cannot be assumed that a
container is available).

However, when I run the "package" goal, which runs the unit tests before
creating the WAR file, I can see that both versions of the file make it
into the "target" directory, one under "classes" and one under
"test-classes".  The problem is that during execution of the JUnit
tests, the version of the file under "classes" (intended for execution
within a container) appears to get picked up first (the JUnit tests
complain that the DataSource is unavailable and fail).

I had assumed that the point of having the "main" and "test" directories
was to be able to specify different versions of resources for unit
testing and running as an application.  Is this not a valid assumption,
or am I doing something else wrong?

Thanks,
Dhruva B. Reddy
Senior Associate of Technology, Level 2 | Sapient

25 1st Street
Cambridge, MA, 02141, USA
desk: +1 617 452 1900
fax: +1 617 621 1300

www.sapient.com


RE: Managing Test and Production Resources with Maven 2

Posted by Dhruva Reddy <dr...@sapient.com>.
Not sure this went through the first time, but I was using 2.0.7, and upgrading to 2.0.8 resolved the issue.

Thanks!
Dhruva

-----Original Message-----
From: Wendy Smoak [mailto:wsmoak@gmail.com]
Sent: Thu 03-Jan-08 20:03
To: Maven Users List
Subject: Re: Managing Test and Production Resources with Maven 2
 
On Jan 3, 2008 5:58 PM, Dhruva Reddy <dr...@sapient.com> wrote:

> However, when I run the "package" goal, which runs the unit tests before
> creating the WAR file, I can see that both versions of the file make it
> into the "target" directory, one under "classes" and one under
> "test-classes".  The problem is that during execution of the JUnit
> tests, the version of the file under "classes" (intended for execution
> within a container) appears to get picked up first (the JUnit tests
> complain that the DataSource is unavailable and fail).

What version of Maven are you using?  It sounds like MNG-3118, which
was fixed in 2.0.8.

http://jira.codehaus.org/browse/MNG-3118

-- 
Wendy

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




Re: Managing Test and Production Resources with Maven 2

Posted by Wendy Smoak <ws...@gmail.com>.
On Jan 3, 2008 5:58 PM, Dhruva Reddy <dr...@sapient.com> wrote:

> However, when I run the "package" goal, which runs the unit tests before
> creating the WAR file, I can see that both versions of the file make it
> into the "target" directory, one under "classes" and one under
> "test-classes".  The problem is that during execution of the JUnit
> tests, the version of the file under "classes" (intended for execution
> within a container) appears to get picked up first (the JUnit tests
> complain that the DataSource is unavailable and fail).

What version of Maven are you using?  It sounds like MNG-3118, which
was fixed in 2.0.8.

http://jira.codehaus.org/browse/MNG-3118

-- 
Wendy

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