gxt工程打包脚本

本文介绍了一个使用Ant进行构建的项目配置文件build.xml的具体内容,包括项目的构建流程、依赖管理和资源复制等关键步骤。该脚本支持不同类型的构建目标,并详细展示了如何利用Ant任务来实现这些目标。
摘要由CSDN通过智能技术生成
  1. build.xml

 

<?xml version="1.0" encoding="UTF-8"?>

<project name="${product.name}" default="dev" basedir="./" xmlns:axis="antlib:org.apache.axis">

<!--typedef resource="org/tigris/subversion/svnant/svnantlib.xml" /--> 

 

<taskdef resource="net/sf/antcontrib/antlib.xml"></taskdef>

<!--

<taskdef name="dbunit" classname="org.dbunit.ant.DbUnitTask"/>

-->

<property environment="evn"/>

<!--

<target name="check-evn-set" nuless="evn.JAVA_HOME">

<fail message="JAVA_HOME must be set!" />

</target> 

    --> 

 

<!---->

<property file="build.properties" />

 

 

<!-- Product name -->

<property name="product.name" value="${product.name}" />

<property name="jar.name" value="${project.perfix}-${product.name}" />

<property name="war.name" value="${project.perfix}-${product.name}" />

<!-- What version are we building -->

<property name="product.version" value="${product.version}" />

<property name="user.name" value="${user.name}" />

<property name="company.name" value="${company.name}" />

 

<!-- Subervsion properties >

<property name="svn.project.base" value="https://192.168.32.4/svn/integrationPlatform/CMP/Portal" />

<property name="svn.deploy.url" value="${svn.project.base}/Trunk/Deploy" />

<property name="svn.project.url" value="${svn.project.base}/Trunk/${product.name}" />

<property name="svn.release.branch.url" value="${svn.project.base}/Release/${version}" />

<property name="svn.build.branch.url" value="${svn.project.base}/Build/${version}" /-->

 

<!--

     The directories where all the source information is located

     that is used to populate the target directory.

    -->

<property name="sourceDir" location="." />

<property name="javaSrcDir" location="${sourceDir}/src/main/java" />

<property name="javaResource" location="${sourceDir}/src/main/resources" />

 

<property name="webroot" location="${sourceDir}/war" />

<!--

     The directory where all the intermediate stuff ends up.

     The target directory should contain all of the content that

     other dependent build might need.

    -->

<property name="targetDir" location="${sourceDir}/target" />

<property name="targetTmp" location="${targetDir}/" />

<property name="targetClasses" location="${webroot}/WEB-INF/classes" />

<property name="targetLib" location="${webroot}/WEB-INF/lib" />

 

<property name="targetJar" location="${targetTmp}/jar" />

<property name="targetWar" location="${targetTmp}/" />

<property name="targetDoc" location="${targetTmp}/javadoc" />

<property name="testClasses" location="${targetTmp}/classes/test" />

<property name="testReport" location="${targetTmp}/report" />

 

<!-- this property is used by the label target to record 

         module and build information -->

<property name="build.info.dir" location="${targetDir}/${product.name}" />

 

<!--Load properties that are common across builds.  These typically

         contain the filesystem location for each build.

         Note: If you wish to override any values that are in commonProperties, then you

         must define them before the below line. 

<property file="${commonProperties}" />-->

 

<!-- Import the build targets 

         These provide usefull ant targets.  If you need to override one of the 

         targets that build.targets provides, then just define a target in your

         build file that has the same name. 

<import file="${build.targets}" />-->

 

<!-- Project compile time dependencies -->

<!--

<property name="thirdParty" location="../Jar" />

<property name="internalParty" location="../Deploy" />

    -->

  <!-- Configure path to GWT SDK -->

  <property name="project.name" value="${product.name}" />

  <property name="gwt.sdk" location="${gwt.sdk}" />

  <property name="gxt.sdk" location="${gxt.sdk}" />

 

 

<!-- Compile Classpath -->

<path id="compile.libs.path">

