如何用最暴力的方法改写Liferay的原生portlet

最近在论坛上看到有人问如何改写Liferay原有的calendar portlet.

然后研究了一下,直接从portal中把calendar portlet的源码拷贝出来,然后修改再部署上去,但是这个过程中需要一些操作来解决编译等一系列问题。

环境:

1. Liferay IDE: 3.1 ga1
2. Liferay portal: liferay-portal-tomcat-6.2-ce-ga6-20160112152609836
3. Sdk: liferay-plugins-sdk-6.2-ce-ga6-20160112152609836.zip

步骤:

1.用这个SDK在Liferay IDE中创建一个名为calendar portlet的portlet plugin项目

2. 把这个项目中docroot下的文件全部删除

3. 把portal中calendar-portlet的源码拷贝进去,在我电脑上是这个目录(F:\liferay-bundle\liferay-portal-tomcat-6.2-ee-sp20-20170717160924965\liferay-portal-6.2-ee-sp20\tomcat-7.0.62\webapps\calendar-          portlet)

4. 在IDE上把这个portlet删除(不要删除源文件),然后把<classpathentry kind="src" path="docroot/WEB-INF/service"/>加到.classpath文件中,再重新导入到IDE中(Import->Liferay Existing SDK Plugin Project)

5. 安装JDK 6,把当前Eclipse的jre环境换为jdk 1.6,因为6.2的原生portlet需要jvm 6的编译环境,然后把项目的编译的级别设为1.6

6. 安装ant, 把IDE的ant runtime指定为安装的外部ant

7.然后就ok了,你运行builder-service, compile, war,deploy什么的都没有问题了。

下面是论坛的原始回答https://web.liferay.com/community/forums/-/message_boards/view_message/92088815

posted @ 2017-07-23 23:57  Hibou  阅读(440)  评论(0编辑  收藏  举报