Re: Still problems to create Ant task

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri Oct 13 2006 - 14:53:23 EDT

  • Next message: Tore Halset: "Re: context - in thread or session?"

    I just created a small test project and it seems to work just fine.
    The jar path includes cayenne.jar, task.jar and driver.jar.

    Andrus

    public class TestTask extends Task {

            protected File cayenneProject;

            public void setCayenneProject(File cayenneProject) {
                    this.cayenneProject = cayenneProject;
            }

            public void execute() throws BuildException {
                    Configuration c = new FileConfiguration(cayenneProject);
                    Configuration.initializeSharedConfiguration(c);

                    DataNode node = (DataNode) c.getDomain().getDataNodes().iterator()
                                    .next();
                    DataMap map = (DataMap) c.getDomain().getDataMaps().iterator().next();

                    DbGenerator gen = new DbGenerator(node.getAdapter(), map);
                    try {
                            gen.runGenerator(node.getDataSource());
                    } catch (Exception e) {
                            throw new BuildException(e);
                    }
            }
    }

    <project name="test" default="d">

            <path id="lib.path">
                    <fileset dir="lib" includes="*.jar" />
            </path>

            <target name="d">
                    <taskdef name="x" classname="test.TestTask" classpathref="lib.path"/>
                    <x cayenneProject="src/cayenne.xml"/>
            </target>
    </project>

    On Oct 13, 2006, at 1:40 PM, DOMINGUEZ Felipe wrote:

    > Hello.
    >
    > I am still having problems building an ant task that uses cayenne.
    >
    > I use the FileConfiguration class,
    >
    >
    >
    > FileConfiguration conf = new FileConfiguration("cayenne.xml");
    >
    > conf.addClassPath("pathToCayenneDir");
    >
    > Configuration.initializeSharedConfiguration(conf);
    >
    >
    >
    > but it throws a
    >
    > java.lang.ClassNotFoundException:
    > org.apache.cayenne.dba.hsqldb.HSQLDBAdapter
    >
    >
    >
    > in Configuration.initializeSharedConfiguration(conf);
    >
    >
    >
    >
    >
    > the class path use to run the ant task is OK, and I can even
    > instantiate
    > the class using
    >
    > Class.forName("org.apache.cayenne.dba.hsqldb.HSQLDBAdapter");
    >
    >
    >
    > can any body send and example or point me to a tutorial where I can
    > find
    > out what is going on.
    >
    > I did not find anything.
    >
    >
    >
    > cheers
    >
    > Felipe
    >
    >
    > ____
    >
    > This message and any files transmitted with it are legally
    > privileged and intended for the sole use of the individual(s) or
    > entity to whom they are addressed. If you are not the intended
    > recipient, please notify the sender by reply and delete the message
    > and any attachments from your system. Any unauthorised use or
    > disclosure of the content of this message is strictly prohibited
    > and may be unlawful.
    >
    > Nothing in this e-mail message amounts to a contractual or legal
    > commitment on the part of EUROCONTROL, unless it is confirmed by
    > appropriately signed hard copy.
    >
    > Any views expressed in this message are those of the sender.
    >



    This archive was generated by hypermail 2.0.0 : Fri Oct 13 2006 - 14:53:50 EDT