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

Difference between revisions of "STP/Stardust/KnowledgeBase/BuildChangeMgmt/Using Maven Overlays to Create Custom Stardust Portal"

m
(Removed dependency:unpack step according to new archetype usage approach.)
 
(17 intermediate revisions by one other user not shown)
Line 1: Line 1:
__NOTOC__
+
== Introduction ==
  
  
Using Maven Overlays to Create Custom Stardust Portal
+
Most of the time, when using Stardust portal, you will need to add your project specific artifacts in the portal war. Artifacts could be anything like spring configuration files, java classes, properties files, html pages.
  
 +
So, with maven you can create a wrapper project to create a Stardust portal war with project specific content overlayed in it. For this, Stardust has provided archetype to create the stardust portal maven project.
 +
 +
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.
  
  
== Introduction ==
+
== Project Structure ==
 
+
THIS IS WORK IN PROGRESS. PLEASE VISIT LATER ON. THANK YOU.
+
  
 +
Here, we will use a parent project having two subprojects, in maven terms, modules. One of the sub project will be your custom project. And the second project will be the Stardust portal. The Stardust portal project will be created using maven archetype provided by the Stardust.
 +
 +
<source lang="xml">
 +
Parent Project
 +
              |---Stardust Portal Module
 +
              |---Custom Webapp Module
 +
</source>
  
 
== Parent Project ==
 
== Parent Project ==
 +
Now, let's 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 looks like
+
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.
  
 
<source lang="XML">
 
<source lang="XML">
 
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?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"
 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Line 63: Line 72:
 
</source>
 
</source>
  
 +
== Custom Module Project ==
 +
Now, go to '''project-portal-war''' directory, create following directory structure and add your project resources like java files, properties files, config files and so on.
  
== Custom Project War ==
+
Note that, you can use maven webapp archetype to create this web project.
  
 +
====Custom Project Directory Structure====
 +
 +
<source lang="XML">
 +
|-- 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
 +
 +
</source>
 +
 +
====Custom Project POM====
 +
The cusotm project pom is given below. Note the usage of '''maven-war-plugin'''. We are using maven overlays mechanism to create a WAR by overlaying the Stadust potal and custom project artifacts.
  
 
<source lang="XML">
 
<source lang="XML">
Line 111: Line 148:
 
<configuration>
 
<configuration>
 
<source>1.6<//source>
 
<source>1.6<//source>
 +
        <!-- Remove the additional slash. I had to add as it conflicted with wiki source tag -->
 
<target>1.6</target>
 
<target>1.6</target>
 
<encoding>UTF-8</encoding>
 
<encoding>UTF-8</encoding>
Line 139: Line 177:
 
<targetPath>/</targetPath>
 
<targetPath>/</targetPath>
 
</resource>
 
</resource>
</webResources>
+
</webResources>
+
<dependentWarExcludes>WEB-INF/web.xml,WEB-INF/lib/jaxws-api-2.0.jar,WEB-INF/lib/jaxb-api-2.0.jar
+
</dependentWarExcludes>
+
+
 
</configuration>
 
</configuration>
 
</plugin>
 
</plugin>
Line 182: Line 216:
 
</source>
 
</source>
  
== Running Archetype Command to Add Stardust Portal as Module ==
+
== Stardust Portal Module ==
 +
Now, we will use the archetype command to create the Stardust portal module. In the parent project, type the following command to create the portal project and add it as a module.
 +
 
  
 
<source lang="XML">
 
<source lang="XML">
 
mvn archetype:generate  
 
mvn archetype:generate  
 
-DarchetypeGroupId=com.infinity.bpm.archetypes -DarchetypeArtifactId=ipp-archetype-tc6-ipp-portal-war
 
-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
+
-DarchetypeVersion=6.0.3 -DgroupId=org.eclipse.stardust.test  
-Dgoals=dependency:unpack
+
-DartifactId=stardust-portal-war -Dversion=1.0-SNAPSHOT
  
 
</source>
 
</source>
  
After you run this command it will download and add the '''stardust-portal-war''' as module to your parent project. You will one more entry in modules section.
+
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.
  
 
<source lang="XML">
 
<source lang="XML">
Line 202: Line 238:
 
</source>
 
</source>
  
Note that you will have to change the order of these modules. We want the '''stardust-portal-war''' to be built befoer our custom project war builds. So change it as follows;
+
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 given below. Here, project-portal-war depends on stardust-potal-war.
  
 
<source lang="XML">
 
<source lang="XML">
Line 210: Line 246:
 
     </modules>
 
     </modules>
 
</source>
 
</source>
 
 
  
 
== Build the Final Project ==
 
== Build the Final Project ==
  
Now use the '''mvn install''' command to build the final custom Stadust Portal project.
+
Now, in the parent project, use '''mvn install''' command to build the final the Stadust portal project WAR overlayed with project artifacts. If the build was successful, you will see the Stardust portal with custom project artifacts at '''/test-portal-project\project-portal-war\target'''.
 
+
 
+
If the build was successful, you will see the Stardust Portal with custom project artefacts at '''/test-portal-project\project-portal-war\target'''.
+
+
 
+
<source lang="XML">
+
test
+
</source>
+

Latest revision as of 04:42, 9 December 2013

Introduction

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

So, with maven you can create a wrapper project to create a Stardust portal war with project specific content overlayed in it. For this, Stardust has provided archetype to create the stardust portal maven project.

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, we will use a parent project having two subprojects, in maven terms, modules. One of the sub project will be your custom project. And the second project will be the Stardust portal. The Stardust portal project will be created using maven archetype provided by the Stardust.

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

Parent Project

Now, let's 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 Module Project

Now, go to project-portal-war directory, create following directory structure and add your project 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 maven overlays mechanism to create a WAR 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>
         <!-- Remove the additional slash. I had to add as it conflicted with wiki source tag -->
					<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>						
				</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 the 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

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 given below. Here, project-portal-war depends on stardust-potal-war.

    <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 the Stadust portal project WAR overlayed with project artifacts. 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