Return-Path: Delivered-To: apmail-maven-users-archive@www.apache.org Received: (qmail 92803 invoked from network); 5 Feb 2010 06:46:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 5 Feb 2010 06:46:28 -0000 Received: (qmail 48452 invoked by uid 500); 5 Feb 2010 06:46:26 -0000 Delivered-To: apmail-maven-users-archive@maven.apache.org Received: (qmail 47996 invoked by uid 500); 5 Feb 2010 06:46:25 -0000 Mailing-List: contact users-help@maven.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Maven Users List" Reply-To: "Maven Users List" Delivered-To: mailing list users@maven.apache.org Received: (qmail 47983 invoked by uid 99); 5 Feb 2010 06:46:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Feb 2010 06:46:25 +0000 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [212.130.89.130] (HELO bruce.dmz1.systematic.dk) (212.130.89.130) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Feb 2010 06:46:16 +0000 Received: from exch1aar.systematic.local ([172.17.2.105]) by bruce.dmz1.systematic.dk with Microsoft SMTPSVC(5.0.2195.6713); Fri, 5 Feb 2010 07:45:51 +0100 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: Read properties from pom.xml from Java Date: Fri, 5 Feb 2010 07:45:51 +0100 Message-ID: <1F73BC0657C6724ABC50790EE83722B5FEDAAF@exch1aar> In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Read properties from pom.xml from Java Thread-Index: AcqlhqWiIkPadqojSV+ppUexn4m3xwApcRrQ References: <1F73BC0657C6724ABC50790EE83722B5FEDAA9@exch1aar> From: =?iso-8859-1?Q?S=F8ren_Krogh_Neigaard?= To: "Maven Users List" X-OriginalArrivalTime: 05 Feb 2010 06:45:51.0671 (UTC) FILETIME=[DB9D5C70:01CAA62E] Thank you all for your answers I tried adding the following to my pom.xml oracle.jdbc.OracleDriver ${database.url} ${database.username} ${database.password} And tried reading with System.getProperty("database.username"), but it = gave me null. The reason for the ${database.url} and so on, is that it gets its values = from either a default settings.xml or a user specific settings.xml, and = that is how I need it to be. We are already using the sql-maven-plugin = to bootstrap the database, but it only gets run once before all junit = tests are run, and that is not what I need, I need it to run for every = test to ensure a clean database. I can easily make some code that drops my tables and so on, but I need = the correct database properties from the correct settings.xml. Bernd you talked about making a plugin that gets called before every = test, how can I do this? Med venlig hilsen / Kind regards=20 S=F8ren Krogh Neigaard Systems Engineer S=F8ren Frichs Vej 39, 8000 Aarhus C Denmark=20 Mobile +4541965252 soeren.krogh.neigaard@systematic.com www.systematic.com -----Original Message----- From: bernd.adamowicz@external.icw-global.com = [mailto:bernd.adamowicz@external.icw-global.com]=20 Sent: 4. februar 2010 11:59 To: Maven Users List Subject: Re: Read properties from pom.xml from Java Sounds like this might help you: - Create a Maven plugin which is executed in any phase >>bevore<< test,=20 e.g. 'generate-test-resources'. This will make it possible to set up the = database. This plugin might help for starting the database (only if = you're=20 using HSQL):=20 http://gforge.openehealth.org/gf/project/development/wiki/?pagename=3DDoc= umentation+HSQLDB+plugin , but there are others, too. - Reading of POM-properties inside a Maven plugin is easy and described=20 here:=20 http://www.sonatype.com/books/mvnref-book/reference/writing-plugins-sect-= mojo-params.html#writing-plugins-sect-param-values However, the scenario described by you clearly indicates that this is = not=20 a unit test instead it is an integration test where other rules/plugins=20 might apply, e.g. maven-invoker-plugin. But this would recommend a=20 restructuring of your project and might not be what you want.=20 Bernd S=F8ren Krogh Neigaard wrote on=20 04.02.2010 09:59:26: > [image removed]=20 >=20 > Read properties from pom.xml from Java >=20 > S=F8ren Krogh Neigaard=20 >=20 > to: >=20 > users >=20 > 04.02.2010 10:00 >=20 > Please respond to "Maven Users List" >=20 > Hi >=20 >=20 >=20 > I have been tossed into a maven controlled project. We run our junit > tests from Eclipse and also on our build server. When ever they are=20 > run, some maven magic happens so that username/password/driver/url=20 > for the dabase is correctly set for the user pc or the buildserver.=20 > However I need to make a small helper class for my junit tests that=20 > wipes the database and loads some testdata on the database for every > junit test. >=20 >=20 >=20 > The username/password/driver/url for the database is set in the=20 > pom.xml file by maven. How do I read these values from my Java helper=20 class? >=20 >=20 >=20 > Best regards >=20 > S=F8ren=20 >=20 >=20 >=20 InterComponentWare AG: =20 Vorstand: Peter Kirschbauer (Vors.), J=F6rg Stadler / = Aufsichtsratsvors.: Prof. Dr. Christof Hettich =20 Firmensitz: 69190 Walldorf, Industriestra=DFe 41 / AG Mannheim HRB = 351761 / USt.-IdNr.: DE 198388516 =3D --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@maven.apache.org For additional commands, e-mail: users-help@maven.apache.org