编译liferay 6.0.6

本文以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模块存在如下依赖关系

编译liferay 6.0.6

但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.properties复制一份,命名为app.server.%USERNAME%.properties(比如你当前的计算机用户名是Administrator,则命名为app.server.Administrator.properties),我们在app.server.%USERNAME%.properties中修改一些属性的设置。我们需要在这里修改指定所使用的应用服务器以及存放的位置:


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的构建

 打开portal-client/build.xml


  • 添加<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" />


参考资料:http://www.liferay.com/community/wiki/-/wiki/Main/JBoss+tips#section-JBoss+tips-Portal+6+on+JBoss+5.1

http://www.liferay.com/documentation/liferay-portal/6.0/administration/-/ai/installing-liferay-for-an-enterpri-4


(未完待续)


 

你可能感兴趣的:(java,liferay)