You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Emmanouil Batsis <ma...@geekologue.com> on 2004/11/21 11:16:08 UTC

[newbie, ant > maven] ear project structure, xdoclet integration, hibernate roundtripping

Deari list,

After going though the maven docs and various resources like the codehaus 
wiki, i find myself over my head with the number of details this morning.

My ant project is packaged as an EAR for deployment and contains an EJB JAR 
(session beans) and a WAR with a Struts app. As most sane people, i use 
xdoclet's ejb, web and struts modules. My are many but i think the main ones 
are these two, hopefully you guys can point me to solutions.

* project structure
   currently i have something like this (i used the parallel project 
structured as suggested at [1]. However i am not so sure as i already have 
three projects to handle just the EJB JAR? What is the structure you guys 
follow, or how would you add EJBs on a WAR based project like [1]?

* xdoclet integration
   Is there a resource that explains how common xdoclet modules are integrated 
in maven projects?

* hibernate
   do you guys use the hibernate plugin for roundtripping or should i try to 
integrate this from my ant builds?

Any help appreciated!

Manos

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


Re: [newbie, ant > maven] ear project structure, xdoclet integration, hibernate roundtripping

Posted by Emmanouil Batsis <ma...@geekologue.com>.

Hi Jose,

On Monday 22 November 2004 23:01, Jose Gonzalez Gomez wrote:
>     I use to put all my domain classes in a subproject, so
> maven/xdoclet/hibernate do their magic and generate all the mapping
> files, and then, in the place where I use them (EJB layer, web layer,
> wherever) I put the generated jar as a dependency, and create a
> hibernate.cfg.xml in src/resources (or whatever your resources are)
> pointing to the database holding the data.

Right... i really like this one artifact(?) per project rule. I'd probably 
never do something like that without maven, but can already see how 
components become easier to reuse with this rule. I even started working out 
different packaging/deployment scenarios for my EAR!

Many thanks for your help,

Manos

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


Re: [newbie, ant > maven] ear project structure, xdoclet integration, hibernate roundtripping

Posted by Jose Gonzalez Gomez <jg...@opentechnet.com>.
manos_lists@kattare.com wrote:

>Hi Jose,
>
>Thanks for your reply.
>
>Quoting Jose Gonzalez Gomez <jg...@opentechnet.com>:
>  
>
>>    I've done this in several projects, so feel free to ask... I'm
>>sure 
>>if you're a bit more specific you'll get a lot of good tips from the
>>list.
>>    
>>
>
>Regarding hibernate tools; should i investigate the hibernate plugin to
>generate the DDL (database schema) and javabeans from my mappings or
>should i try to integrate my ant logic through the ant plugin (i think
>this should be easy)? I heard the plugin is not mature enough. 
>  
>
    Well, it has limited functionality (no update schema) but it's usable.

>I must admit all my recent posts could be rephrased to "i am not yet
>familiar the directories maven uses, or when and how i should interrupt
>the build process" and that translates to my problems figuring out
>hibernate/xdoclet under maven. Sorry if this has RTFM written all over
>it, i have been over the docs; it's just too much to absorb right away
>and usually one learns better from an existing solution/best practice...
>plus there just isn't enough time to do things the right way these days
>(which is the main reason i want to use maven in the first place, to
>both do things right and save time).
>  
>
    Regarding hibernate/xdoclet... my maven.xml in a hibernate/xdoclet 
project:

<!-- I must clean all those library tags, not all of them are needed :o) -->
<project default="jar" xmlns:j="jelly:core" xmlns:maven="jelly:maven" 
xmlns:ant="jelly:ant" xmlns:artifact="artifact">
    <!-- This generates Hibernate mapping files just before compiling. -->
    <preGoal name="java:compile">
        <attainGoal name="xdoclet:hibernatedoclet"/>
    </preGoal>
    <!-- This is only useful if you need to use the generated schema 
elsewhere. -->
    <postGoal name="jar:install">
        <artifact:install 
artifact="${maven.build.dir}/schema/${pom.artifactId}-${pom.currentVersion}-schema.sql" 
type="schema" project="${pom}"/>
    </postGoal>
    <!-- I use this to force the copy of mapping files to the build 
directory. -->
    <preGoal name="hibernate:schema-export">
        <attainGoal name="jar:jar"/>
    </preGoal>
   
    <!-- ...and talking about missing update functionality. I guess it 
shouldn't be that dificult to add this to the plugin. -->
    <goal name="myproject:update-schema" prereqs="jar:jar">
        <ant:taskdef name="schemaupdate" 
classname="net.sf.hibernate.tool.hbm2ddl.SchemaUpdateTask">
            <ant:classpath>
                <ant:pathelement location="${maven.build.dest}"/>
                <ant:path refid="maven.dependency.classpath"/>
            </ant:classpath>
        </ant:taskdef>
        <ant:schemaupdate properties="hibernate.properties" quiet="no">
            <ant:fileset 
dir="${maven.xdoclet.hibernatedoclet.destDir}"><ant:include 
name="**/*.hbm.xml"/></ant:fileset>
        </ant:schemaupdate>
    </goal>
</project>

    In project properties:

# XDoclet - Hibernate properties
maven.xdoclet.hibernatedoclet.destDir=${maven.build.dir}/xdoclet/hibernatedoclet
maven.xdoclet.hibernatedoclet.hibernate.0.Version=2.0

