pátek 31. října 2014

Wildfly Extension Installer - maven plugin

I recently started to play with RHQ Metrics, especially WildFly Monitor subsystem. One thing I found annoying was copying over module to WildFly and registering it as server extension. As WildFly does not (yet) support adding extensions at runtime, I decided to write a maven plugin for it.

Plugin features

  • Install module - this is an easy one.Plugin requires a module zip file and just extracts it into your WF home.
  • Register extension - your module gets automatically added among server extensions
  • Register subsystem - if you supply subsystem xml file, plugin puts it's content to right place
  • Register socket-binding - if your subsystem requires to set socket binding and you supply socket-binding xml file, plugin puts it's content to right place
  • Support for domain.xml - all above applies to domain.xml as well, for subsystem and socket-bindings you just need to provide wich profiles and socket-binding-groups to affect.

Example usage

Prepare your module.zip (ie. using maven-assembly-plugin) see for example pom.xml and module-assembly.xml from wildfly-monitor project.

Setup your build:
<?xml version="1.0" encoding="UTF-8"?>
...
<plugin>
<groupId>org.jboss.plugins</groupId>
<artifactId>wildfly-extension-maven-plugin</artifactId>
<version>${version.wildfly-extension-maven-plugin}</version>
<configuration>
<!-- required: -->
<moduleZip>${project.build.directory}/module.zip</moduleZip>
<!-- required: WF home -->
<jbossHome>/jboss/wildfly-8.1.0.Final</jbossHome>
<!-- optional: standalone.xml or domain.xml -->
<serverConfig>standalone/configuration/standalone-full.xml</serverConfig>
<!-- optional: configuration of subystem -->
<subsystem>src/main/resources/standalone-subsystem.xml</subsystem>
<!-- optional: socket-binding configuration -->
<socketBinding>src/main/resource/socket-binding.xml</socketBinding>
</configuration>
<!-- uncomment this piece if you wish to activate plugin any time you run install goal
<executions>
<execution>
<id>build-dist</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
-->
</plugin>
...
view raw pom.xml hosted with ❤ by GitHub
<?xml version="1.0" encoding="UTF-8"?>
<socket-binding name="your binding name" <!-- binding attributes --> />
<?xml version="1.0" encoding="UTF-8"?>
<subsystem xmlns="your namespace">
<!-- subsystem specific content -->
</subsystem>
view raw subsystem.xml hosted with ❤ by GitHub

Run plugin:
mvn wildfly-extension:deploy
For more details take a look at the plugin documentation.

Possible future enhancements

  • Restart server - plugin could optionally restart WildFly server after it has installed module and registered all stuff
  • Extract module only - add option to extract module without registering an extension
  • Assemble module - based on configuration and maven depenencies, plugin could generate module.xml and collect all required jars or directories
  • Add a way to uninstall module and extension from WildFly server

Ideas welcome!


Contribute

If you'd like to contribute, check out source code.

Žádné komentáře:

Okomentovat