Re: Cgen task

From: Mike Kienenberger (mkienen..mail.com)
Date: Thu Feb 09 2006 - 14:00:41 EST

  • Next message: Mike Kienenberger: "Re: Problem with connections leak"

    Gary,

    I've got working tasks that create interfaces.
    I could probably make them available if you like, although they also
    add in vertical inheritance stuff by overloading some of the multitier
    client attributes.

    As for your specific questions, you need to use makepairs=false and
    usepkgpath=false. You're trying to make the default behavior do
    something it was not intended to support.

    Here's the build targets I use. "entity" creates the interfaces and
    cayenne implementation. "stubs" creates POJO non-persisted
    implementations.

            <target name="entity" depends="failure check"
    description="internal:generate entity">
            <mkdir dir="${dataMapModelPackageDir}/entity"/>
                <cgen map="${template.datamap}"
                        additionalMaps="${additional.template.datamaps}"
                version="1.2"
                makepairs="false"
                overwrite="false"
                        mode="entity"
                destDir="${dataMapModelPackageDir}/entity"
                        superpkg="${dataMapModelPackage}.entity.cayenne.generated"
                        template="${template.subclass.interface}"
                usepkgpath="false">
                </cgen>
            <mkdir dir="${dataMapModelPackageDir}/entity/generated"/>
                <cgen map="${template.datamap}"
                        additionalMaps="${additional.template.datamaps}"
                version="1.2"
                makepairs="false"
                overwrite="true"
                        mode="entity"
                        outputPattern="_*.java"
                destDir="${dataMapModelPackageDir}/entity/generated"
                        superpkg="${dataMapModelPackage}.entity.cayenne.generated"
                        template="${template.superclass.interface}"
                usepkgpath="false">
                </cgen>
            <mkdir dir="${dataMapModelPackageDir}/entity/cayenne"/>
                <cgen map="${template.datamap}"
                        additionalMaps="${additional.template.datamaps}"
                version="1.2"
                makepairs="false"
                overwrite="false"
                        mode="entity"
                destDir="${dataMapModelPackageDir}/entity/cayenne"
                        superpkg="${dataMapModelPackage}.entity.cayenne.generated"
                        template="${template.subclass}"
                usepkgpath="false">
                </cgen>
            <mkdir dir="${dataMapModelPackageDir}/entity/cayenne/generated"/>
                <cgen map="${template.datamap}"
                        additionalMaps="${additional.template.datamaps}"
                version="1.2"
                makepairs="false"
                overwrite="true"
                        mode="entity"
                        outputPattern="_*Impl.java"
                destDir="${dataMapModelPackageDir}/entity/cayenne/generated"
                        superpkg="${dataMapModelPackage}.entity.cayenne.generated"
                        template="${template.superclass}"
                usepkgpath="false">
                </cgen>
        </target>

            <target name="entity stub" depends="failure check"
    description="internal:generate entity">
            <mkdir dir="${dataMapModelPackageDir}/entity/stub/generated"/>
                <cgen map="${template.datamap}"
                        additionalMaps="${additional.template.datamaps}"
                version="1.2"
                makepairs="false"
                overwrite="true"
                        mode="entity"
                        outputPattern="_*StubImpl.java"
                destDir="${dataMapModelPackageDir}/entity/stub/generated"
                        superpkg="${dataMapModelPackage}.entity.cayenne.generated"
                        template="${template.superclass.stub}"
                usepkgpath="false">
                </cgen>
            <mkdir dir="${dataMapModelPackageDir}/entity/stub"/>
                <cgen map="${template.datamap}"
                        additionalMaps="${additional.template.datamaps}"
                version="1.2"
                makepairs="false"
                overwrite="false"
                        mode="entity"
                        outputPattern="*StubImpl.java"
                destDir="${dataMapModelPackageDir}/entity/stub"
                        superpkg="${dataMapModelPackage}.entity.cayenne.generated"
                        template="${template.subclass.stub}"
                usepkgpath="false">
                </cgen>
        </target>

    On 2/9/06, Gary Jarrel <garyjarre..mail.com> wrote:
    > Hi All!
    >
    > I'm using the cgen ant task to generate interfaces using the map for a
    > particular cayenne project.
    >
    > I'm generating a pair of interface (as I've seen discussed on this
    > list) i.e IFooInterface and I_FooInterface. Hence I'm using the
    > makepairs=true and usepkgpath=true. I'm also setting a custom package
    > for the super interface using superpkg. This custom package and hence
    > custom directory is different to that used by the generated cayenne
    > super classes
    >
    > The problem is sub interface get generated into the same folder as the
    > standard cayenne sub classes, and I can't see an easy way to modify
    > the directory into which these interface are generated, as it appears
    > cgen reads the package name from the map file, and builds the
    > directory structure accordingly. Is there a way to modify this
    > behaviour?
    >
    > Thankyou for you help!
    >
    > Gary
    >



    This archive was generated by hypermail 2.0.0 : Thu Feb 09 2006 - 14:00:43 EST