JBoss Community

Creating Project Examples

modified by Snjezana Peco in JBoss Tools - View the full document

Project examples are created using a project examples xml file added to a project examples site.
Defining project examples sites is described on Project Examples Sites.

 

The following is a definition of a project example within some site:


<?xml version="1.0" encoding="UTF-8"?>

<projects

  <project>

  ...

  </project>

</projects>


Simple Project Example

A definition of a simple project example:

 

<project>

    <category>Seam</category>

    <name>registration</name>

    <included-projects>registration, registration-ejb ...</included-projects>

    <shortDescription>Seam Registration Example</shortDescription>

    <description>This is a trivial example for the Seam tutorial. ...</description>

    <size>31657984</size>

    <url>http://...registration.zip</url>

</project>


Below is a description of the basic elements:

 

  • category - the category to which the project example belongs
  • name - the project example name - it is used internally and isn't shown to the user
  • included-projects - the projects included in the project example.  The Project Example engine will import only those projects included within this element.
  • shortDescription - the short description (it is recommended to be a few words)
  • description - the complete description of the project example (a few lines recommended)
  • size - the archive size in bytes. This is an informative and optional element
  • url - the URL which the zip archive is placed on; can be local or remote; optional

 

These are the minimal elements necessary to create a project example.
In this example, the url has to point to the zip archive containing one or more Eclipse projects.

The category, name, shortDescription, description, size and url are shown in the project example wizard.

http://community.jboss.org/servlet/JiveServlet/downloadImage/14212/ProjectExamples7.png

Fixes/Requirements

 

The developer can define requirements that need to be satisfied in order the project example to work correctly. The Project Example engine will warn the user if the requirements aren't satisfied (see the figure) and fix some possible issues when the project example is imported.

http://community.jboss.org/servlet/JiveServlet/downloadImage/102-14955-9-2270/451-598/ProjectExamples3.png

 

http://community.jboss.org/servlet/JiveServlet/downloadImage/102-14955-9-2274/449-296/projectExamples4.png

The following is an example of how to define fixes/requirements:

 