<pathelement location="${gwt.sdk}/gwt-user.jar"/>

<fileset dir="${gwt.sdk}" includes="gwt-dev*.jar"/>

<!-- Add any additional non-server libs (such as JUnit) -->

<!--

<fileset dir="war/WEB-INF/lib" includes="**/*.jar"/>

-->

<fileset dir="${webroot}/WEB-INF/lib" includes="**/*.jar" />

<!--

<fileset dir="${internalParty}" includes="${internal.include.jar}" excludes="${internal.exclude.jar}" />

-->

</path>

<path id="classpath.run">

<path refid="compile.libs.path" />

<pathelement path="${targetClasses}"/>

</path>

    <path id="classpath.test">

        <path refid="compile.libs.path" />

<pathelement path="${testClasses}"/>

    </path>

 

 

<!-- The main target.  Causes everything to happen -->

<target name="main" depends="init,clean,copy,compile,jar,doc" />

<target name="dev" depends="dev.init,dev.build,dev.publish" />

<target name="dev.init" depends="init" />

<target name="dev.build" depends="clean,copy,compile,gwtc,jar,war" />

<target name="dev.publish" depends="deploy" />

<target name="cc" depends="cc.init,cc.build,cc.publish" />

<target name="cc.init" depends="init" />

<target name="cc.build" depends="clean,copy,compile,gwtc,jar,war" />

<target name="cc.publish" depends="deploy" />

 

 

<!--

     Initialization.

     Sets the timestamp.  (This is done because the Ant documentation

     says its a good idea to do it.  We don't currently use the timestamp

     for anything.)

     Defines the Carefx custom tasks.

    -->

<target name="init">

<echo message="init" />

<tstamp>

<format property="TODAY" pattern="MM/dd/yyyy HH:mm" />

</tstamp>

<!--defaultexcludes add=".svn/**" />-->

<defaultexcludes add="**/.svn/**" />

</target>

 

<!-- Delete everything there is.  Forces a clean build. -->

<target name="clean"  >

<echo message="clean target" />

<delete includeEmptyDirs="true" quiet="true">

<fileset defaultexcludes="no" dir="${targetDir}/" />

<fileset defaultexcludes="no" dir="${targetClasses}/" />

</delete>

<echo message="clean war" />

<delete includeEmptyDirs="true"  quiet="true">

<fileset  dir="war/${EntryPointClass}"  />

        </delete>

</target>

<!-- Copy necessary files -->

<target name="copy" >

<echo message="copy" />

<!--  Copy the resource files  -->

<mkdir dir="${targetClasses}" />

<copy todir="${targetClasses}">

<fileset dir="${javaResource}" />

</copy>

<copy todir="${targetClasses}">

<fileset dir="${javaSrcDir}" includes="**/*.xml" />

</copy>

</target>

 

<!-- Compile the java class  -->

<target name="compile" >

<echo message="compile" />

<mkdir dir="${targetClasses}" />

<javac srcdir="${javaSrcDir}" destdir="${targetClasses}" encoding="UTF-8" excludes="**/*.html" debug="on" deprecation="on" >

<classpath refid="compile.libs.path" />

</javac>

</target>

 

 

<target name="gwtc" depends="compile" description="GWT compile to JavaScript">

<java failοnerrοr="true" fork="true" classname="com.google.gwt.dev.Compiler">

 <classpath>

<pathelement location="${javaSrcDir}"/>

<path refid="compile.libs.path"/>

 </classpath>

 <!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->

 <jvmarg value="-Xmx256M"/>

 <!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->

 <arg value="${EntryPointClass}"/>

</java>

 </target>

 

 

<!-- Make the java doc -->

<target name="doc" >

<echo message="doc" />

<mkdir dir="${targetTmp}/javadoc" />

<path id="docSrcPath">

<pathelement location="${javaSrcDir}" />

</path>

