Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

STP/Stardust/KnowledgeBase/BuildChangeMgmt/Using Maven Overlays to Create Custom Stardust Portal

< STP‎ | Stardust‎ | KnowledgeBase
Revision as of 06:33, 19 December 2011 by Ganesh.lawande.sungard.com (Talk | contribs) (Parent Project)

THIS IS WORK IN PROGRESS. PLEASE VISIT LATER ON. THANK YOU.


Introduction

Most of the times, when using Stardust Portal, you will need to add your custom project specific artifacts in the portal war. Artifacts could anything like project spring configuration files, java classes, properties files, html pages.

So, with maven you can create a build project to create a Stardust Portal war with project specific artifacts. For this, Stardust has provided archetype to create the stardust portal model.

In this article, we will see how maven overlays mechanism can be used to create a custom webapp (WAR) project by overlaying Stardust portal project and your custom war project.


Project Structure

Here will use a parent project having two subprojects. One of the sub project, in maven terms module, we will be your custom project. And the second project will be the Stardust Portal. The Stardust portal project will be created using custom archetype provided by Stardust.

Parent Project
              |---Stardust Portal Module
              |---Custom Webapp Module

Parent Project

Now let us look at how parent project looks like. It contains the two module projects as mentioned above and a POM file. So create a parent project directory, say test-portal-project, and then create a custom webapp module project and name it say project-portal-war.

The POM file is given below. Note that, repositories section is not required if you have already configured it as a part of maven settings.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>sungard</groupId>
	<artifactId>test-portal-project</artifactId>
	<version>6.0.3</version>
	<name>test-portal-project</name>
	<description>holds the ipp portal facets file</description>
	<packaging>pom</packaging>
 
	<properties>
		<ipp.version>6.0.3</ipp.version>
	</properties>
 
	<modules>
		<module>project-portal-war</module>
	</modules>
 
	<repositories>
		<repository>
			<id>central-mirror-internal</id>
			<url>https://infinity.sungard.com/repository/repo
			</url>
		</repository>
		<repository>
			<id>csa-public-repo</id>
			<url>
				https://svn.csa.sungard.com/maven_jar_repository/repository/public
			</url>
		</repository>
		<repository>
			<id>Public-Maven-repository</id>
			<url>http://repo1.maven.org/maven2</url>
		</repository>
		<repository>
			<id>Apache-Camel-Releases</id>
			<url>
				https://repository.apache.org/content/repositories/releases
			</url>
		</repository>
	</repositories>
 
</project>

Custom Moduel Project

Now inside, project-portal-war directory, create following directory structure and add your custom resources like java files, properties files, config files and so on.

Note that you can use maven webapp archetype to create this web project.

Custom Project Directory Structure

|-- pom.xml
 `-- src
     `-- main
         |-- java
         |   `-- com
         |       `-- example
         |           `-- projects
         |               `-- SampleAction.java
         |-- resources
         |   |-- images
         |   |   `-- sampleimage.jpg
         |   `-- sampleresource
         `-- webapp
             |-- WEB-INF
             |   `-- web.xml
             |-- index.jsp
             `-- jsp
                 `-- samplewebsource.jsp

Custom Project POM

The cusotm project pom is given below. Note the usage of maven-war-plugin. We are using overlays mechanism to create a project by overlaying the Stadust Potal and Custom project artifacts.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	 <parent>
	    <groupId>sungard</groupId>
		<artifactId>test-portal-project</artifactId>		
		<version>6.0.3</version>
	</parent>
 
	<groupId>sungard</groupId>
	<artifactId>project-portal-war</artifactId>
	<packaging>war</packaging>
	<version>6.0.3</version>
	<name>project-portal-war</name>
	<description>holds the project facets</description>
 
	<properties>
		<ipp.version>6.0.3</ipp.version>
	</properties>
 
	<build>
		<resources>
			<resource>
				<directory>src/main/resources</directory>
			</resource>
			<resource>
				<directory>src/main/java</directory>
				<filtering>true</filtering>
				<includes>
					<include>**/*.properties</include>
					<include>com/mypakge/cs/**/*-context.xml</include>
				</includes>
			</resource>
		</resources>
 
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.0.2</version>
				<configuration>
					<source>1.6<//source>
					<target>1.6</target>
					<encoding>UTF-8</encoding>
				</configuration>
			</plugin>
			<!-- This creates the WAR file for the project -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-war-plugin</artifactId>
				<version>2.1-alpha-1</version>
				<configuration>
					<archiveClasses>true</archiveClasses>
					<overlays>
						<overlay>
							<groupId>org.eclipse.stardust.test</groupId>
							<artifactId>stardust-portal-war</artifactId>
							<type>war</type>
						</overlay>						
					</overlays>
					<webResources>
						<resource>
							<directory>
								${basedir}/src/main/webapp
							</directory>
							<includes>
								<include>*</include>
							</includes>							
							<targetPath>/</targetPath>
						</resource>
					</webResources>
 
						<dependentWarExcludes>WEB-INF/web.xml,WEB-INF/lib/jaxws-api-2.0.jar,WEB-INF/lib/jaxb-api-2.0.jar
						</dependentWarExcludes>					
 
				</configuration>				
			</plugin>
		</plugins>
	</build>
	  <dependencies>
      <dependency>
         <groupId>org.eclipse.stardust.test</groupId>
         <artifactId>stardust-portal-war</artifactId>
         <version>1.0-SNAPSHOT</version>         
         <type>war</type>
      </dependency>
	</dependencies>
	<repositories>
		<repository>
			<id>central-mirror-internal</id>
			<url>https://infinity.sungard.com/repository/repo
			</url>
		</repository>
		<repository>
			<id>csa-public-repo</id>
			<url>
				https://svn.csa.sungard.com/maven_jar_repository/repository/public
			</url>
		</repository>
		<repository>
			<id>Public-Maven-repository</id>
			<url>http://repo1.maven.org/maven2</url>
		</repository>
		<repository>
			<id>Apache-Camel-Releases</id>
			<url>
				https://repository.apache.org/content/repositories/releases
			</url>
		</repository>
	</repositories>	
</project>

Stardust Portal Module

Now we will use the archetype command to create a Stardust Portal module. In the parent project, type the following command to create the portal project and add it as a module.


mvn archetype:generate 
-DarchetypeGroupId=com.infinity.bpm.archetypes -DarchetypeArtifactId=ipp-archetype-tc6-ipp-portal-war
-DarchetypeVersion=6.0.3 -DgroupId=org.eclipse.stardust.test -DartifactId=stardust-portal-war -Dversion=1.0-SNAPSHOT
-Dgoals=dependency:unpack

After you run this command, it will download and add the stardust-portal-war as a module to your parent project. You will see one more entry in modules section.

    <modules>
		<module>project-portal-war</module>
		<module>stardust-portal-war</module>
    </modules>

Note that, you will have to change the order of these modules. We want the stardust-portal-war to be built before our custom project war project builds. So change the module order as follows;

    <modules>
	<module>stardust-portal-war</module>
        <module>project-portal-war</module>
    </modules>

Build the Final Project

Now in the parent project, use mvn install command to build the final custom Stadust Portal project. If the build was successful, you will see the Stardust Portal with custom project artifacts at /test-portal-project\project-portal-war\target.

Back to the top