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.
Difference between revisions of "STP/Stardust/KnowledgeBase/BuildChangeMgmt/Using Maven Overlays to Create Custom Stardust Portal"
m |
m |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
+ | 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 == | == 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 looks like following; | ||
− | |||
<source lang="XML"> | <source lang="XML"> | ||
Line 64: | Line 80: | ||
− | == Custom 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. | ||
+ | |||
+ | |||
+ | |-- pom.xml | ||
+ | `-- src | ||
+ | `-- main | ||
+ | |-- java | ||
+ | | `-- com | ||
+ | | `-- example | ||
+ | | `-- projects | ||
+ | | `-- SampleAction.java | ||
+ | |-- resources | ||
+ | | |-- images | ||
+ | | | `-- sampleimage.jpg | ||
+ | | `-- sampleresource | ||
+ | `-- webapp | ||
+ | |-- WEB-INF | ||
+ | | `-- web.xml | ||
+ | |-- index.jsp | ||
+ | `-- jsp | ||
+ | `-- websource.jsp | ||
+ | |||
Revision as of 06:09, 19 December 2011
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 looks like following;
<?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.
|-- pom.xml
`-- src `-- main |-- java | `-- com | `-- example | `-- projects | `-- SampleAction.java |-- resources | |-- images | | `-- sampleimage.jpg | `-- sampleresource `-- webapp |-- WEB-INF | `-- web.xml |-- index.jsp `-- jsp `-- websource.jsp
<?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>
Running Archetype Command to Add Stardust Portal as 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 module to your parent project. You will 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 befoer our custom project war builds. So change it as follows;
<modules> <module>stardust-portal-war</module> <module>project-portal-war</module> </modules>
Build the Final Project
Now use the 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 artefacts at /test-portal-project\project-portal-war\target.
test