当前位置: 首页 > news >正文

appfuse配置文件解读

● AppFuse的ant构建使用非常复杂,功能也非常强大,怎样能够充分的利用它,为我所用,在今后的开发中大幅度的减轻开发量,顾做此详细研究(其中不包括测试任务)。 build.xml的正常运行依赖以下文件i) propertie..

AppFuse的ant构建使用非常复杂,功能也非常强大,

怎样能够充分的利用它,为我所用,在今后的开发中大幅度的减轻开发量,顾做此详细研究(其中不包括测试任务)。

Ø build.xml的正常运行依赖以下文件

i) properties.xml

该文件定义build.xml所需的属性值,主要完成通过build.properties 产生

database.properties 文件定义构建工具需要的Classpath属性等工作。

ii) app-settings.xml

该文件定义设置应用程序状态的一些属性值

iii) build.properties

定义一些全局设置属性

Ø build.xml文件具体分析

<!DOCTYPE project [

<!ENTITY properties SYSTEM "properties.xml">

<!ENTITY app-settings SYSTEM "app-settings.xml">

]>

<!XML DTD定义propertiesapp-settings -->

<project name="dudu" basedir="." default="package-web">

<!导入配置文件properties.xml(其中主要处理classpath,jar文件位置定义)-->

<!-- import project-wide properties (classpath, jar file locations) -->

&properties;

<!导入配置文件app-settings.xml-->

&app-settings;

<!定义一些自定义任务,-->

<target name="init" description="defines custom tasks">

</target>

<!建立所需的目录:build/dudu;build/dudu/WEB-INF;dist/webapps-->

<target name="prepare" depends="build.properties.missing,init"

</target>

<!用定义的名字新建一个项目 -->

<!使用方法ant new -Dapp.name=NAME-Ddb.name=NAME -->

<!该任务会在上层目录中构建自定义名字应用程序,内容与本目录中的大致相同-->

<target name="new" depends="clean">

</target>

<!拷贝资源和配置文件:将web/WEB-INF/classes下的ApplicationResources_zh_CN.properties;log4j.properties等配置文件拷贝到build/web/classes下.

拷贝src/dao/packageName/applicationContext-hibernate.xml 到dudu/WEB-INF目录下,

拷贝src/service/packageName/applicationContext-service.xml到dudu/WEB-INF目录下.

在此任务中会进行native2ascii 的转码工作.

此任务比较有用,以后可以复用.

-->

<target name="copy-resources" depends="prepare">

<native2ascii src="http://dev.csdn.net/article/"web/WEB-INF/classes""

dest="${build.dir}/web/classes"

includes="ApplicationResources_zh_CN.properties" encoding="gb2312"/>

</target>

<!拷贝web目录下footer.jsp; pages/*.jsp;**/classes/**;**/*-resources.xml到

build/dudu/的对应目录下,拷贝时会自动建立相应的目录结构

-->

<target name="copy-web-files" depends="prepare">

</target>

<!拷贝所有页面与配置文件以形成web应用程序-->

<target name="stage-web"

depends="copy-resources,copy-web-files"

description="Calls other targets to gather static resources"/>

<!利用XDoclet根据POJO生成对应的hiberante映射文件

根据src/dao中的POJO生成映射文件,存放于build/dao/gen目录中.

此任务比较有用,以后可以复用.

执行此任务之前,需执行ant clean删除build目录

-->

<target name="hibernatedoclet" depends="prepare"

unless="hibernatedoclet.unnecessary"

description="Generate Hibernate mapping files">

<taskdef name="hibernatedoclet"

classname="xdoclet.modules.hibernate.HibernateDocletTask"

classpathref="http://dev.csdn.net/article/"xdoclet.classpath"/>

<!-- generate hibernate files -->

<hibernatedoclet

destdir="${build.dir}/dao/gen"

mergedir="metadata/dao"

excludedtags="@version,@author"

addedtags="@xdoclet-generated at ${TODAY}"

force="${xdoclet.force}">

<fileset dir="src/dao"/>

<hibernate validatexml="true" version="2.0"/>

</hibernatedoclet>

