1
votes

I have a multi-project Maven web project and I am using Eclipse June with M2E and WTP. My test project defines a hibernate.properties file (in /src/main/resources) with connection parameters to my test database. If I add test as a normal compile-scope Maven dependency to the main project, its hibernate.properties is deployed successfully (in Eclipse, under Web Deployment Assembly, I see the test project is deployed as a JAR to WEB-INF/lib).

Now, because hibernate.properties only contains test data, I don't want it to be deployed for real. When I change the scope of the test dependency to "test", m2e doesn't include it anymore in the Deployment Assembly. Is there any way I can change this?

I could duplicate hibernate.properties into every sub-project that needs it, but I would like to be able to avoid needing to duplicate various test configuration files.

1
Out of curiosity, what sort of custom test only properties are you specifying? If it's only connection information you could define a resource reference in your web.xml, and have your J2EE server (Tomcat?) setup and provide the connection to your war. Then all your code knows is your container will provide a connection with a certain JNDI name. - Charlie
Just JDBC driver/url/user/pw. I'm refactoring a legacy application which has tons of duplicated config files and messy Ant scripts. I don't want JDNI as I want to keep things simple. :) Besides, I'd like the configurations to be usable by JUnit tests as well as the webapplication. - bcody

1 Answers

1
votes

You could move hibernate.properties to /src/test/resources. This is the place for test related resources and they will be copied to target/test-classes during the process-test-resources phase.