# Hibernate properties
maven.hibernate.properties=${basedir}/hibernate.properties
maven.hibernate.text=true
maven.hibernate.delimiter=;

    And from project.xml (don't know if some of those dependencies could 
be taken away, I did this a lot of time ago ;o)

    <dependencies>
        <dependency>
            <groupId>hibernate</groupId>
            <artifactId>hibernate</artifactId>
            <version>2.1.6</version>
            <properties>
                <jar.manifest.classpath>true</jar.manifest.classpath>
            </properties>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib-full</artifactId>
            <version>2.0.1</version>
            <properties>
                <jar.manifest.classpath>true</jar.manifest.classpath>
            </properties>
        </dependency>
        <dependency>
            <groupId>dom4j</groupId>
            <artifactId>dom4j</artifactId>
            <version>1.4</version>
            <properties>
                <jar.manifest.classpath>true</jar.manifest.classpath>
            </properties>
        </dependency>
        <dependency>
            <groupId>odmg</groupId>
            <artifactId>odmg</artifactId>
            <version>3.0</version>
            <properties>
                <jar.manifest.classpath>true</jar.manifest.classpath>
            </properties>
        </dependency>
        <dependency>
            <groupId>ehcache</groupId>
            <artifactId>ehcache</artifactId>
            <version>0.7</version>
            <properties>
                <jar.manifest.classpath>true</jar.manifest.classpath>
            </properties>
        </dependency>
        <dependency>
            <groupId>xdoclet</groupId>
            <artifactId>xjavadoc</artifactId>
            <version>1.0.3</version>
            <properties/>
        </dependency>
        <dependency>
            <groupId>xdoclet</groupId>
            <artifactId>xdoclet-hibernate-module</artifactId>
            <version>1.2.2-SNAPSHOT</version>
            <properties/>
        </dependency>
        <dependency>
            <groupId>maven</groupId>
            <artifactId>maven-hibernate-plugin</artifactId>
            <version>1.2</version>
            <type>plugin</type>
        </dependency>
        <dependency>
            <groupId>postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>7.4.1-jdbc3</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.1</version>
        </dependency>
    </dependencies>
    <!-- This is needed to get the mapping files copied to the resulting 
jar -->
    <build>
        <resources>
            <resource>
                
<directory>${maven.xdoclet.hibernatedoclet.destDir}</directory>
                <includes>
                    <include>**/*.hbm.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
    </build>

    And don't forget to create hibernate.properties:

hibernate.dialect=net.sf.hibernate.dialect.PostgreSQLDialect

    I use to put all my domain classes in a subproject, so 
maven/xdoclet/hibernate do their magic and generate all the mapping 
files, and then, in the place where I use them (EJB layer, web layer, 
wherever) I put the generated jar as a dependency, and create a 
hibernate.cfg.xml in src/resources (or whatever your resources are) 
pointing to the database holding the data.

    HTH, best regards
    Jose

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


Re: [newbie, ant > maven] ear project structure, xdoclet integration, hibernate roundtripping

Posted by ma...@kattare.com.

Hi Jose,

Thanks for your reply.

Quoting Jose Gonzalez Gomez <jg...@opentechnet.com>:
>     I've done this in several projects, so feel free to ask... I'm
> sure 
> if you're a bit more specific you'll get a lot of good tips from the
> list.

Regarding hibernate tools; should i investigate the hibernate plugin to
generate the DDL (database schema) and javabeans from my mappings or
should i try to integrate my ant logic through the ant plugin (i think
this should be easy)? I heard the plugin is not mature enough. 

I must admit all my recent posts could be rephrased to "i am not yet
familiar the directories maven uses, or when and how i should interrupt
the build process" and that translates to my problems figuring out
hibernate/xdoclet under maven. Sorry if this has RTFM written all over
it, i have been over the docs; it's just too much to absorb right away
and usually one learns better from an existing solution/best practice...
plus there just isn't enough time to do things the right way these days
(which is the main reason i want to use maven in the first place, to
both do things right and save time).

Thanks,

Manos 


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


Re: [newbie, ant > maven] ear project structure, xdoclet integration, hibernate roundtripping

Posted by Jose Gonzalez Gomez <jg...@opentechnet.com>.
Emmanouil Batsis wrote:

>On Sunday 21 November 2004 15:53, Emmanouil Batsis wrote:
>  
>
>>i would appreciate any tips on the hibernate integration...
>>    
>>
>
>Meaning the generation of POJOs and database creation using the hibernate 
>mappings. 
>
>Manos
>
>  
>
    Emmanouil,

    I've done this in several projects, so feel free to ask... I'm sure 
if you're a bit more specific you'll get a lot of good tips from the list.

    Best regards
    Jose

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


Re: [newbie, ant > maven] ear project structure, xdoclet integration, hibernate roundtripping

Posted by Emmanouil Batsis <ma...@geekologue.com>.
On Sunday 21 November 2004 15:53, Emmanouil Batsis wrote:
> i would appreciate any tips on the hibernate integration...

Meaning the generation of POJOs and database creation using the hibernate 
mappings. 

Manos

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


Re: [newbie, ant > maven] ear project structure, xdoclet integration, hibernate roundtripping

Posted by Emmanouil Batsis <ma...@geekologue.com>.
On Sunday 21 November 2004 12:16, Emmanouil Batsis wrote:
> * project structure

Regarding this one, i'm doing quite well following the nested structure 
suggested at [1] with a root project containing subprojects for EJB, WAR and 
a 'shared' JAR. Even works great for eclipse (with the root project being the 
IDE project). I think i'll be able to solve the xdoclet stuff but i would 
appreciate any tips on the hibernate integration...

[1] http://www.theserverside.com/resources/article.jsp?l=MavenMagic

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