Hiện tại trên mạng có rất nhiều cách chỉ để phát triển mã nguồn của liferay portal và cũng đã thử qua. Có rất nhiều hình thức develop như trên web và code từ IDE.
Do thầy yêu cầu code nên phải mày mò và vô tình lượm đưuọc cây kiếm gãy, share lên cho các bạn cùng nhau phát triền nha.
Testing thành công trên: Ubuntu Maverick 10.10, Eclipse 3.6 Helios
Let’s go!
Đầu tiên là các thứ cần có khi phát triển mã nguồn cho Liferay Portal:
- Apache Ant
- OpenJDK 6.0
- Eclipse for Java EE
- Subversion
- Liferay IDE
sudo apt-get updatesudo apt-get install ant openjdk-6-jdk libnb-snvclienadapter-java
-vmargs
-Djava.library.path=/usr/lib/jni
Cài đặt Subclipse như sau:
- Mở Eclipse lên, chọn Help => Install new Software
- Chọn Add địa chỉ sau vô thanh URL: http://subclipse.tigris.org/update_1.6.x
- Chọn hết để cài đặt, sau khi thành công restart lại Eclipse
- Switch to the SVN Repository Exploring in Eclipse
- Right-click in SVN repositories pane and click New > Repository Location
- Enter the following in the Url box:
svn://svn.liferay.com/repos/public
- Enter Guest as the username.
- Liferay Tomcat Bundle
- Liferay Portal Source
- Liferay Plugins SDK
Liferay Tomcat Bundle #
The Liferay Tomcat Bundle is a fully functional Liferay Portal server pre-configured on Tomcat 6.0.
- Create a directory called bundles in the Eclipse workspace: /home/{username}/workspace/bundles <Taọ thư lục bundles trong workspace của Eclipse>
- Extract the Liferay Tomcat Bundle in the newly created bundles directory in the Eclipse workspace <Giải nén gói Liferay Tomcat Bundle vô thư mục đó>
Liferay Portal Source #
The Liferay Portal Source is the source code for Liferay itself. The Liferay Source code serves as a guide to Liferay customisations for Hook Plugins or Extension Plugins.
- Extract the Liferay Portal Source to /home/{username}/workspace <Giải nén thư mục file source của Liferay Portal vô workspace>
Liferay Plugins SDK #
The Plugins SDK is used by the Liferay IDE in the background. The reason for this is because the Plugins SDK is IDE agnostic and Plugins developed with the Liferay IDE can still be modified using other IDEs.
- Create a directory called liferay-plugins-sdk in /home/{username}/workspace/liferay-portal-jdk <Tạo thư mục JDK trong workspace và giải nén JDK Liferay vô đó>
- Extract Liferay Plugins SDK to the newly created liferay-plugins-sdk directory.
Install Liferay IDE by doing the following: <Bước cài đặt Plug-in của Liferay IDE trên Eclipse>
- Install Liferay IDE in Eclipse by going to Help > Install New Software
- Paste the following URL in the Work with box and click Add: http://releases.liferay.com/tools/ide/eclipse/helios/stable/
- Name the site: Liferay IDE
Select Liferay Tooling
Restart Eclipse
Define Liferay Server in Eclipse # <Bước tạo một Rumtime Environment Server cho Liferay hoạt động>
Switch to the Liferay Perspective in Eclipse
Create a new Liferay Server in eclipse by doing the following:
- Click the Server tab
- Right-click in the Servers Pane and choose New > Server
- Select Liferay, Inc. > Liferay v6.0 Server (Tomcat 6)
- Enter the following for the Liferay Tomcat directory: /home/{username}/workspace/bundles/liferay-portal-6.0.5/tomcat-6.0.26 <thư mục chứa gói bundles vừa giải nén như ở trên.>
Configure Liferay Plugins SDK # <Bước import SDK để có thể phát triển mã nguồn>
Configure the Liferay Plugins SDK by doing the following:
- Choose Window > Preferences > Liferay > Installed SDKs
- Click Add
- Enter the following for Location: /home/{username}/workspace/liferay-plugins-sdk <thư mục cua SDK vừa giải nén ở trên,>
Import Portal Source Code # <Import Source của Liferay Portal vô>
Import the Liferay Portal Source code into Eclipse by doing the following:
- Right-click in Package Explorer and choose Import
- Go to General and choose Existing Projects into Workspace
- Enter the following for the root directory: /home/{username}/workspace/liferay-portal-src-6.0.5 <là wordspace vừa mới giải nén ở trên>
- liferay-portal-src-6.0.5 should show up in the Project list
- Click Finish
Creating a Test Plugin # <Tạo thử 1 Project Test cho Liferay>
This section will create a test plugin to make sure that the development environment is properly configured.
- In the Liferay Perspective click File > New > Liferay Project <Chọn Liferay Project>
- Name the project Test and click Finish
- Click File > New > Liferay Portlet
- Make sure the Test-portlet project is selected
- Choose javax.portlet.GenericPortlet as the Superclass and click Finish
- Drag and drop the Test-portlet project onto the Liferay Portal server in the servers pane.
- Start the Liferay Portal Server
- Once the Server is started, Right-click the Server and choose Liferay > Open Portal Home
- Log in to Liferay using the username/password test@liferay.com/test
- Click Add > More > Sample
- Drag NewPortlet onto the Welcome Page <kéo project vửa viết vào Portlet Container chú ý tên của Prọect>
