开发者

Issue with maven ant plugin for generating hbm files in hibernate using Xdoclet

开发者 https://www.devze.com 2023-04-11 15:38 出处:网络
I am trying to generate hbm files using ant task with maven, however it\'s running into issues related to classpath. (I am doing this to migrate the project from ant to maven and do not want to change

I am trying to generate hbm files using ant task with maven, however it's running into issues related to classpath. (I am doing this to migrate the project from ant to maven and do not want to change the way hibernate works in the first step). If someone knows a better way to handle this, that would also be helpful. My pom.xml looks like

            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.6</version>
            <dependencies>
                <dependency>
                    <groupId>org.apache.ant</groupId>
                    <artifactId>ant-nodeps</artifactId>
                    <version>1.8.1</version>
                </dependency>
                <dependency>
                    <groupId>xdoclet</groupId>
                    <artifactId>xdoclet-hibernate-module</artifactId>
                    <version>1.2.3</version>
                </dependency>
                <dependency>
                    <groupId>xjavadoc</groupId>
                    <artifactId>xjavadoc</artifactId>
                    <version>1.1</version>
                </dependency>
                <dependency>
                    <groupId>xdoclet</groupId>
                    <artifactId>xdoclet-xdoclet-module</artifactId>
                    <version>1.2.3</version>
                </dependency>
                <dependency>
                    <groupId>org.codehaus.xdoclet</groupId>
                    <artifactId>xdoclet</artifactId>
                    <version>2.0.7</version>
                </dependency>
                <dependency>
                    <groupId>commons-collections</groupId>
                    <artifactId>commons-collections</artifactId>
                    <version>20040616</version>
                </dependency>
                <dependency>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                    <version>1.1.1</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <phase> generate-sources</phase>
                    <configuration>
                        <target name="generate-hibernate" unless="hibernatedoclet.unnecessary">
                            <echo level="info">generating hibernate files</echo>
                            <taskdef name="hibernatedoclet"
                                classname="xdoclet.modules.hibernate.HibernateDocletTask"
                                classpathref="maven.plugin.classpath" />
                            <hibernatedoclet destdir="${project.build.directory}"
                                force="ture" verbose="true">
                                <fileset id="hbm" dir="${basedir}/src/main/java">
                        开发者_运维知识库            <include name="**/model/*.java" />
                                </fileset>
                                <hibernate version="3.0" />
                            </hibernatedoclet>
                        </target>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

The exception that I am getting is

   Can't create a hibernate element under hibernatedoclet. Make sure the jar file containing    the corresponding subtask class is on the classpath specified in the <taskdef> that defined {2}.
    at xdoclet.DocletTask.createDynamicElement(DocletTask.java:343)
    at org.apache.tools.ant.IntrospectionHelper.createDynamicElement(IntrospectionHelper.java:57
    at org.apache.tools.ant.IntrospectionHelper.getNestedCreator(IntrospectionHelper.java:542)
    at org.apache.tools.ant.IntrospectionHelper.getElementCreator(IntrospectionHelper.java:637)
    at org.apache.tools.ant.UnknownElement.handleChild(UnknownElement.java:552)
    at org.apache.tools.ant.UnknownElement.handleChildren(UnknownElement.java:349)
    at org.apache.tools.ant.UnknownElement.configure(UnknownElement.java:201)
    at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:163)
    at org.apache.tools.ant.Task.perform(Task.java:347)
    at org.apache.tools.ant.Target.execute(Target.java:390)
    at org.apache.tools.ant.Target.performTasks(Target.java:411)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1397)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1366)
    at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:270)


As the error says

Can't create a hibernate element under hibernatedoclet

I guess you need to add hibernate to your maven ant plugin dependency.

0

精彩评论

暂无评论...
验证码 换一张
取 消