You should find that the system property "baseDir" is the root of the
active project being built.
eg System.getProperty("baseDir")
Cheers,
Ben
Craig S. Cottingham wrote:
On Aug 5, 2004, at 10:19, Eric Hauser wrote:
I running some unit tests with Maven during my build process using
Hypersonic in-memory mode as the datasource. I generating the schema
from Hibernate and then loading the schema in a preGoal for test:test
using the ant:sql tags. The problem that I am having is every time
the unit test runs, Hypersonic cannot seem to find the tables that I
just loaded. Anyone have an example code that does something
similar? Thanks.
We don't generate the database schema as part of the test goal;
instead, the Hypersonic database script is an original source and
stored in version control. Other than that, I think we're doing
something similar to what you're trying to do.
The problem we ran into was that Maven has no well-defined current
directory from which to specify a relative path to the database
script. Normally, this would mean that you'd have to specify an
absolute path, which is generally a Bad Idea.
I got around this by modifying the datasource configuration properties
file in a pregoal for test:test:
<preGoal name="test:test">
<ant:copy todir="${maven.build.dir}/test-classes" overwrite="true" >
<ant:fileset dir="${maven.src.dir}/test/conf">
<ant:include name="datasource.properties" />
</ant:fileset>
<ant:filterset>
<ant:filter token="BUILDDIR" value="${maven.build.dir}" />
</ant:filterset>
</ant:copy>
</preGoal>
The datasource configuration properties file contains (in part):
testPool.jdbc.driver=org.hsqldb.jdbcDriver
testPool.jdbc.url=jdbc:hsqldb:@BUILDDIR@/testdb
The glue between the datasource configuration properties and the code
that uses the datasource I can't show you, unfortunately. But as long
as you're defining the connection parameters in a configuration file
(and you should be :-), you should be able to do something similar.
Hope this helps.
--
Craig S. Cottingham
[EMAIL PROTECTED]
OpenPGP key available from:
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x7977F79C
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]