<javadoc sourcepathref="docSrcPath" destdir="${targetTmp}/javadoc" packagenames="net.carefx.*" Windowtitle="Carefx Managerment Platform Java Documentation" charset="UTF-8" encoding="UTF-8" docencoding="UTF-8" failοnerrοr="true">

<classpath refid="compile.libs.path" />

</javadoc>

<mkdir dir="${targetDoc}" />

</target>

 

 

<!-- Make the config jar file for other product team -->

<target name="jar" >

<mkdir dir="${targetJar}" />

<tstamp>

<format property="build.date" pattern="EEEE, d MMMM yyyy"/>

<format property="build.time" pattern="hh:mm a"/>

</tstamp>   

<jar jarfile="${targetJar}/${jar.name}.jar"  basedir="${targetClasses}" includes="**/*.class,**/*.xml,**/*.xsd" excludes="**/*portal*/**,">

<manifest>

<attribute name="Built-By" value="${user.name}" />

<attribute name="Specification-Title" value="${product.name}"/>  

<attribute name="Specification-Version" value="${product.version}"/>  

<attribute name="Specification-Vendor" value="${companyName}"/>  

<section name="common">

<attribute name="Implementation-Title" value="${product.name}" />

<attribute name="Implementation-Version" value="${product.version} ${TODAY}" />

<attribute name="Implementation-Vendor" value="${companyName}" />

</section>

</manifest>

</jar>

</target>

 

 

<target name="war" description="Create a war file">

<echo message="war" />

<delete file="${targetWar}/${war.name}.war"/>

<!--

<zip destfile="${targetDir}/${project.name}.war" basedir="war"/>

-->

 

<!--WebService

<copy todir="${targetWeb}/WEB-INF/services">

<fileset dir="${cmpWebServicesAar}" includes="*.aar"/>

</copy>

-->

<manifest file="MANIFEST.MF">

<attribute name="Built-By" value="${user.name}" />

<section name="common">

<attribute name="Implementation-Title" value="${product.name}" />

<attribute name="Implementation-Version" value="${version} ${TODAY}" />

<attribute name="Implementation-Vendor" value="${CompanyName}" />

</section>

</manifest>

<war destfile="${targetWar}/${war.name}.war" webxml="${webroot}/WEB-INF/web.xml" manifest="MANIFEST.MF">

<fileset dir="${webroot}">

<exclude name="${webroot}/WEB-INF/lib/*.jar"/>

<exclude name="${webroot}/WEB-INF/classes/*.class"/>

</fileset>

<!--

<lib dir="${thirdParty}">

<include name="${internal.include.jar}"/>

<exclude name="${internal.exclude.jar}"/>

</lib>

<lib dir="${internalParty}">

<include name="${internal.include.jar}"/>

<exclude name="${internal.exclude.jar}"/>

</lib>

-->

</war>

</target>

<target name="deploy">

<echo message="deploy" />

<!--

<copy todir="${internalParty}">

<fileset dir="${targetJar}" />

<fileset file="${targetWar}/${war.name}.war" />

</copy>

-->

</target>

 

<target name="devmode" depends="compile" description="Run development mode">

<java failοnerrοr="true" fork="true" classname="com.google.gwt.dev.DevMode">

 <classpath>

<pathelement location="${javaSrcDir}"/>

<path refid="compile.libs.path"/>

 </classpath>

 <jvmarg value="-Xmx256M"/>

 <arg value="-startupUrl"/>

 <arg value="index.html"/>

 <!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->

 <arg value="${EntryPointClass}"/>

</java>

   </target>

 

   <target name="hosted" depends="devmode" description="Run development mode (NOTE: the 'hosted' target is deprecated)" />

<!--