<fixes>

  <fix type="wtpruntime">

    <property name="allowed-types">org.jboss.ide.eclipse.as.runtime.eap.43, org.jboss.ide.eclipse.as.runtime.42</property>

    <property name="eclipse-projects">registration,registration-ejb,registration-ear</property>

    <property name="required-components">esb</property>

    <property name="description">This project example requires the JBoss EAP 4.3 or JBoss AS 4.2.x</property>

    <property name="downloadId">org.jboss.tools.runtime.core.as.423</property>

  </fix>       

  <fix type="seam">

     <property name="allowed-versions">2.0.0, 2.0.1, 2.0.2</property>

     <property name="eclipse-projects">registration</property>

     <property name="description">This project example requires Seam version 2.0</property>

     <property name="downloadId">org.jboss.tools.runtime.core.seam.202</property>

  </fix>       

  <fix type="plugin" hard="true">

     <property name="id">org.testng.eclipse</property>

     <property name="versions">[5.8.0</property>

     <property name="description">The TestNG plugin is required if you want to run Seam tests. You can install it using the following update site: http://beust.com/eclipse</property>

     <property name="connectorIds">org.testng.eclipse</property>

  </fix>

</fixes>

 

Currently, the project examples engine recognizes 3 types of requirements:

 

  • wtpruntime - if there is a requirement of the type wtpruntime, a project example will require WTP runtime described with properties.

    wtpruntime properties

    • allowed-types - a list of WTP runtime types required by the project example, comma separated. If the workspace contains a runtime from the list, the requirement is satisfied.
    • eclipse-projects - a list of Eclipse projects to which the requirement is related.  If the workspace contains a runtime of the corresponding type, the project example will  automatically add that runtime to the projects.
      For instance, if the developer creates a project example using a WTP/Seam runtime named Runtime A and the workspace contains  a compatible runtime named Runtime B, the Project Examples engine will fix the runtime name in Runtime B for all the projects listed in the eclipse-projects property.
    • required-components - a list of comma separated components  that have to be contained in a WTP runtime. Possible values are esb, portlet and bpel.
    • description - the text showing up in the UI if the requirement isn't satisfied
    • downloadId - the id of the org.jboss.tools.runtime.core.downloadruntimes extension point. This extension point is defined in the org.jboss.tools.runtime.core plugin. The downloadId property is used in the JBoss Central editor to download/install the required WTP runtime.
  • seam - a project example requires a Seam runtime
  • Seam properties

    • allowed-versions required Seam versions
    • eclipse-projects - a list of Eclipse projects to which the requirement is related 
      The Seam runtime name will be fixed in the way similar to how it is done for the wtpruntime type.
    • description - the text showing up in the UI if the requirement isn't satisfied

       

    • downloadId - the id of the org.jboss.tools.runtime.core.downloadruntimes extension point. This extension point is defined in the org.jboss.tools.runtime.core plugin. The downloadId property is used in the JBoss Central editor to download/install the required Seam runtime.

  • plugin - a project example requires a plugin
  • Plugin properties

    • id - plugin ID
    • versions - required versions
    • description - the text showing up in the UI if the requirement isn't satisfied
    • connectorIds - a list of the ids of the org.eclipse.mylyn.discovery.core.connectorDiscovery extension point. The extension point is defined in the org.eclipse.equinox.p2.discovery.compatibility plugin. An example of the use of this extension point can be found in the org.jboss.tools.central.discovery plugin. The connectorIds property is used in the JBoss Central editor to install the required plugins.

Cheatsheet/html welcome page

 

The developer can define an Eclipse cheatsheet or a html page that will be opened after importing a project example.

The following is an example:

 

<project>
...
<welcome type="cheatsheets" url="/booking/cheatsheets/booking.xml"/>
... </project>

 

The type of the welcome page can be cheatsheets or html.

The url is the address of an Eclipse cheatsheet or html page that needs to be opened. It can be a standard url address or a location within the workspace.

Eclipse cheatsheet examples can be found on  http://anonsvn.jboss.org/repos/jbosstools/workspace/snjeza/seam-examples/booking22.zip.

The org.jboss.tools.project.examples.cheatsheet plugin includes several actions that can be used in a cheatsheet.

The Javadoc API contains the description of those actions.

Maven Project examples

 

Such project examples require the m2e, m2eclipse-wtp and JBoss Maven Project Examples feature.

There are three types of Maven project examples:

Pure maven project examples

Pure maven project examples are defined in the following way:

 

 <project> 
  ... <importType>maven</importType>
<importTypeDescription>...</importTypeDescription>
...
</project>

 

The developer defines the maven importType element and creates a zip archive containing a pure maven project that doesn't have to include Eclipse settings. The project example engine will import the project and configure Eclipse settings.

If the user's environment doesn't satisfy the requirements (doesn't include m2eclipse, for instance), a text from the importTypeDescription element will be shown.

 

See JBIDE-6214 for more details.

Maven project examples based on a Maven archetype

The following is an example:

 

<importType>mavenArchetype</importType>

<importTypeDescription>The project example requires ...</importTypeDescription>

<mavenArchetype>

    <archetypeGroupId>org.jboss.weld.archetypes</archetypeGroupId>

    <archetypeArtifactId>jboss-javaee6-webapp</archetypeArtifactId>

    <archetypeVersion>1.0.1.Beta2</archetypeVersion>

    <!-- <archetypeRepository>http://repository.jboss.org/nexus/content/groups/public/</archetypeRepository>  -->

    <groupId>org.jboss.tools.examples</groupId>

    <artifactId>jboss-javaee6-webapp</artifactId>

    <version>0.0.1-SNAPSHOT</version>

    <javaPackage>org.jboss.tools.examples</javaPackage>           

    <properties>

        <property name="name" value="Java EE 6 webapp project"/>

    </properties>       

</mavenArchetype>

 

The developer defines the mavenArchetype importType element.

A Maven archetype is defined within the mavenArchetype element.

The project examples engine will create an archetype and configure an Eclipse project.

For more details see JBIDE-7890

This type of Maven project examples doesn't require creating any archive.

 

Notice:

 

Maven project examples aren't available in JBDS <= 4.0.

Pure Maven project examples are available in JBoss Tools 3.2.0.GA.

Project examples of the mavenArchetype type are available in JBoss Tools 3.3.0.M1.

Comment by going to Community

Create a new document in JBoss Tools at Community