本文以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, 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.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}" ,若是不添加這項屬性,當你往源碼添加中文註釋後,有些源碼被抹掉(我也不知道爲啥)
<delete dir="classes" failonerror="false" /> <delete file="${jar.file}.jar" failonerror="false" />