Developing Custom Portlets
(Just copying information from the mailing list to the wiki. Please complete with your experiences! Thanks Shah Amit.)
Directory setup
Setup a seperate directory for all sources of the custom portlet, decorators, etc.
e.g. c:\MyProjects\MyPortlet\src\xxxx
You already have a directory to deploy to when using the binary jetspeed distribution.
e.g. ...\webapps\jetspeed\WEB-INF\deploy
If you build jetspeed from source put it in a seperate directory.
e.g. c:\jetspeed2
This way whenever I want, I update my jetspeed distribution and deploy it. And then use my maven goals to deploy my psmls, portlets etc.
The Base Source Code
Just copy one of the source code from the jetspeed2 demo applications.
Customize maven.xml
Just a sample. Adapt it to your own needs.
<project default="tag:buildDev" xmlns:j="jelly:core" xmlns:deploy="deploy" xmlns:ant="jelly:ant"> <goal name="deploy.portlet" description="Builds the war file, and deploys it under jetspeed deploy directory."> <attainGoal name="war"/> <ant:echo>Deploying the war file to Jetspeed ...</ant:echo> <ant:copy file="${maven.build.dir}/${maven.war.final.name}" tofile="${portlet.deploy.dir}/${maven.war.final.name}" overwrite="true"/> </goal> <goal name="deploy.decorators" description="Deploys TAG specific decorators to jetspeed"> <attainGoal name="create.decorator.variables"/> <attainGoal name="deploy.layout.decorator"/> <attainGoal name="deploy.portlet.decorator"/> </goal> <goal name="create.decorator.variables" description="Create variables required by the deploy.decorators goal"> <j:set var="com.tagaudit.tagportal.layout.decorator.directory" value="${maven.src.dir}/webapp/WEB-INF/decorations/layout/html/tag"/> <j:set var="com.tagaudit.tagportal.portlet.decorator.directory" value="${maven.src.dir}/webapp/WEB-INF/decorations/portlet/html/tag"/> <j:set var="com.tagaudit.tagportal.layoutdecorator.filename" value="taglayoutdecorator.jar"/> <j:set var="com.tagaudit.tagportal.portletdecorator.filename" value="tagportletdecorator.jar"/> </goal> <goal name="deploy.portlet.decorator" description="Deploy the portlet decorator"> <ant:jar basedir="${com.tagaudit.tagportal.portlet.decorator.directory}" destfile="${portlet.deploy.dir}/${com.tagaudit.tagportal.portletdecorator.filename}" overwrite="true"/> </goal> <goal name="deploy.layout.decorator" description="Deploy the layout decorator"> <ant:jar basedir="${com.tagaudit.tagportal.layout.decorator.directory}" destfile="${portlet.deploy.dir}/${com.tagaudit.tagportal.layoutdecorator.filename}" overwrite="true"/> </goal> <goal name="deploy.psml" description="Deploy the pAgEs directory into jetspeed. Unfortunately we will have to keep doing this till jetspeed can pick it up from the portlet war file."> <ant:delete quiet="true" dir="${jetspeed.webinf.dir}/pages"/> <ant:mkdir dir="${jetspeed.webinf.dir}/pages"/> <ant:copy todir="${jetspeed.webinf.dir}/pages" overwrite="true"> <fileset dir="${maven.src.dir}/webapp/WEB-INF/pages" casesensitive="yes"/> </ant:copy> </goal> <goal name="deploy.all" description="Deployes the portal, decorators and the psml pages to appropriate directories"> <attainGoal name="deploy.portlet"/> <attainGoal name="deploy.decorators"/> <attainGoal name="deploy.psml"/> </goal> </project>
customize project.properties
Just a sample. Adapt it to your own needs.
#Set tomcat home to deploy war file tomcat.home=C:/jakarta-tomcat-5.0.28 #Deploy portlet jetspeed.webinf.dir=${tomcat.home}/webapps/jetspeed/WEB-INF/ portlet.deploy.dir=${jetspeed.webinf.dir}/deploy # Set up eclipse for the project maven.eclipse.output.dir=target/tagportal/WEB-INF/classes
customize project.xml
This file does not have much specific to your project. you can pick up anyone from jetspeed and customize it.