文档
Liferay提供丰富知识资源,协助我们的社区与我们的技术更好地结合、应用。
Initial Setup
Setting up the Plugins SDK is pretty straightforward. Download the archive from Liferay's Additional Files download page, in the section for developers here:
http://www.liferay.com/web/guest/downloads/additional.
Unzip the file to the location in which you will be doing your work. The two folders you will be working in mostly are the portlets and the themes folders. It is here that you will place your portlet and theme plugin projects.
But first you will need to create a configuration file and make sure you have some tools installed. Building portlet and theme projects in the plugins SDK requires that you have Ant 1.7.0 or higher installed on your machine. Download the latest version of Ant from http://ant.apache.org. Uncompress the archive into an appropriate folder of your choosing.
Next, set an environment variable called ANT_HOME which points to the folder to which you installed Ant. Use this variable to add the binaries for Ant to your PATH by adding ANT_HOME/bin to your PATH environment variable. Set another environment variable called ANT_OPTS with the proper memory settings for building projects.
You can do this on Linux by modifying your .bash_profile file as follows (assuming you installed Ant in /java):
ANT_HOME=/java/apache-ant-1.7.0
ANT_OPTS="-Xms256M -Xmx512M"
PATH=$PATH:$HOME/bin:$ANT_HOME/bin
export ANT_HOME ANT_OPTS PATH
Log out and log back in to make these settings take effect.
You can do this on Windows by going to Start -> Control Panel, and double-clicking the System icon. Go to Advanced, and then click the Environment Variables button. Under System Variables, select New. Make the Variable Name ANT_HOME and the Variable Value the path to which you installed Ant (e.g., c:\java\apache-ant-1.7.0), and click OK.
Select New again. Make the Variable Name ANT_OPTS and the Variable Value "-Xms256M -Xmx512M" and click OK.
Scroll down until you find the PATH environment variable. Select it and select Edit. Add %ANT_HOME%\bin to the end or beginning of the PATH. Select OK, and then select OK again. Open a command prompt and type ant and press Enter. If you get a build file not found error, you have correctly installed Ant. If not, check your environment variable settings and make sure they are pointing to the directory to which you unzipped Ant.
You will need a Liferay runtime on which to deploy your plugins to test them. We recommend using the Liferay-Tomcat bundle which is available from Liferay's web site, as Tomcat is small, fast, and takes up less resources than most other containers. Download the latest Liferay-Tomcat bundle and unzip it to a folder on your machine. You can start Tomcat by navigating to the <Tomcat Home>/bin folder and running the startup command (i.e., startup.bat for Windows or ./startup.sh for Linux or Mac).
You will notice that the plugins SDK contains a file called build.properties. Open this file in the text editor or IDE you will be using to create portlets and themes. At the top of the file is a message, "DO NOT EDIT THIS FILE." This file contains the settings for where you have Liferay installed and where your deployment folder is going to be, but you don't want to customize this file. Instead, create a new file in the same folder called build.${user.name}.properties, where ${user.name} is your user ID on your machine. For example, if your user name is jsmith (for John Smith), you would create a file called build.jsmith.properties.
You will likely need to customize the following properties:
app.server.dir=
java.compiler=
app.server.dir: This is the folder into which you have installed your application server..
java.compiler: Defaults to the standard Java compiler, modern, from your JDK. However, you can set this to the Eclipse compiler, ECJ, if you want.
Save the file. You are now ready to start using the plugins SDK.
The plugins SDK can be used to house all of your portlet and theme projects enterprise-wide, or you can have separate plugins SDK projects for each of your portal projects. For example, if you have an internal Intranet which uses Liferay and which has some custom written portlets for internal use, you could keep those portlets and themes in their own plugins SDK project in your source code repository. If you also have an external instance of Liferay running for your public Internet web site, you could have a separate plugins SDK with those projects (portlet and theme) in your source code repository. Or you could further separate your projects by having a different plugins SDK project for each portlet or theme project. It's really up to you.
You could also use the plugins SDK as a simple cross-platform new project generator. You can generate the project using the ant scripts in the plugins SDK and then copy the resulting project from the portlets or themes folder to your IDE of choice. You would need to customize the ant script if you wish to do that, but this allows organizations which have strict standards for their Java projects to adhere to those standards.