History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: APF-565
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Matt Raible
Reporter: Matt Raible
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
AppFuse

Setting dao.framework property doesn't work in AppFuse-generated projects

Created: 04/Jan/07 10:42 PM   Updated: 19/Sep/08 12:19 AM
Component/s: Installation
Affects Version/s: 2.0-M2
Fix Version/s: 2.0-M5

Environment: Windows XP and OS X, Maven 2.0.4


 Description  « Hide
Setting the "dao.framework" property in an AppFuse-based project's pom.xml doesn't work as expected. You can read more about the problem on the Maven list.

http://www.nabble.com/Overriding-properties-in-a-dependency%27s-pom.xml-tf2921218s177.html

Until we figure out a solution, 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. Ugh.

 All   Comments   Change History   FishEye      Sort Order:
Michael Horwitz - 06/Jan/07 03:30 PM
Looking through the Maven 2.0.4 code it is not possible to override properties in the pom files of dependent artifacts other than via environment variables. It is not so much that Maven treats the properties as immutable, rather that the pom files for dependent artifacts are read and resolved in complete isolation of the project environment being run.

For AppFuse the simplest solution is going to be to make the DAO framework an optional dependency on the web tier. Child projects can then choose their persistence framework by explicitly setting the dependency themselves.

Matt Raible - 06/Jan/07 04:15 PM
So we should make it optional in the service layer, as well as specify it (and make it optional) the web modules? Then modify the archetypes to have the persistence module as a dependency?

Michael Horwitz - 08/Jan/07 04:51 AM
That was the idea. Unfortunately the war plugin explicitly excludes any dependencies marked as optional from WEB-INF/lib and the Canoo web tests then fail- I will need to revise the solution.

The service layer should have an explicit dependency on the data-commons project as this is invarient of the chosen DAO layer.

Matt Raible - 08/Jan/07 11:39 AM
I added an explicity dependency on appfuse-data-common to service/pom.xml and web/common/pom.xml. Unfortunately, the web tests still fail.

Matt Raible - 11/Jan/07 04:29 PM
Entered as a "wish" in Maven's JIRA: http://jira.codehaus.org/browse/MNG-2757

Matt Raible - 29/Mar/07 02:41 PM
Fixed DAO framework switching problem by excluding appfuse-hibernate (the default) and then adding the dependency back in with a ${dao.framework} variable taht will be read from the local pom.xml. Here's the code to change existing projects:

<dependency>
            <groupId>org.appfuse</groupId>
            <artifactId>appfuse-${web.framework}</artifactId>
            <version>${appfuse.version}</version>
            <type>warpath</type>
            <!-- This exclusion and the dependency following this one allow DAO framework switching. -->
            <!-- You only need these if you want to use JPA or iBATIS. See APF-565 for more information. -->
            <!-- It does no harm to leave it in for Hibernate, but it's not needed. -->
            <exclusions>
                <exclusion>
                    <groupId>org.appfuse</groupId>
                    <artifactId>appfuse-hibernate</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.appfuse</groupId>
            <artifactId>appfuse-${dao.framework}</artifactId>
            <version>${appfuse.version}</version>
        </dependency>

Of course, if you know of a better solution - please let me know!