</target>

<!编译dao模块-->

<target name="compile-dao" depends="hibernatedoclet">

</target>

<!将编译好的dao模块打包成对应的jar文件,生成的jar文件存放在dist目录下-->

<target name="package-dao" depends="prepare,compile-dao"

</target>

<!编译service模块-->

<target name="compile-service" depends="package-dao"

description="Compile service module">

<antcall target="compile-module" inheritAll="true">

<param name="module" value="service"/>

<reference refid="service.compile.classpath"

torefid="http://dev.csdn.net/article/"compile.classpath"/>

<reference refid="service.test.classpath"

torefid="test.classpath"/>

</antcall>

</target>

<!打包service模块,日后开发自定义的模块可以参考此任务编译和打包-->

<target name="package-service" depends="compile-service">

<jar destfile="${dist.dir}/${webapp.name}-service.jar">

<manifest>

<attribute name="Class-Path"

value="${webapp.name}-dao.jar ${webapp.name}-service.jar"/>

</manifest>

<fileset dir="${build.dir}/service/classes" includes="**/*.class"/>

</jar>

</target>

<!根据POJO生成Struts 的ActionForms,生成的FormBean存放在build/web/gen下

此任务比较有用,以后可以复用

-->

<target name="gen-forms" depends="prepare" unless="webdoclet.uptodate">

</target>

<!利用webdoclet生成web.xml;struts-config.xml等web应用程序配置文件

生成的文件放在build/dudu/WEB-INF下

此任务比较有用,以后可以复用

-->

<target name="webdoclet" depends="compile-web"

unless="webdoclet.unnecessary">

</target>

<!打包web模块,处理build/dudu/WEB-INF/web.xml文件;

根据metadata/conf/tomcat-context.xml 产生dist/webapps/context.xml;

改变build/dudu/WEB-INF/ applicationContext-hibernate.xml中的路径,以便

dudu-dao.jar可以找到.hbm文件,

拷贝src/web/**/*.properties和*.xml文件到build/web/classes中,

将build/dudu下的文件打包成dist/dudu.war,其中包括build/web/classes中的文件

生成WEB-INF/classes中的文件,

dist/*.jar生成WEB-INF/lib中的文件

此任务比较有用,以后可以复用

-->

<target name="package-web" depends="compile-web,jsp-2">

</target>

<!所有编译任务都要调用的基本编译,接收其他任务的参数,编译相应的模块

输入参数:待编译模块名称,编译所需的路径.

编译后的文件存放于build/moduleName/classes中.

此任务比较有用,以后可以复用

-->

<target name="compile-module">

<!-- Inputs: module, compile.classpath, test.classpath -->

<echo level="info">Compiling ${module}...</echo>

<mkdir dir="${build.dir}/${module}/classes"/>

<mkdir dir="${test.dir}/${module}/classes"/>

<property name="excludes" value=""/>

<property name="additional.src.dirs" value=""/>

<javac srcdir="src/${module};${additional.src.dirs}"

destdir="${build.dir}/${module}/classes"

debug="${compile.debug}"

deprecation="${compile.deprecation}"

optimize="${compile.optimize}"

classpathref="http://dev.csdn.net/article/"compile.classpath"/>

</target>

<!

将数据库中的数据导出为xml文件

此任务比较有用,以后可以复用

-->

<target name="db-export" depends="prepare"

</target>

<!利用dbunit工具,根据metadata/sql/sample-data.xml 填充数据库表记录-->

<target name="db-load" depends="prepare"

</target>

<!

根据metadata/sql/${database.type}-create.sql中的sql语句建立数据库和用户

此任务比较有用,以后可以复用

-->

<target name="db-create" depends="init">

</target>

<!

根据映射hibernate映射文件生成数据库表

此任务比较有用,以后可以复用

-->

<target name="db-prepare" depends="clean,package-dao"

description="creates database tables">

<taskdef name="schemaexport"

classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask">

<classpath>

<path refid="xdoclet.classpath"/>

<path refid="hibernate.classpath"/>

</classpath>

</taskdef>

<antcall target="generate.database.properties"/>

<schemaexport quiet="no" text="no" drop="no" delimiter=";"

properties="database.properties" output="create-tables.sql">

<fileset dir="${build.dir}/dao/gen" includes="**/*.hbm.xml"/>

