[jboss-user] [JBoss Tools] - Creating Project Examples

Snjezana Peco do-not-reply at jboss.com
Mon Nov 7 12:09:11 EST 2011


Snjezana Peco [http://community.jboss.org/people/snjeza] modified the document:

"Creating Project Examples"

To view the document, visit: http://community.jboss.org/docs/DOC-16578

--------------------------------------------------------------
Project examples are created using a project examples xml file added to a project examples site. 
Defining project examples sites is described on  http://community.jboss.org/docs/DOC-14955 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>


h4. 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 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/showImage/14212/ProjectExamples7.png  http://community.jboss.org/servlet/JiveServlet/downloadImage/14212/ProjectExamples7.png 
h4. 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/showImage/102-14955-9-2270/ProjectExamples3.png  http://community.jboss.org/servlet/JiveServlet/downloadImage/102-14955-9-2270/451-598/ProjectExamples3.png 

 http://community.jboss.org/servlet/JiveServlet/showImage/102-14955-9-2274/projectExamples4.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>
  </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>
  </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 http://beust.com/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

* *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
* *plugin* - a project example requires a plugin
*Plugin properties*
** *id* - plugin ID
** *versions* - required versions (the syntax is the same as in the Eclipse manifest file (*isn't implemented yet*) 
** *description* - the text showing up in the UI if the requirement isn't satisfied
If the *fix* contains the *hard* argument, the project example won't be shown if the requirement isn't satisfied (*isn't implemented yet*) 
h4. 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 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.
h4. 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: 
h5. 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  https://issues.jboss.org/browse/JBIDE-6214 JBIDE-6214 for more details. 
h5. 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/ 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  https://issues.jboss.org/browse/JBIDE-7890 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
[http://community.jboss.org/docs/DOC-16578]

Create a new document in JBoss Tools at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2128]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20111107/03ccb3c5/attachment.html 


More information about the jboss-user mailing list