編譯liferay 6.0.6

本文以tomcat 7.0.27和liferay 6.0.6爲例,詳細講述如何從liferay 6.0.6源碼編譯出整套liferay 應用. java

設BASE_DIR=D:\java爲頂層目錄, 將liferay 6.0.6源碼包解壓到$BASE_DIR, 將tomcat解壓到$BASE_DIR\bundles\tomcat。即: web

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 shell

set "ANT_OPTS=-Xmx1024m -XX:MaxPermSize=256m"

liferay源碼是採用1.7或以上版本的ant工具構建,所以請安裝ant,配置環境變量ANT_HOME,並將ant運行腳本放入環境變量PATH中. apache

整個liferay項目主要由portal-service, portal-impl, portal-web, util-java, util-bridges, util-taglib和tunnel-web模塊組成.各個模塊的主要功能以下: tomcat

  • 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聲明的構建順序不對。修改方法以下: app

打開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" />

改成 ui

<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" />


url

<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

(未完待續)
相關文章
相關標籤/搜索