Maven Multi-Module Setup

Help
Cyrill
2009-02-25
2013-06-04
  • Cyrill
    Cyrill
    2009-02-25

    Hello,

    Is there a cookbook to setup a multi-module Maven project?
    So my most basically question is if I have to include the xradar configuration file in each module stripped down to only cover the submodules of this module? Or can I place one configuration file in the parent and reference in the module to this configuration? But then while generating a report for a particular module, It wont' find all sources. And If I do the report just from the parent, I have no access to the sources of all modules.

    Anyone has some hints?

    Thanks,

    Cyrill

     
    • Romain PELISSE
      Romain PELISSE
      2009-02-25

      Hi,

      ndox might be able to help. The ugly (but easy) thing you can do is set up a quick and dirty shell or a Ant script to simply copy every sources in directory (let's say, to stay a little mavenish the target/xradar/src) and all the classes (target/xradar/classes), then run XRadar with those.

      This way you will be able to analyse your project, using the 'audit-mode'... However, I completly agree, this is far from perfect. I'm slowly thinking to change stuff to have a real "multiproject" support, but it'll have to wait until 1.1 is release (so most likely in 1.2)

       
      • Nicolas  Dordet
        Nicolas Dordet
        2009-02-25

        By using the maven-xradar-plugin you can have a report for each module but for the moment it's not possible to aggregate the reports in order to have only one.

        You can declare the plugin only in the parent module then you will find the audits in each module.

        I also really think that XRadar should give a multiproject aggregate report.

         
    • Romain PELISSE
      Romain PELISSE
      2009-02-25

      Theorically, if you just do with Maven a "copy every file to a directory" + "copy every classes to another" and "analyse those" that will do your "agregated analysis".. I do not know really well mvn API, but if you can iterate on available source directory and availaible classes directory, this could be really easy to implement...

       
    • Cyrill
      Cyrill
      2009-02-26

      Thanks,

      I will try today to setup the parent report today. I will keep you posted.

      Regards,

      Cyrill

       
    • Cyrill
      Cyrill
      2009-02-26

      Hello,

      I have done the following to copy all compiled classes of the modules to the parent project:

      <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-antrun-plugin</artifactId>
                     <inherited>false</inherited>
                     <executions>
                         <execution>
                             <phase>pre-site</phase>
                             <configuration>
                                 <tasks>
                                     <mkdir dir="target/xradar/classes"/>
                                     <copy todir="target/xradar/classes">
                                         <fileset dir="dcs-model/target/classes" includes="**/*.class"/>
                                         <fileset dir="dcs-ejbclient/target/classes" includes="**/*.class"/>
                                         <fileset dir="dcs-ejb/target/classes" includes="**/*.class"/>
                                         <fileset dir="dcs-ear/target/classes" includes="**/*.class"/>
                                         <fileset dir="dcs-swing/target/classes" includes="**/*.class"/>
                                         <fileset dir="dcs-swing-war/target/classes" includes="**/*.class"/>
                                         <fileset dir="dcs-test/target/classes" includes="**/*.class"/>
                                         <fileset dir="dcs-infrastructure/target/classes" includes="**/*.class"/>
                                     </copy>
                                 </tasks>
                             </configuration>
                             <goals>
                                 <goal>run</goal>
                             </goals>
                         </execution>
                     </executions>
                 </plugin>

      and then executed xradar:

      <plugin>
                     <inherited>false</inherited>
                     <groupId>net.sf.xradar</groupId>
                     <artifactId>maven-xradar-plugin</artifactId>
                     <version>1.2-beta-1</version>
                     <configuration>
                         <classDirectory>${basedir}/target/xradar/classes</classDirectory>
                     </configuration>
                 </plugin>

      ... but since this project is a POM-Project, XRadar plugin does nothing:

      [INFO] dcs is a pom project : skipping Dynamic...

      So what will resolve this issue:
         - allow the <classDirectory> to be an array of <classDirectories>, then I do not need to copy in the class files from the modules
         - provide a configuration option to force the XRadar Plugin from executing his reports in a POM-File.

      Regards,

      Cyrill

       
      • Nicolas  Dordet
        Nicolas Dordet
        2009-02-26

        Need to think about it. Normally in a pom project you don't have classes files, that's why the plugin didn't execute XRadar on those projects.

        We maybe could add a parameter to execute the plugin in a "multimodule mode" and so let Xradar been executed in a pom projects with a list of classes. My fear is that I don't know how the plugins (ckjm, pmd,...) called by the xradar plugins will react...

        Another way, longer but better I think, is to add an xslt that take the submodules reports and make an aggregate one. 

        Have you try the "aggregator" trick of my last post?

         
    • Cyrill
      Cyrill
      2009-02-26

      I have not yet tried out the "aggregator" mode, but this is only for one module since I can only specify one xml file for a particular report and not multiple ones for each module, right?

       
    • Jochen Dornauf
      Jochen Dornauf
      2009-04-01

      if you have success pls. let me know - im highly interested in this topic too.

      regards
      Jochen