<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    jinfeng_wang

    G-G-S,D-D-U!

    BlogJava 首頁(yè) 新隨筆 聯(lián)系 聚合 管理
      400 Posts :: 0 Stories :: 296 Comments :: 0 Trackbacks

     

    <?xml version="1.0"?>
    <project name="Harnessing Hibernate: The Developer's Notebook"
             default
    ="db" basedir=".">

      
    <!-- Set up properties containing important project directories -->
      
    <property name="source.root" value="src"/>
      
    <property name="class.root" value="classes"/>
      
    <property name="lib.dir" value="lib"/>
      
    <property name="data.dir" value="data"/>

      
    <!-- Set up the class path for compilation and execution -->
      
    <path id="project.class.path">
          
    <!-- Include our own classes, of course -->
          
    <pathelement location="${class.root}" />
          
    <!-- Include jars in the project library directory -->
          
    <fileset dir="${lib.dir}">
            
    <include name="*.jar"/>
          
    </fileset>
      
    </path>

      
    <target name="db" description="Runs HSQLDB database management UI
    against the database file--use when application is not running"
    >
          
    <java classname="org.hsqldb.util.DatabaseManager"
                fork
    ="yes">
             
    <classpath refid="project.class.path"/>
             
    <arg value="-driver"/>
             
    <arg value="org.hsqldb.jdbcDriver"/>
             
    <arg value="-url"/>
             
    <arg value="jdbc:hsqldb:${data.dir}/music"/>
             
    <arg value="-user"/>
             
    <arg value="sa"/>
          
    </java>
      
    </target>

      
    <!-- Teach Ant how to use Hibernate's code generation tool -->
      
    <taskdef name="hbm2java"
               classname
    ="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
               classpathref
    ="project.class.path"/>

      
    <!-- Generate the java code for all mapping files in our source tree -->
      
    <target name="codegen"
              description
    ="Generate Java source from the O/R mapping files">
        
    <hbm2java output="${source.root}">
          
    <fileset dir="${source.root}">
            
    <include name="**/*.hbm.xml"/>
          
    </fileset>
        
    </hbm2java>
      
    </target>

      
    <!-- Create our runtime subdirectories and copy resources into them -->
      
    <target name="prepare" description="Sets up build structures">
        
    <mkdir dir="${class.root}"/>

        
    <!-- Copy our property files and O/R mappings for use at runtime -->
        
    <copy todir="${class.root}" >
          
    <fileset dir="${source.root}" >
            
    <include name="**/*.properties"/>
            
    <include name="**/*.hbm.xml"/>
          
    </fileset>
        
    </copy>
      
    </target>

      
    <!-- Compile the java source of the project -->
      
    <target name="compile" depends="prepare"
              description
    ="Compiles all Java classes">
        
    <javac srcdir="${source.root}"
               destdir
    ="${class.root}"
               debug
    ="on"
               optimize
    ="off"
               deprecation
    ="on">
          
    <classpath refid="project.class.path"/>
        
    </javac>
      
    </target>

      
    <!-- Generate the schemas for all mapping files in our class tree -->
      
    <target name="schema" depends="compile"
              description
    ="Generate DB schema from the O/R mapping files">

        
    <!-- Teach Ant how to use Hibernate's schema generation tool -->
        
    <taskdef name="schemaexport"
                 classname
    ="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask"
                 classpathref
    ="project.class.path"/>

        
    <schemaexport properties="${class.root}/hibernate.properties"
                      quiet
    ="no" text="no" drop="no">
          
    <fileset dir="${class.root}">
            
    <include name="**/*.hbm.xml"/>
          
    </fileset>
        
    </schemaexport>
      
    </target>

    </project>

     

    You may be wondering why the taskdef for the schema update tool is inside our schema target, rather than at the top of the build file, next to the one for hbm2java. Well, I wanted it up there too, but I ran into a snag that's worth explaining. I got strange error messages the first time I tried to build the schema target, complaining there was no hibernate.properties on the class path and our compiled Track class couldn't be found. When I ran it again, it worked. Some detective work using ant -verbose revealed that if the classes directory didn't exist when the taskdef was encountered, Ant helpfully removed it from the class path. Since a taskdef can't have its own dependencies, the solution is to move it into the schema target, giving it the benefit of that target's dependencies, ensuring the classes directory exists by the time the taskdef is processed.

    也許你會(huì)奇怪,為何找了schema更新工具的taskdef會(huì)在schema的target中進(jìn)行定義,而不是在build文件的頂部,緊接著hbm2java進(jìn)行定義。剛開(kāi)始我也是那樣想的,這里我需要解釋一下這里的問(wèn)題。當(dāng)?shù)谝淮螛?gòu)建schema時(shí),我得到了許多莫名奇妙的錯(cuò)誤,報(bào)錯(cuò)信息是:在classpath中找不到hibernate.properties和Track類。但是再次構(gòu)建的時(shí)候,就可以了。當(dāng)使用命令“ant -verbose”時(shí),你就可以發(fā)現(xiàn)其中的細(xì)節(jié)之所在。如果在ant解析到taskdef時(shí),build文件中所使用的class目錄并不存在,那么ant就會(huì)自己將此目錄從classpath中移除。但是taskdef又無(wú)法定義自己的dependencies,因此這里不得不將其移入到schema target中,這樣也就可以使用到target的dependencies,保證在ant處理taskdef的時(shí)候,class目錄必然已經(jīng)存在。

    posted on 2005-04-01 10:22 jinfeng_wang 閱讀(1336) 評(píng)論(0)  編輯  收藏 所屬分類: hibernateant
    主站蜘蛛池模板: 国产免费MV大全视频网站| 亚洲精品乱码久久久久久蜜桃图片| 国产亚洲精品美女久久久久久下载| 久久亚洲免费视频| 夜色阁亚洲一区二区三区| 2020久久精品亚洲热综合一本| 久久国产精品国产自线拍免费| 国产免费131美女视频| 亚洲大片免费观看| 少妇性饥渴无码A区免费| 免费国产a国产片高清| 亚洲六月丁香婷婷综合| 91网站免费观看| 成年在线观看免费人视频草莓| 亚洲成Av人片乱码色午夜| 黄网站免费在线观看| 日韩欧毛片免费视频| 日韩免费视频播放| 久久久久亚洲精品天堂久久久久久| 国产亚洲免费的视频看| 亚洲一级毛片在线播放| 七次郎成人免费线路视频| 久久久久成人片免费观看蜜芽| 最新免费jlzzjlzz在线播放| 免费h黄肉动漫在线观看| 亚洲欧洲自拍拍偷午夜色无码| 亚洲精品无播放器在线播放| 亚洲香蕉免费有线视频| 免费人成激情视频在线观看冫| 亚洲AV无码乱码精品国产| 精品国产日韩亚洲一区91| 精品免费久久久久久成人影院 | 亚洲综合另类小说色区| 国产亚洲精品欧洲在线观看| 免费看片免费播放| 亚洲一区二区无码偷拍| 成人免费毛片内射美女APP| 亚洲第一成人在线| 91在线品视觉盛宴免费| 久久精品亚洲AV久久久无码| 日本zzzzwww大片免费|