Version 1

    We started with JBoss modules recently and had the problem of generating the modules structure for some of our projects. Therefore we wrote a small plugin for Maven that generates module folders with module XMLs based on proprietary XML descriptors. The plugin is called smartics-jboss-modules-maven-plugin.

     

    To give you a short impression, what the plugin does, here is a descriptor that maps all artifacts of the (transitive) dependencies of a Maven BOM to a module named 'de.smartics.exceptions':

     

    <modules xmlns="http://smartics.de/ns/jboss-modules-descriptor/1">
      <module name="$g1">
        <match>
          <includes>
            <include>
              <groupId>(de.smartics.exceptions)</groupId>
            </include>
          </includes>
        </match>
      </module>
    </modules>
    

     

    So every artifact found in the project is matched and a (individual) module is created. For instance, the generated module.xml for the 'de.smartics.exceptions' module is this:

     

    <module xmlns="urn:jboss:module:1.1" name="de.smartics.exceptions">
      <resources>
        <resource-root path="smart-exceptions-core-0.12.3-SNAPSHOT.jar" />
        <resource-root path="smart-exceptions-i18n-0.12.3-SNAPSHOT.jar" />
        <resource-root path="smart-exceptions-report-0.12.3-SNAPSHOT.jar" />
      </resources>
      <dependencies>
        <module name="com.google.code.findbugs.jsr305" />
        <module name="com.google.guava" />
        <module name="com.ibm.icu.icu4j" />
        <module name="com.thoughtworks.qdox" />
        <module name="commons-configuration" />
        <module name="commons-io" />
        <module name="commons-lang" />
        <module name="commons-logging" />
        <module name="de.smartics.messages.smart-messages-core" />
        <module name="de.smartics.properties.smart-properties-core" />
        <module name="de.smartics.util.smartics-commons" />
        <module name="ognl" />
        <module name="org.apache.ant" />
        <module name="org.javassist" />
      </dependencies>
    </module>
    

     

    Not every descriptor is that short, especially if you want to add additional information (export, optional, ...) to the generated modules. But it is not that hard either. I don't want to bother you with the details here, but you'll find more information about this plugin at it's home page, the project's blog (especially in this blog post) or the BOM project with the configuration given above.

     

    We just started to work with it, but it already makes the process of synchronization between the POM and the module.xml (plus directory structure) for our projects very easy. Recently we got some encouraging user feedback, but the number of users is still quite small.

     

    I wonder how other developers, who do use or do not use Maven, generate the module structure for their projects. What do you think about our approach?

     

    Note: I thought this thing would be more appropriate as a blog article (because it sketches just a thought with a few questions at the end). Unfortunately I did not mange to get it published due to problems selecting the right place (none has been shown as selectable and all guessed place names were rejected). I hope the article format is also ok ...