Hello all,

I'm writing a blog post about the creation of RHQ plugin and I'm trying all the paths to get it done. Well, I've already done it before but now I'm starting from the very beginning, trying to follow the same steps a newbie would do.

1. The first trying was using the Skeleton Plugin [1].

I updated my source tree to rev 4298, built it and everything went just fine. Then, I made a copy of etc/samples/skeleton-plugin on /modules/plugins/test1, tried to build it and, for my surprise, it didn't compile!

test1$ mvn package 
(...)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
/Volumes/Data/Code/jboss.org/rhq/modules/plugins/test1/src/main/java/org/rhq/sample/skeletonplugin/SamplePluginServerComponent.java:[39,43] package org.rhq.core.pluginapi.availability does not exist



/Volumes/Data/Code/jboss.org/rhq/modules/plugins/test1/src/main/java/org/rhq/sample/skeletonplugin/SamplePluginServerComponent.java:[39,43] package org.rhq.core.pluginapi.availability does not exist


[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20 seconds
[INFO] Finished at: Fri Jul 03 09:48:48 BRT 2009
[INFO] Final Memory: 6M/15M

The same error happens if I set test1 as a module in plugins' pom.xml and build it from modules/plugins dir.


2. The second trying was using Maven Archetype [2]

I did

plugins$ mvn archetype:generate -DarchetypeGroupId=org.rhq -DarchetypeArtifactId=rhq-plugin-archetype -DarchetypeVersion=1.0.0.GA -DarchetypeRepository=http://snapshots.jboss.org/maven2/ -Drhq-plugin-name=test2 -DgroupId=my.second.test -DartifactId=test2 -Dversion=1.3.0-SNAPSHOT -Dpackage=my.second.test

but I had to change some arguments to get depended libs compatible with my source tree. This should be clear in [2] instructions.

test2 plugin was built and deployed successfully. WOW! 

11:08:04,592 INFO  [ProductPluginDeployer] Discovered agent plugin [test2]
11:08:04,766 INFO  [ProductPluginDeployer] Deploying [1] new or updated agent plugins: [test2]
11:08:05,217 INFO  [ProductPluginDeployer] Plugin metadata updates are complete: [test2]


3. The third trying was using Plugin Generator 

plugins$ java -jar rhq-pluginGen-1.2.2-jar-with-dependencies.jar 
Please specify the plugin root category PLATFORM(P), SERVER(S), SERVICE(I), i
Please specify its PackagePrefix: my.third.test  
Please specify its FileSystemRoot: /Users/alegomes/Code/jboss.org/rhq-mssql/modules/plugins
Please specify its ComponentClass: ThirdComponent
Please specify its DiscoveryClass: ThirdDiscovery
Please specify if it should support Events (y/N): 
Please specify its ParentType: 
Please specify if it should support Monitoring (y/N): y
Please specify if it should support Operations (y/N): 
Please specify if it should support Singleton (y/N): 
Please specify if it should support ResourceConfiguration (y/N): 
Please specify if it should support CreateChildren (y/N): y
Please specify if it should support UsesExternalJarsInPlugin (y/N): y
Please specify if it should support DeleteChildren (y/N): y
Please specify if it should support ManualAddOfChildren (y/N): y
Please specify if it should support UsePluginLifecycleListenerApi (y/N): 
Please specify its Name: test3
Please specify its Description: My third Test

Do you want to add a child to test3? (y/N) 
Don't forget to add your plugin to the parent pom.xml

plugins$ cd test3
test3 $ mvn package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

GroupId: org.rhq
ArtifactId: rhq-plugins-parent
Version: 1.2.0-SNAPSHOT

Reason: Unable to download the artifact from any repository

  org.rhq:rhq-plugins-parent:pom:1.2.0-SNAPSHOT

from the specified remote repositories:
  central (http://repo1.maven.org/maven2)

...
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Tue Jul 07 11:48:59 BRT 2009
[INFO] Final Memory: 1M/2M
[INFO] ------------------------------------------------------------------------

Oh yes, I forgot, we need to change test3/pom.xml, replacing

<version>1.2.0-SNAPSHOT</version><!-- TODO adjust RHQ version -->

by

<version>1.3.0-SNAPSHOT</version><!-- TODO adjust RHQ version -->

What about showing at the end of plugin generation process the instruction of changing pom.xml?

Then, when I tried to deploy my brand new plugin, I got a problem:

19:07:05,942 INFO  [ProductPluginDeployer] Discovered agent plugin [test3]
19:07:05,977 INFO  [ProductPluginDeployer] Deploying [1] new or updated agent plugins: [test3]
19:07:06,249 ERROR [PluginMetadataManager] Error transforming plugin descriptor [test3].
org.rhq.core.clientapi.agent.metadata.InvalidPluginDescriptorException: Configuration properties are missing. Resource configurations must have at least one group or one config-property as a child. 
...
19:07:06,279 ERROR [ProductPluginDeployer] Failed to register RHQ plugin file [test3-plugin-1.3.0-SNAPSHOT.jar] at [file:/Volumes/Data/Code/jboss.org/rhq-mssql/modules/enterprise/server/container/target/rhq-server-1.3.0-SNAPSHOT/jbossas/server/default/tmp/deploy/tmp2270423192953241509test3-plugin-1.3.0-SNAPSHOT.jar]
java.lang.Exception: Failed to load plugin [test3].


Isn't it strange a generated code not deploying correctly?


[1] http://support.rhq-project.org/display/RHQ/Plugins+-+Skeleton+Plugin
[2] http://support.rhq-project.org/display/RHQ/Plugins+-+Archetype


Hope this helps somehow....
--
[]s!