FAQ
Hey guys,

A couple fo questions about class generation:

1) Is it possible to trigger (from within Eclipse) an automated build of
the classes when the model file changes? I had this with WebObjects/WOLips
and it's such nice feature.
2) I can't figure out how to get the modeler to build classes into the
right directories honoring packages. It seems like if I choose the
"packages" option (I can't remember the specific name) it doesn't end up in
the right place. I'm sure I just misunderstand the options.


-Lon

Search Discussions

  • John Huss at Aug 7, 2014 at 6:50 pm

    On Thu, Aug 7, 2014 at 12:35 PM, Lon Varscsak wrote:

    Hey guys,

    A couple fo questions about class generation:

    1) Is it possible to trigger (from within Eclipse) an automated build of
    the classes when the model file changes? I had this with WebObjects/WOLips
    and it's such nice feature.
    No :-(

    But I haven't found it to be much of an issue. It's pretty easy to
    generate the classes from the Modeler menu, or from an ant target. I do it
    both ways, but use ant more often now since it always has the right
    settings.

    If you are using ant, the setup could look like this:

    <path id="cgen.classpath">
    <fileset dir="path/to/cayenne" includes="cayenne-server*.jar" />
    <fileset dir="path/to/cayenne" includes="cayenne-di*.jar" />
    <fileset dir="path/to/cayenne" includes="commons-*.jar" />
    <fileset dir="path/to/cayenne" includes="velocity-*.jar" />
    <fileset dir="path/to/cayenne-tools" includes="*.jar" />
    </path>
    <typedef resource="org/apache/cayenne/tools/antlib.xml">
    <classpath refid="cgen.classpath"/>
    </typedef>
      <target name="generate.entity.classes">
    <touch file="src/MyModel.map.xml" />
    <cgen map="src/MyModel.map.xml"
    superpkg="com.company.cayenne.auto"
    supertemplate="superclass.vm"
    template="subclass.vm"
    destDir="src"
    outputPattern="*.java"
    encoding="UTF-8"
    mode="all"
    />
    </target>

    You may be able to add an eclipse "builder" to do it automatically - not
    sure..


    2) I can't figure out how to get the modeler to build classes into the
    right directories honoring packages. It seems like if I choose the
    "packages" option (I can't remember the specific name) it doesn't end up in
    the right place. I'm sure I just misunderstand the options.
    Do you have the "Use package path" box checked at the bottom of the
    generate classes window?


    -Lon
  • John Huss at Aug 7, 2014 at 8:42 pm
    Also, you can vote for this feature here:
    https://issues.apache.org/jira/browse/CAY-1723

    On Thu, Aug 7, 2014 at 1:49 PM, John Huss wrote:
    On Thu, Aug 7, 2014 at 12:35 PM, Lon Varscsak wrote:

    Hey guys,

    A couple fo questions about class generation:

    1) Is it possible to trigger (from within Eclipse) an automated build of
    the classes when the model file changes? I had this with
    WebObjects/WOLips
    and it's such nice feature.
    No :-(

    But I haven't found it to be much of an issue. It's pretty easy to
    generate the classes from the Modeler menu, or from an ant target. I do it
    both ways, but use ant more often now since it always has the right
    settings.

    If you are using ant, the setup could look like this:

    <path id="cgen.classpath">
    <fileset dir="path/to/cayenne" includes="cayenne-server*.jar" />
    <fileset dir="path/to/cayenne" includes="cayenne-di*.jar" />
    <fileset dir="path/to/cayenne" includes="commons-*.jar" />
    <fileset dir="path/to/cayenne" includes="velocity-*.jar" />
    <fileset dir="path/to/cayenne-tools" includes="*.jar" />
    </path>
    <typedef resource="org/apache/cayenne/tools/antlib.xml">
    <classpath refid="cgen.classpath"/>
    </typedef>
    <target name="generate.entity.classes">
    <touch file="src/MyModel.map.xml" />
    <cgen map="src/MyModel.map.xml"
    superpkg="com.company.cayenne.auto"
    supertemplate="superclass.vm"
    template="subclass.vm"
    destDir="src"
    outputPattern="*.java"
    encoding="UTF-8"
    mode="all"
    />
    </target>

    You may be able to add an eclipse "builder" to do it automatically - not
    sure..


    2) I can't figure out how to get the modeler to build classes into the
    right directories honoring packages. It seems like if I choose the
    "packages" option (I can't remember the specific name) it doesn't end up
    in
    the right place. I'm sure I just misunderstand the options.
    Do you have the "Use package path" box checked at the bottom of the
    generate classes window?


    -Lon
  • Lon Varscsak at Aug 7, 2014 at 10:54 pm
    I think it's just you and I John. :D

    -Lon

    On Thu, Aug 7, 2014 at 1:41 PM, John Huss wrote:

    Also, you can vote for this feature here:
    https://issues.apache.org/jira/browse/CAY-1723

    On Thu, Aug 7, 2014 at 1:49 PM, John Huss wrote:

    On Thu, Aug 7, 2014 at 12:35 PM, Lon Varscsak <lon.varscsak@gmail.com>
    wrote:
    Hey guys,

    A couple fo questions about class generation:

    1) Is it possible to trigger (from within Eclipse) an automated build of
    the classes when the model file changes? I had this with
    WebObjects/WOLips
    and it's such nice feature.
    No :-(

    But I haven't found it to be much of an issue. It's pretty easy to
    generate the classes from the Modeler menu, or from an ant target. I do it
    both ways, but use ant more often now since it always has the right
    settings.

    If you are using ant, the setup could look like this:

    <path id="cgen.classpath">
    <fileset dir="path/to/cayenne" includes="cayenne-server*.jar" />
    <fileset dir="path/to/cayenne" includes="cayenne-di*.jar" />
    <fileset dir="path/to/cayenne" includes="commons-*.jar" />
    <fileset dir="path/to/cayenne" includes="velocity-*.jar" />
    <fileset dir="path/to/cayenne-tools" includes="*.jar" />
    </path>
    <typedef resource="org/apache/cayenne/tools/antlib.xml">
    <classpath refid="cgen.classpath"/>
    </typedef>
    <target name="generate.entity.classes">
    <touch file="src/MyModel.map.xml" />
    <cgen map="src/MyModel.map.xml"
    superpkg="com.company.cayenne.auto"
    supertemplate="superclass.vm"
    template="subclass.vm"
    destDir="src"
    outputPattern="*.java"
    encoding="UTF-8"
    mode="all"
    />
    </target>

    You may be able to add an eclipse "builder" to do it automatically - not
    sure..


    2) I can't figure out how to get the modeler to build classes into the
    right directories honoring packages. It seems like if I choose the
    "packages" option (I can't remember the specific name) it doesn't end up
    in
    the right place. I'm sure I just misunderstand the options.
    Do you have the "Use package path" box checked at the bottom of the
    generate classes window?


    -Lon
  • Andrus Adamchik at Aug 8, 2014 at 6:55 am
    Works semi-automatically for me. I put a declaration for “cgen” in my Maven pom. After a model change I do refresh in Eclipse, and this triggers Maven invocation. Then I have to do refresh again, so I can see the changes. Having said that I am +1 on CAY-1723.

    Andrus
    On Aug 7, 2014, at 9:49 PM, John Huss wrote:
    On Thu, Aug 7, 2014 at 12:35 PM, Lon Varscsak wrote:

    Hey guys,

    A couple fo questions about class generation:

    1) Is it possible to trigger (from within Eclipse) an automated build of
    the classes when the model file changes? I had this with WebObjects/WOLips
    and it's such nice feature.
    No :-(

    But I haven't found it to be much of an issue. It's pretty easy to
    generate the classes from the Modeler menu, or from an ant target. I do it
    both ways, but use ant more often now since it always has the right
    settings.

    If you are using ant, the setup could look like this:

    <path id="cgen.classpath">
    <fileset dir="path/to/cayenne" includes="cayenne-server*.jar" />
    <fileset dir="path/to/cayenne" includes="cayenne-di*.jar" />
    <fileset dir="path/to/cayenne" includes="commons-*.jar" />
    <fileset dir="path/to/cayenne" includes="velocity-*.jar" />
    <fileset dir="path/to/cayenne-tools" includes="*.jar" />
    </path>
    <typedef resource="org/apache/cayenne/tools/antlib.xml">
    <classpath refid="cgen.classpath"/>
    </typedef>
    <target name="generate.entity.classes">
    <touch file="src/MyModel.map.xml" />
    <cgen map="src/MyModel.map.xml"
    superpkg="com.company.cayenne.auto"
    supertemplate="superclass.vm"
    template="subclass.vm"
    destDir="src"
    outputPattern="*.java"
    encoding="UTF-8"
    mode="all"
    />
    </target>

    You may be able to add an eclipse "builder" to do it automatically - not
    sure..


    2) I can't figure out how to get the modeler to build classes into the
    right directories honoring packages. It seems like if I choose the
    "packages" option (I can't remember the specific name) it doesn't end up in
    the right place. I'm sure I just misunderstand the options.
    Do you have the "Use package path" box checked at the bottom of the
    generate classes window?


    -Lon

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriescayenne
postedAug 7, '14 at 5:35p
activeAug 8, '14 at 6:55a
posts5
users3
websitecayenne.apache.org

People

Translate

site design / logo © 2021 Grokbase