You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Stephane-3 <mi...@yahoo.se> on 2013/03/14 08:57:14 UTC

Multiple build arguments

Hello,

I have a pom.xml file with several profiles, one for MySql, one for H2, one
for HSQLDB and one for Oracle XE.

And I run a build, for example against MySql, with the command:

mvn clean install -Pmysql-db

Or against the Oracle XE with the command:

mvn clean install -Poracle-db

Now, all of them use a Hibernate Dao with old fashioned xml mapping files.

I'm now trying to implement a JPA2 layer to be used in place of the
Hibernate Dao layer.

And I would like to choose which of the two is used with a command line
argument, say something like -Ddao=hibernate or -Ddao=jpa2

Is is possible to do that ?

Or do I have to create additional profiles ?

Kind Regards,




--
View this message in context: http://maven.40175.n5.nabble.com/Multiple-build-arguments-tp5750700.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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


Re: Multiple build arguments

Posted by Stephane-3 <mi...@yahoo.se>.
Thank you Andreas ! It solved the issue.





--
View this message in context: http://maven.40175.n5.nabble.com/Multiple-build-arguments-tp5750700p5751511.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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


Re: Multiple build arguments

Posted by Andreas Gudian <an...@gmail.com>.
You can specify more than one profile at a time. Separated by comma or with
multiple -P.

Am Freitag, 15. März 2013 schrieb Stephane-3 :

> Hello,
>
> Thanks for the input. But maybe my original post was not so clear. I
> already
> have four profiles in my pom file. So if I factor in the choice between
> hibernate and jpa I'll end up with eight profiles. This is why I posted
> here
> asking for another way to gi.
>
> Kind Regards,
>
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Multiple-build-arguments-tp5750700p5750852.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org <javascript:;>
> For additional commands, e-mail: users-help@maven.apache.org<javascript:;>
>
>

RE: Multiple build arguments

Posted by Stephane-3 <mi...@yahoo.se>.
Hello,

Thanks for the input. But maybe my original post was not so clear. I already
have four profiles in my pom file. So if I factor in the choice between
hibernate and jpa I'll end up with eight profiles. This is why I posted here
asking for another way to gi.

Kind Regards,




--
View this message in context: http://maven.40175.n5.nabble.com/Multiple-build-arguments-tp5750700p5750852.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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


RE: Multiple build arguments

Posted by Stephane-3 <mi...@yahoo.se>.
Hello,

What do you mean with to sub in another data-source ?
Also can you elaborate on how can someone messes up my classpath ?
What do you mean with to toss in a new injector ?

Kind Regards,




--
View this message in context: http://maven.40175.n5.nabble.com/Multiple-build-arguments-tp5750700p5750853.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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


RE: Multiple build arguments

Posted by Martin Gainty <mg...@hotmail.com>.
you can accomplish this with either strategy

1)Spring IOC will inject into placeholders the supplied params BUT you would need to (re)compile each time 2)you can accomplish mvn repackaging your ear with any number of varied data sources with Profiles e.g.-Phibernate or -Pjpa2 this would activate the requested profile

IMHO spring implementation means you would have to force a compile each time you want to sub in another data-source ....this can be very time-consuming ..not to mention god help you if someone messes up your classpath
by tossing in a new injector...

My vote is for option2

Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.

 > Date: Thu, 14 Mar 2013 14:40:44 -0700
> From: mittiprovence@yahoo.se
> To: users@maven.apache.org
> Subject: Re: Multiple build arguments
> 
> Hi Baptiste,
> 
> Thanks for that, I tried it, but got stuck in syntax error..
> 
> You'd have some example with the syntax to use ?
> 
> Kind Regards,
> 
> 
> 
> 
> --
> View this message in context: http://maven.40175.n5.nabble.com/Multiple-build-arguments-tp5750700p5750816.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
 		 	   		  

Re: Multiple build arguments

Posted by Stephane-3 <mi...@yahoo.se>.
Hi Baptiste,

Thanks for that, I tried it, but got stuck in syntax error..

You'd have some example with the syntax to use ?

Kind Regards,




--
View this message in context: http://maven.40175.n5.nabble.com/Multiple-build-arguments-tp5750700p5750816.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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


Re: Multiple build arguments

Posted by Baptiste MATHUS <ml...@batmat.net>.
Hi,
Just a thought, maybe you could just have a solution.being not really Maven
related.
Use a placeholder in your spring ctx files to use differently named files
with with a given prefix corresponding to the one given on the command line
?

Cheers
Le 14 mars 2013 09:03, "Stephane-3" <mi...@yahoo.se> a écrit :

> In each profile I have the test source directory being specified:
>
> <profile>
>       <id>mysql-db</id>
>       <properties>
>         <test.source.dir>src/integration/java</test.source.dir>
>       </properties>
>
> which contains the abstract test class loading the Hibernate or the JPA2
> configuration file:
>
> @ContextConfiguration(locations = { "classpath:spring-hibernate.xml",
> "classpath:spring-hibernate-dao.xml", "classpath:spring-data-source.xml",
> "classpath:log4j.xml" })
> public abstract class AbstractDaoTest extends
> AbstractTransactionalJUnit4SpringContextTests {
> }
>
> What I would need is a way to specify spring-hibernate.xml or
> spring-jpa.xml
> in this abstract test class.
>
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Multiple-build-arguments-tp5750700p5750701.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Multiple build arguments

Posted by Stephane-3 <mi...@yahoo.se>.
In each profile I have the test source directory being specified:

<profile>
      <id>mysql-db</id>
      <properties>
        <test.source.dir>src/integration/java</test.source.dir>
      </properties>

which contains the abstract test class loading the Hibernate or the JPA2
configuration file:

@ContextConfiguration(locations = { "classpath:spring-hibernate.xml",
"classpath:spring-hibernate-dao.xml", "classpath:spring-data-source.xml",
"classpath:log4j.xml" })
public abstract class AbstractDaoTest extends
AbstractTransactionalJUnit4SpringContextTests {
}

What I would need is a way to specify spring-hibernate.xml or spring-jpa.xml
in this abstract test class.




--
View this message in context: http://maven.40175.n5.nabble.com/Multiple-build-arguments-tp5750700p5750701.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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