Test targets suppressed because -junit argument was not specified when running webAppCreator.

 

  <target name="javac.tests" depends="javac" description="Compiles test code">

    <javac srcdir="test" includes="**" encoding="utf-8"

      source="1.5" target="1.5" nowarn="true"

      debug="true" debuglevel="lines,vars,source">

      <classpath location="path_to_the_junit_jar"/>

      <classpath refid="project.class.path"/>

    </javac>

  </target>

 

  <target name="test.dev" depends="javac.tests" description="Run development mode tests">

    <mkdir dir="reports/htmlunit.dev" />

    <junit fork="yes" printsummary="yes" haltonfailure="yes">

      <jvmarg line="-Xmx256m" />

      <sysproperty key="gwt.args" value="-logLevel WARN" />

      <sysproperty key="java.awt.headless" value="true" />

      <classpath>

        <pathelement location="src" />

        <pathelement location="test" />

        <path refid="project.class.path" />

        <pathelement location="path_to_the_junit_jar" />

      </classpath>

      <batchtest todir="reports/htmlunit.dev" >

        <fileset dir="test" >

          <include name="**/*Test.java" />

        </fileset>

      </batchtest>

      <formatter type="plain" />

      <formatter type="xml" />

    </junit>

  </target>

 

  <target name="test.prod" depends="javac.tests" description="Run production mode tests">

    <mkdir dir="reports/htmlunit.prod" />

    <junit fork="yes" printsummary="yes" haltonfailure="yes">

      <jvmarg line="-Xmx256m" />

      <sysproperty key="gwt.args" value="-prod -logLevel WARN -out www-test" />

      <sysproperty key="java.awt.headless" value="true" />

      <classpath>

        <pathelement location="src" />

        <pathelement location="test" />

        <path refid="project.class.path" />

        <pathelement location="path_to_the_junit_jar" />

      </classpath>

      <batchtest todir="reports/htmlunit.prod" >

        <fileset dir="test" >

          <include name="**/*Test.java" />

        </fileset>

      </batchtest>

      <formatter type="plain" />

      <formatter type="xml" />

    </junit>

  </target>

 

  <target name="test" description="Run development and production mode tests">

    <antcall target="test.dev" />

    <antcall target="test.prod" />

  </target>

-->

 

<!-- Finialization >

<target name="final" >

<echo message="final" />

<trycatch property="GetBuildError">  

        <try>  

           <svn username="${svn.authz.user}" password="${svn.authz.passwd}">

<delete url="${svn.deploy.url}/${product.name}" message="import-lib-to-svn" force="true" />

            </svn>  

        </try>  

        <catch>   

           <echo message="direction not exist"/>

           <echo message="URL: ${svn.deploy.url}/${product.name}"/>    

        </catch>  

        <finally>  

           <svn username="${svn.authz.user}" password="${svn.authz.passwd}">

<import url="${svn.deploy.url}/${product.name}" path="${targetDir}"  message="import-lib-to-svn" />

</svn>

        </finally>  

</trycatch>

<trycatch property="GetBuildError">  

        <try>  

           <svn username="${svn.authz.user}" password="${svn.authz.passwd}">

<delete url="${svn.deploy.url}/Jar/${jar.name}.jar" message="import-lib-to-svn" force="true" />

            </svn>  

        </try>  

        <catch>   

           <echo message="direction not exist"/>

           <echo message="URL: ${svn.deploy.url}/Jar/${jar.name}.jar"/>    

        </catch>  

        <finally>  

           <svn username="${svn.authz.user}" password="${svn.authz.passwd}">

<import url="${svn.deploy.url}/Jar" path="${targetJar}"  message="import-lib-to-svn" />

</svn>

        </finally>  

</trycatch>

</target -->

</project>

  1. build.properties

 

#工程前缀

project.perfix=empi

#工程名称

product.name=webconsole

#工程版本号

product.version=1.0

user.name=

#公司名称

company.name=supcon

 

 

thirdParty.include.jar=*.jar

thirdParty.exclude.jar=

 

 

internal.include.jar=*.jar

internal.exclude.jar=

#工程主模块

EntryPointClass=com.supcon.empi.console.index.Index

#gwt软件包地址

gwt.sdk=D:/software_files/gwt-2.0.3/gwt-2.0.3

#gxt软件包地址

gxt.sdk=D:/software_files/gxt-2.1.1-gwt2/gxt-2.1.1

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值