WebLab Archetype Plugin

From WebLab Wiki
Jump to: navigation, search

Goal of the plugin

This plugin allows to generate WebLab service(s) stub(s) with all resources necessary for their execution. According to usage, it uses several archetypes that should not be called outside of this plugin.

Maven configuration

First of all, if it's not done, you have to install Maven (see maven documentation[1]). Then, you have to modifying the file <maven directory>/conf/settings.xml. If you already have a profile in your settings, then you just have to add this in the repositories markup :

[...]
<repositories>
[...]
    <repository>
        <id>ow2</id>
        <url>http://maven.ow2.org/maven2</url>
        <name>ow2</name>
    </repository>
    <repository>
	<id>ow2-snapshot</id>
	<url>http://maven.ow2.org/maven2-snapshot/</url>
	<name>ow2-snapshot</name>
    </repository>
    <repository>
        <id>weblab</id>
        <url>http://maven.weblab-project.org/</url>
        <name>weblab</name>
    </repository>
    <repository>
	<id>weblab-snapshot</id>
	<url>http://maven-snapshot.eblab-project.org/</url>
	<name>weblab-snapshot</name>
    </repository> 
</repositories>
[...]

If not, you have to create a new profile in the profiles mark-up, and activate the profile in the settings mark-up, such as below :

<settings ...>
[...]
    <profiles>
        <profile>
            <id>AnyIDYouWant</id> <!-- must be the same as below -->
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <repositories>
                <repository>
                    <id>ow2</id>
                    <url>http://maven.ow2.org/maven2</url>
                    <name>ow2</name>
                </repository>
                <repository>
	            <id>ow2-snapshot</id>
	            <url>http://maven.ow2.org/maven2-snapshot/</url>
	            <name>ow2-snapshot</name>
                </repository>
		<repository>
        		<id>weblab</id>
        		<url>http://maven.weblab-project.org/</url>
        		<name>weblab</name>
		   </repository>
		   <repository>
			<id>weblab-snapshot</id>
			<url>http://maven-snapshot.eblab-project.org/</url>
                	<name>weblab-snapshot</name>
               </repository> 
            </repositories>
            <pluginRepositories>
		<pluginRepository>
		    <id>ow2</id>
		    <url>http://maven.ow2.org/maven2</url>
                    <name>ow2</name>
		</pluginRepository>
		<pluginRepository>
		    <id>ow2-snapshot</id>
		    <url>http://maven.ow2.org/maven2-snapshot/</url>
		    <name>ow2-snapshot</name>
		</pluginRepository>
	    </pluginRepositories>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>AnyIDYouWant</activeProfile> <!-- must be the same as above -->
    </activeProfiles>
</settings>

To invoke the plugin by its prefix weblab you have to add group identifier (i.e.: mvn weblab:generate ...):

<settings ...>
[...]
    <pluginGroups>
    [...]
        <pluginGroup>org.ow2.weblab.tools.maven</pluginGroup>
    </pluginGroups>
</settings>

With this configuration, Maven can retrieve libraries needed to the next steps.

Usage

Calls to the plugin is as follows:

mvn org.ow2.weblab.tools.maven:weblab-archetype-plugin:generate

or simply (see below how to enable this)

mvn weblab:generate

Some parameters are compulsory:

  • -DserviceName: The name of service(s) classes. Concatenated with the interface name whether more than two WebLab interfaces are invoking;
  • -DwebLabInterface: A comma separated list of interfaces to be implemented. It can either be their number or their simple name;
  • -DartifactId: The name of the project and actifactId to be used in generated POM.


Some other are optional:

  • -DgroupId: The groupId to be used in the generated pom. Default value is org.ow2.weblab.service;
  • -Dpackage: The package to be used for generated classes. Default value is groupId;
  • -Dversion: The version to be used in the generated pom. Default value is 1.0-SNAPSHOT.


WebLab Web service(s) implement several interfaces which can be:

  • 1 <=> analyser
  • 2 <=> configurable
  • 3 <=> indexer
  • 4 <=> queuemanager
  • 5 <=> reportprovider --> deprecated since WebLab 1.2.5, please consider using an Auditable combine with an Indexer
  • 6 <=> resourcecontainer
  • 7 <=> searcher
  • 8 <=> sourcereader --> deprecated since WebLab 1.2.5, please consider using a QueueManager
  • 9 <=> trainable
  • 10 <=> auditable
  • 11 <=> cleanable


Example command line

Invoke the plugin with the required parameters can be for instance:

mvn org.ow2.weblab.tools.maven:weblab-archetype-plugin:generate
-DserviceName=Service
-DwebLabInterface=analyser
-DartifactId=Test

The plugin will then generate the following folders and files:

├── pom.xml
└── src
    ├── main
    │   ├── java
    │   │   └── org
    │   │       └── ow2
    │   │           └── weblab
    │   │               └── service
    │   │                   └── Service.java
    │   └── webapp
    │       └── WEB-INF
    │           ├── cxf-servlet.xml
    │           └── web.xml
    └── test
        ├── java
        │   └── org
        │       └── ow2
        │           └── weblab
        │               └── service
        │                   └── ServiceTest.java
        └── resources
            ├── corpus
            │   └── resourceTest.xml
            └── log4j.properties

Invoke with prefix

When the plugin group identifier is added in the file <maven directory>/conf/settings.xml, the command line may be simplified as follows:

mvn weblab:generate ...

Display documentation

To display help of the plugin, you can used the specific goal:

mvn org.ow2.weblab.tools.maven:weblab-archetype-plugin:help

Extra documentation

For more information, follow the link hereafter:


  1. http://maven.apache.org/