本文以tomcat 7.0.27和liferay 6.0.6为例,详细讲述如何从liferay 6.0.6源码编译出整套liferay 应用.
设BASE_DIR=D:\java为顶层目录, 将liferay 6.0.6源码包解压到$BASE_DIR, 将tomcat解压到$BASE_DIR\bundles\tomcat。即:
SET "BASE_DIR=D:\java"
SET "LIFERAY_SRC=%BASE_DIR%\liferay-portal-src-6.0.6"
SET "CATALINA_HOME=%BASE_DIR%\bundles\tomcat\tomcat-7.0.27"
SET "PATH=%CATALINA_HOME%\bin;%PATH%"
进入%LIFERAY_SRC%,打开命令行, 设置ANT_OPTS
set "ANT_OPTS=-Xmx1024m -XX:MaxPermSize=256m"
liferay源码是采用1.7或以上版本的ant工具构建,因此请安装ant,配置环境变量ANT_HOME,并将ant运行脚本放入环境变量PATH中.
整个liferay项目主要由portal-service, portal-impl, portal-web, util-java, util-bridges, util-taglib和tunnel-web模块组成.各个模块的主要功能如下:
- portal-service: 定义liferay核心类,提供基本的接口
- portal-impl: liferay的主要实现
- portal-web: liferay页面,UI库
- util-java: 工具类
- util-bridges:
- util-taglib: 自定义标签实现类
- tunnel-web:
portal-service, portal-impl, util-java, util-bridges, util-taglib模块存在如下依赖关系
但build.xml声明的构建顺序不对。修改方法如下:
打开build.xml, 将<target neme="deploy">...</target>中
<ant dir="portal-service" target="deploy" inheritAll="false" />
<ant dir="util-bridges" target="deploy" inheritAll="false" />
<ant dir="util-java" target="deploy" inheritAll="false" />
<ant dir="util-taglib" target="deploy" inheritAll="false" />
<ant dir="portal-impl" target="deploy" inheritAll="false" />
改为
<ant dir="portal-service" target="deploy" inheritAll="false" />
<ant dir="util-java" target="deploy" inheritAll="false" />
<ant dir="util-bridges" target="deploy" inheritAll="false" />
<ant dir="portal-impl" target="deploy" inheritAll="false" />
<ant dir="util-taglib" target="deploy" inheritAll="false" />
把
<ant dir="portal-service" target="jar" inheritAll="false" />
<ant dir="util-bridges" target="jar" inheritAll="false" />
<ant dir="util-java" target="jar" inheritAll="false" />
<ant dir="util-taglib" target="jar" inheritAll="false" />
<ant dir="portal-impl" target="jar" inheritAll="false" />
改为:
<ant dir="portal-service" target="jar" inheritAll="false" />
<ant dir="util-java" target="jar" inheritAll="false" />
<ant dir="util-bridges" target="jar" inheritAll="false" />
<ant dir="portal-impl" target="jar" inheritAll="false" />
<ant dir="util-taglib" target="jar" inheritAll="false" />
在<taget name="compile">..</target>中尾部添加
<ant dir="util-taglib" target="compile" inheritAll="false" />
app.server.tomcat.version=7.0.27
app.server.tomcat.dir=${app.server.parent.dir}/tomcat/tomcat-6.0.27
app.server.type=tomcat
# app.server.tomcat.zip.name=apache-tomcat-6.0.29.zip
app.server.tomcat.zip.name=apache-tomcat-7.0.27.zip
# app.server.tomcat.zip.url=http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.29/bin/${app.server.tomcat.zip.name}
app.server.tomcat.zip.url=http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.27/bin/${app.server.tomcat.zip.name}
构建过程中可能需要访问外网,如果需要通过代理才能访问外网,则在build.properties添加代理设置。
打开portal-web/build.xml,在<target name="deploy">...</target>中添加:
<antcall target="build-themes" />
<antcall target="build-selenium" />
在build.%USERNAME%.properties添加一项属性 javac.encoding=UTF-8, 并给所有ant构建文件的javac 任务(task)加上encoding="${javac.encoding}" ,如果不添加这项属性,当你往源码添加中文注释后,有些源码被抹掉(我也不知道为啥)
关于portal-client的构建
- 添加<property name="deploy.dir" value="${app.server.lib.portal.dir}" />
- 去掉<target name="build-client"></target>中的<axis-wsdl2java />注释
- 去掉<antcall target="jar" />的注释
- 在<target name="clean">...</target>中添加:
<delete dir="classes" failonerror="false" />
<delete file="${jar.file}.jar" failonerror="false" />
来源:oschina
链接:https://my.oschina.net/u/103999/blog/85810