« Return to Thread: Overriding properties in a dependency's pom.xml

Re: Overriding properties in a dependency's pom.xml

by mraible :: Rate this Message:

Reply to Author | View in Thread

I tried setting the dao.framework property in settings.xml, but that didn't work either.

It seems there's only two ways to set a DAO Framework with AppFuse/Maven.

1. Pass it in from the command-line: mvn jetty:run-war -Ddao.framework=jpa-hibernate
2. Set it in your MAVEN_OPTS environment variable: export MAVEN_OPTS='-Ddao.framework=jpa-hibernate'.

Both of these seem pretty fragile as it requires end users to do something.  If they don't set the MAVEN_OPTS variable, they'll end up with Hibernate instead of iBATIS or JPA. Is there a better way to do this?  

Is Maven like Ant in that properties are immutable?  If so, can I hook into the lifecycle sooner and set this dao.framework property from the local pom.xml?

Thanks,

Matt


mraible wrote:
I have a project that has <dao.framework>hibernate</dao.framework> defined as a property in the root pom.xml. In a "service" project, that property is used as follows:

        <dependency>
            <groupId>${pom.groupId}</groupId>
            <artifactId>appfuse-${dao.framework}</artifactId>
            <version>${pom.version}</version>
        </dependency>

In turn, the service dependency is used in WAR projects:

        <dependency>
            <groupId>${pom.groupId}</groupId>
            <artifactId>appfuse-service</artifactId>
            <version>${pom.version}</version>
            <exclusions>
        </dependency>

From here, child projects use this WAR project (it's overlayed).  We're using the Maven WarPath plugin (http://static.appfuse.org/plugins/maven-warpath-plugin/) to read dependencies from WARs.

For some reason, if I put <dao.framework>ibatis</dao.framework> in my child project, it doesn't override the variable in the service/pom.xml.  However, if I pass in -Ddao.framework=ibatis from the command-line, everything works.  

Is it possible to override property values in child projects - or is it only possible from the command-line?  My child project does not refer to any other projects as parent projects.

Matt

 « Return to Thread: Overriding properties in a dependency's pom.xml