</schemaexport>

</target>

<!删除数据库中的表-->

<target name="db-drop" depends="hibernatedoclet">

</target>

<!删除目录-->

<target name="clean" description="Removes build artifacts">

<delete dir="${build.dir}"/>

</target>

<!生成JavaDoc,生成文件存放在E:\dudu\build\docs\api -->

<target name="javadoc" depends="java2html">

</target>

<!

将build/dudu下的文件拷贝到tomcat-home/webapps/dudu/,包括完整的目录和所有的

Jsp文件,但不包括jar文件和WEB-INF/classes中的文件,也不包括web.xml文件和

spring的配置文件这些文件不在build/dudu目录下.

-->

<target name="deploy-web" depends="stage-web" if="tomcat.home">

</target>

<!部署web应用,并解包war文件-->

<target name="deploy" depends="package-web" if="tomcat.home">

<unwar src="http://dev.csdn.net/article/"${webapp.dist}/${webapp.war}"

dest="${tomcat.home}/webapps/${webapp.name}"/>

</target>

<!删除web应用 -->

<target name="undeploy" if="tomcat.home">

<delete file="${tomcat.home}/webapps/${webapp.war}"/>

<delete dir="${tomcat.home}/webapps/${webapp.name}"/>

</target>

<!将war文件拷贝到tomcat容器-->

<target name="deploy-war" depends="package-web" if="tomcat.home">

<copy file="${webapp.dist}/${webapp.war}"

todir="${tomcat.home}/webapps"/>

</target>

</project>

Ø properties.xml文件分析

该文件定义build.xml所需的属性值。

<!导入lib.properties 文件,其中包括了构建时所需的jar文件定义-->

<property name="lib.dir" location="lib"/>

<property file="${lib.dir}/lib.properties"/>

<!加载build.properties 文件-->

<property file="build.properties"/>

<!加载运行unit tests所需的tomcat配置属性文件 -->

<property file="tomcat.properties"/>

<!-- webapp.name被定义在build.properties,在此做检查看该属性是否被定义-->

<target name="build.properties.missing" unless="webapp.name">

<fail message="missing build.properties file in current directory or in ${user.home}"/>

</target>

<!如果build.properties 不存在时,定义数据库的基本配置-->

<property name="database.jar" location="${mysql.jar}"/>

<!定义建立数据库时所用到的database URL,它被用在db-create任务中-->

<property name="database.url"

value="jdbc:mysql://localhost/jpetstore"/>

<!通过build.properties 产生database.properties 文件-->

<!由于build.properties 中的属性被注释了,所以这些属性会从properties.xml中取得-->

<target name="generate.database.properties">

<propertyfile comment="Hibernate Configuration for JUnit tests"

file="${basedir}/database.properties">

<entry key="hibernate.dialect" value="${hibernate.dialect}"/>

</propertyfile>

</target>

<!初始化属性值-->

<property environment="env"/>

<property name="env.COMPUTERNAME" value="${env.HOSTNAME}"/>

<!properties.xml文件的主要工作:定义构建工具需要的Classpath属性-->

<path id="xdoclet.classpath">

</path>

<path id="hibernate.classpath">

</path>

<path id="dao.compile.classpath">

</path>

<path id="dao.test.classpath">

</path>

<path id="service.compile.classpath">

</path>

<path id="service.test.classpath">

</path>

<path id="web.compile.classpath">

</path>

<path id="web.test.classpath">

</path>

Ø app-settings.xml文件分析

该文件定义设置应用程序状态的一些属性值

<property name="encrypt.password" value="true"/>

<property name="encrypt.algorithm" value="SHA"/>

<property name="secure.login" value="false"/>

<property name="secure.application" value="false"/>

<property name="rememberMe.enabled" value="true"/>

Øbuild.properties文件分析

build.compiler=modern

webapp.name=dudu

webapp.version=1.7

webapp.war=${webapp.name}.war

