The Maven1 j2:portal.genapp goal has been supported in the Maven2 build as an archetype. However, until a Jetspeed2 Maven2 repository is completely populated, a normal Maven2 build must be completed to make Jetspeed2 archetypes available in your local repository. One can tweak the following command as needed to create a Jetspeed2 instance using this archetype:
mvn archetype:create -DarchetypeGroupId=org.apache.portals.jetspeed-2 -DarchetypeArtifactId=portal-archetype -DarchetypeVersion=2.1.3 -DgroupId=myportalgroup -DartifactId=myportal -Dversion=1.0
Note that this and other archetypes can issue many harmless warnings while expanding. Please ignore the warnings unless the expansion of the archetype template fails. When complete, the portal archetype expansion will contain the following structure within a directory named as the specified artifactId relative to the current working directory:
The archetype also contains a settings.xml.sample that is a subset of the Jetspeed2 source build parameters. If one has not previously configured the ~/.m2/settings.xml file as described above, this sample can be used to do so without J2 test configurations.
When the Maven2 enviroment is properly configured, the J2 Maven2 commands outlined above can now be used to build and deploy a customized portal. Most of the command options are supported with the exception of these profiles:
Currently, only Maven2 builds are supported. Longer range goals include support for Ant custom portal builds and prepackaged Maven2 repository downloads.
Two additional Maven2 archetypes are also available to generate custom portal applications and components on top of the generated portal template. Before these archetypes are used, the host portal archetype should have been previously built to install all parent POMs, (it is not necessary to deploy the portal before using these archetypes). These archetypes should be created from the applications and components subdirectories to work correctly.
A portal portlets application to be deployed by Jetspeed2:
mvn archetype:create -DarchetypeGroupId=org.apache.portals.jetspeed-2 -DarchetypeArtifactId=application-archetype -DarchetypeVersion=2.1.3 -DgroupId=myportalgroup -DartifactId=myportal-application -Dversion=1.0
A simple component to be used by other component and application modules:
mvn archetype:create -DarchetypeGroupId=org.apache.portals.jetspeed-2 -DarchetypeArtifactId=component-archetype -DarchetypeVersion=2.1.3 -DgroupId=myportalgroup -DartifactId=myportal-component -Dversion=1.0
A shared component to be deployed as a shared JAR in the application server:
mvn archetype:create -DarchetypeGroupId=org.apache.portals.jetspeed-2 -DarchetypeArtifactId=shared-component-archetype -DarchetypeVersion=2.1.3 -DgroupId=myportalgroup -DartifactId=myportal-shared-component -Dversion=1.0
A component to be deployed within the portal, (Jetspeed2), web application:
mvn archetype:create -DarchetypeGroupId=org.apache.portals.jetspeed-2 -DarchetypeArtifactId=portal-component-archetype -DarchetypeVersion=2.1.3 -DgroupId=myportalgroup -DartifactId=myportal-portal-component -Dversion=1.0
Note that the groupId and version settings should match the values used when generating the host portal template.
There are a few manual steps that must be followed to use these created applications and components.
<modules> ... <module>myportal-application</module> ... </modules>
The same syntax is used for components.
<dependencyManagement> <dependencies> ... <dependency> <groupId>${pom.groupId}</groupId> <artifactId>myportal-component</artifactId> <version>${pom.version}</version> </dependency> ... </dependencies> </dependencyManagement>
Applications are declared similarly, except for the addition of a required <type> element:
<dependencyManagement> <dependencies> ... <dependency> <groupId>${pom.groupId}</groupId> <artifactId>myportal-application</artifactId> <type>war</type> <version>${pom.version}</version> </dependency> ... </dependencies> </dependencyManagement>
<dependencies> ... <dependency> <groupId>${pom.groupId}</groupId> <artifactId>myportal-component</artifactId> </dependency> ... </dependencies>
Shared components that are intended to be deployed as a shared JAR should be declared as a provided dependency in the applications POM or individual application and component POMs, (note the additional provided <scope> element):
<dependencies> ... <dependency> <groupId>${pom.groupId}</groupId> <artifactId>myportal-shared-component</artifactId> <scope>provided</scope> </dependency> ... </dependencies>
Shared and portal components must also be made available for deployment and should be integrated in the app-servers module POM as a normal dependency:
<dependencies> ... <dependency> <groupId>${pom.groupId}</groupId> <artifactId>myportal-shared-component</artifactId> </dependency> ... </dependencies>
Applications are normally referenced only for deployment. To ensure they are available during deployment builds, they must be integrated in the app-servers module POM like this:
<dependencies> ... <dependency> <groupId>${pom.groupId}</groupId> <artifactId>myportal-application</artifactId> <type>war</type> </dependency> ... </dependencies>
<target name="hot-deploy-apps"> ... <antcall target="hot-deploy-war"> <param name="org.apache.jetspeed.deploy.groupid" value="${portal.groupid}"/> <param name="org.apache.jetspeed.deploy.artifactid" value="myportal-application"/> <param name="org.apache.jetspeed.deploy.version" value="${portal.version}"/> </antcall> ... </target>
Shared components that are to be installed in the application server should be added to the shared deployment hook in the same buildfile:
<target name="hot-deploy-shared-components"> ... <antcall target="hot-deploy-shared-jar"> <param name="org.apache.jetspeed.deploy.groupid" value="${portal.groupid}"/> <param name="org.apache.jetspeed.deploy.artifactid" value="myportal-shared-component"/> <param name="org.apache.jetspeed.deploy.version" value="${portal.version}"/> </antcall> ... </target>
And finally, portal components that are to be inserted into the portal application itself should be added to the 'hot' component/JAR hooks like this:
<target name="hot-deploy-components"> ... <antcall target="hot-deploy-jar"> <param name="org.apache.jetspeed.deploy.groupid" value="${portal.groupid}"/> <param name="org.apache.jetspeed.deploy.artifactid" value="myportal-portal-component"/> <param name="org.apache.jetspeed.deploy.version" value="${portal.version}"/> </antcall> ... </target>
Please refer to the Maven2 site documentation for more detail or background information: Maven-2 Docs