Subversion Repositories bacoAlunos

Rev

Blame | Last modification | View Log | RSS feed

<?xml version="1.0"?>
<project name="Hibernate" default="compile" basedir=".">

        <import file="libs.xml"/>


        <taskdef
                        resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
                <classpath>
                        <!--<pathelement location="${aspectj}/aspectj-ant.jar"/>-->
                        <pathelement location="lib/aspectj/aspectjtools.jar"/>
                </classpath>
        </taskdef>


        <target name="compile">
                <delete dir="build/ant/classes"/>
                <mkdir dir="build/ant/classes"/>


        <iajc  source="1.8" target="1.8" destdir="build/ant/classes" classpath="lib/aspectj/aspectjrt.jar" classpathref="pathref">
            <sourceroots>
                <pathelement location="src/java"/>
                <pathelement location="src/gen"/>
            </sourceroots>
        </iajc>



                <copy file="conf/hibernate.cfg.xml" todir="build/ant/classes/pt/estgp/es/exemplos/hibernate"/>
                <copy file="conf/log4j.properties" todir="build/ant/classes"/>
                <copy todir="build/ant/classes">
                        <fileset dir="src/java">
                                <include name="**/*.hbm.xml"/>
                        </fileset>
                </copy>

        <copy file="conf/jdbc.properties" todir="build/ant/classes/pt/estgp/es/exemplos/hibernate"/>
        <replace file="build/ant/classes/pt/estgp/es/exemplos/hibernate/jdbc.properties">
            <replacefilter token="@database.username@" value="${database.username}"/>
            <replacefilter token="@database.password@" value="${database.password}"/>
            <replacefilter token="@database.connection.url@" value="${database.connection.url}"/>
        </replace>
        <replace file="build/ant/classes/pt/estgp/es/exemplos/hibernate/hibernate.cfg.xml">
        <replacefilter token="@database.username@" value="${database.username}"/>
        <replacefilter token="@database.password@" value="${database.password}"/>
        <replacefilter token="@database.connection.url@" value="${database.connection.url}"/>
        <replacefilter token="@hibernate.show.sql@" value="${hibernate.show.sql}"/>
        </replace>

        </target>

        <target name="build.war" depends="compile">
                <delete dir="build/ant/war"/>
                <mkdir dir="build/ant/war"/>
                <copy todir="build/ant/war">
                        <fileset dir="src/web">
                                <include name="**/*.*"/>
                        </fileset>
                </copy>
                <mkdir dir="build"/>
                <mkdir dir="build/ant"/>
                <mkdir dir="build/ant/war"/>
                <mkdir dir="build/ant/war/WEB-INF"/>
                <mkdir dir="build/ant/war/WEB-INF/classes"/>
                <mkdir dir="build/ant/war/WEB-INF/lib"/>
        <mkdir dir="build/ant/war/WEB-INF/tlds"/>
                <copy todir="build/ant/war/WEB-INF" file="conf/web/web.xml"/>
                <copy todir="build/ant/war/WEB-INF/classes">
                        <fileset dir="build/ant/classes">
                                <include name="**/*.*"/>
                        </fileset>
                </copy>

        <copy todir="build/ant/war/WEB-INF">
            <fileset dir="conf/web">
                <include name="**/*.*"/>
            </fileset>
        </copy>

        <copy todir="build/ant/war/WEB-INF/lib">
            <fileset dir="lib/aspectj">
                <include name="*.*"/>
            </fileset>
            <fileset dir="lib/struts">
                <include name="*.*"/>
            </fileset>
            <fileset dir="lib/commons">
                <include name="*.*"/>
            </fileset>
            <fileset dir="lib/dom4j">
                <include name="*.*"/>
            </fileset>
            <fileset dir="lib/hibernate/hibernate3">
            <include name="*.*"/>
            </fileset>
            <fileset dir="lib/hibernate/mysql">
                <include name="*.*"/>
            </fileset>
            <fileset dir="lib/log4j">
                <include name="*.*"/>
            </fileset>
        </copy>
                <delete file="build/ant/${tomcat.war.filename}"/>
                <jar destfile="build/ant/${tomcat.war.filename}">
                        <fileset dir="build/ant/war">
                            <include name="**/*.*"/>
                        </fileset>
                </jar>

        <!--<copy file="build/ant/${tomcat.war.filename}" todir="${tomcat.home}/webapps" overwrite="true"/>-->
               
        </target>
       
        <target name="create.context.tomcat.file">
                <copy file="conf/tomcat/project.xml" todir="build/ant" overwrite="true"/>
                <replace file="build/ant/project.xml">
            <replacefilter token="@build.dir.war@" value="${basedir}${file.separator}build${file.separator}ant${file.separator}war${file.separator}"/>
            <replacefilter token="@context.path@" value="${web.path}"/>
        </replace>
        </target>
       
        <target name="testar" depends="compile">
                <java classname="pt.estgp.es.exemplos.hibernate.Main"  classpath="build/ant/classes" classpathref="pathref"/>
        </target>

    <target name="generateUpdateHibernateSql" depends="compile">
        <schemaupdate
               properties="build/ant/classes/pt/estgp/es/exemplos/hibernate/jdbc.properties"
               quiet="no"
               text="no">
            <fileset dir="src/java">
                <include name="**/*.hbm.xml"/>
            </fileset>
        </schemaupdate>
    </target>

    <target name="generateHibernateDomainObjects">
        <mkdir dir="src/gen"/>
        <replace dir="src/java" value="">
            <include name="**/*.hbm.xml"/>
            <replacefilter token='&lt;timestamp source="db"' value="&lt;timestamp"/>
        </replace>

        <hibernatetool>
            <configuration>
                <fileset dir="src/java">
                    <include name="**/*.hbm.xml"/>
                </fileset>
            </configuration>
            <hbm2java
                   jdk5="true"
                   ejb3="false"
                   destdir="src/gen"/>
        </hibernatetool>
        <delete>
            <fileset dir="src/gen">
                <include name="**/*Impl.java"/>
            </fileset>
        </delete>
        <replace dir="src/java" value="">
            <include name="**/*.hbm.xml"/>
            <replacefilter token='&lt;timestamp' value='&lt;timestamp source="db"'/>
        </replace>
    </target>

    <!--codigo para gerar metricas que as apresenta num ficheiro .txt-->
    <target name="generateMetrics">
        <taskdef name="ckjm" classname="gr.spinellis.ckjm.ant.CkjmTask">
            <classpath>
                <pathelement location="lib/metricas/ckjm-1.9.jar"/>
            </classpath>
        </taskdef>
        <ckjm outputfile="metricas-desenho-ckjm.txt" format="plain" classdir="build/ant/classes">
            <include name="**/*.class" />
            <exclude name="**/*Test.class" />
            <extdirs path="lib" />
        </ckjm>
    </target>

</project>