compile.deprecation=true

build.dir=${basedir}/build

dist.dir=${basedir}/dist

test.dir=${build.dir}/test

javac.debug=true

junit.fork=true

xdoclet.force=false

error.mailTo=junk@raibledesigns.com

error.mailHost=localhost

error.server=localhost

ftp.server=upload.sourceforge.net

ftp.remoteDir=incoming

ftp.user=anonymous

Ø tomcat.properties文件分析

tomcat.server=localhost

tomcat.manager.url=http://${tomcat.server}:8080/manager

tomcat.username=admin

tomcat.password=admin

相关文章:

  • 使CBIntrospect支持在设备上使用
  • Windows Mobile BLOG 问题集锦 2006-9-25
  • 拨一下就断的电话是否是在测电话号码是否可用
  • JBoss JTA的使用心得
  • 确保测试代码不会在发布版上运行
  • Tech-ED2006会场见闻图片集
  • 拨打电话时直接拨分机号
  • 技巧和诀窍:在VS 2005里使用Vista的IIS7
  • 使UIButton的子view不影响button的点击事件
  • 网站如何做分布式(集群)的大纲
  • iOS7下有时MKMapView中的字特别大的问题的解决
  • 有感Atlas - 优点、缺点、学习
  • NSInvocationOperation的cancelAllOperations不会取消正在运行的operation
  • 微软.NET俱乐部Tech-ED2006追踪报道!
  • MAC下SVN客户端Versions和Cornerstone的比较
  • Angular js 常用指令ng-if、ng-class、ng-option、ng-value、ng-click是如何使用的?
  • hadoop入门学习教程--DKHadoop完整安装步骤
  • Java 23种设计模式 之单例模式 7种实现方式
  • javascript从右向左截取指定位数字符的3种方法
  • scala基础语法(二)
  • Spring框架之我见(三)——IOC、AOP
  • Webpack入门之遇到的那些坑,系列示例Demo
  • 从0到1:PostCSS 插件开发最佳实践
  • 读懂package.json -- 依赖管理
  • 分类模型——Logistics Regression
  • 观察者模式实现非直接耦合
  • 基于游标的分页接口实现
  • 爬虫模拟登陆 SegmentFault
  • 吐槽Javascript系列二:数组中的splice和slice方法
  • 微信小程序填坑清单
  • 问:在指定的JSON数据中(最外层是数组)根据指定条件拿到匹配到的结果
  • 无服务器化是企业 IT 架构的未来吗?
  • 一文看透浏览器架构
  • 掌握面试——弹出框的实现(一道题中包含布局/js设计模式)
  • 阿里云API、SDK和CLI应用实践方案
  • 阿里云服务器如何修改远程端口?
  • ​Kaggle X光肺炎检测比赛第二名方案解析 | CVPR 2020 Workshop
  • (13)Hive调优——动态分区导致的小文件问题
  • (html转换)StringEscapeUtils类的转义与反转义方法
  • (原創) 博客園正式支援VHDL語法著色功能 (SOC) (VHDL)
  • (转)使用VMware vSphere标准交换机设置网络连接
  • .NET 4.0中的泛型协变和反变
  • .NET6使用MiniExcel根据数据源横向导出头部标题及数据
  • .NET高级面试指南专题十一【 设计模式介绍,为什么要用设计模式】
  • /deep/和 >>>以及 ::v-deep 三者的区别
  • [ 攻防演练演示篇 ] 利用通达OA 文件上传漏洞上传webshell获取主机权限
  • [ 云计算 | AWS 实践 ] Java 如何重命名 Amazon S3 中的文件和文件夹
  • [ 云计算 | AWS 实践 ] 基于 Amazon S3 协议搭建个人云存储服务
  • [bzoj2957]楼房重建
  • [C#]C# OpenVINO部署yolov8图像分类模型
  • [C#C++]类CLASS
  • [C++参考]拷贝构造函数的参数必须是引用类型
  • [cogs2652]秘术「天文密葬法」
  • [HNCTF 2022 WEEK2]easy_include 文件包含遇上nginx
  • [iOS]-网络请求总结