Cactus
  1. Cactus
  2. CACTUS-102

support for maven multiproject plugin

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.6
    • Component/s: Maven Integration
    • Labels:
      None
    • Environment:
      maven multiproject

      Description

      Hi guys,

      Here's a proposal for a new goal on multiproject plugin. It allows to run cactus tests on all sub-projects of "war"
      type, the same way junit tests can be run.

      I use it from cruisecontrol scripts to update, compile and test my app (having 3 web modules and 4 jars).

      Nico.

      <!-====================================================================->
      <!-- Exécute les test Cactus sur tous les sous-projects de type "war" -->
      <!-====================================================================->
      <goal name="multiproject:cactus">
      <maven:reactor basedir="$

      {maven.multiproject.basedir}

      "
      includes="$

      {maven.multiproject.includes}

      "
      excludes="$

      {maven.multiproject.excludes}

      "
      postProcessing="true"
      ignoreFailures="$

      {maven.multiproject.ignoreFailures}" />

      <j:forEach var="reactorProject" items="${reactorProjects}">
      <j:set
      var="type"
      value="${reactorProject.getContext().getVariable('maven.multiproject.type')}"/>
      <j:if test="${type == 'war'}">
      <ant:echo>----------------------------------------------------</ant:echo>
      <ant:echo>Running cactus test for ${reactorProject.artifactId}</ant:echo>
      <ant:echo>----------------------------------------------------</ant:echo>
      <maven:maven
      descriptor="${basedir}/../${reactorProject.artifactId}/project.xml"
      goals="cactus"
      ignoreFailures="${maven.multiproject.ignoreFailures}

      " />
      </j:if>
      </j:forEach>
      </goal>

      1. patch.txt
        1 kB
        nicolas de loof

        Activity

        Hide
        Vincent Massol added a comment -

        Hi Nicolas,

        Why not do the following instead:

        • Create a goal in your top level maven.xml:

        <goal name="cactus-run">
        <j:if test="$

        {context.getVariable('maven.multiproject.type')== 'war'}

        ">
        <attainGoal name="cactus"/>
        </j:if>
        </goal>

        Then you invoke it with:

        maven -Dgoal=cactus-run multiproject:goal

        Of course you can make it even more automated by adding the following to maven.xml:

        <goal name="multicactus">
        <j:set var="goal" value="cactus-run"/>
        <attainGoal name="multiproject:goal"/>
        </goal>

        Then typing "maven multicactus" will perform the feat.

        We cannot apply your solution as is because you're suggesting to modify the multiproject plugin by introducing a dependency on Cactus. As Cactus is out of the "core" maven plugins, it won't be possible.

        Thanks

        Show
        Vincent Massol added a comment - Hi Nicolas, Why not do the following instead: Create a goal in your top level maven.xml: <goal name="cactus-run"> <j:if test="$ {context.getVariable('maven.multiproject.type')== 'war'} "> <attainGoal name="cactus"/> </j:if> </goal> Then you invoke it with: maven -Dgoal=cactus-run multiproject:goal Of course you can make it even more automated by adding the following to maven.xml: <goal name="multicactus"> <j:set var="goal" value="cactus-run"/> <attainGoal name="multiproject:goal"/> </goal> Then typing "maven multicactus" will perform the feat. We cannot apply your solution as is because you're suggesting to modify the multiproject plugin by introducing a dependency on Cactus. As Cactus is out of the "core" maven plugins, it won't be possible. Thanks
        Hide
        nicolas de loof added a comment -

        As an alternative, could the cactus goal be enhanced to do nothing on any project having maven.multiproject.type not set to "war" (if this variable is set ? This way we can use "maven -DGoal=cactus multiproject:goal" without having to configure any maven.xml script.

        Show
        nicolas de loof added a comment - As an alternative, could the cactus goal be enhanced to do nothing on any project having maven.multiproject.type not set to "war" (if this variable is set ? This way we can use "maven -DGoal=cactus multiproject:goal" without having to configure any maven.xml script.
        Hide
        Vincent Massol added a comment -

        We cannot penalize users that are not using the multiproject plugin! Imagine all exciting projects that suddenly do not work because they have not set this multiproject property!

        Also, you have to realize that this multiproject type property is a hack. It is temporary and will be removed after Maven 1.0 is released. If you use Maven from CVS HEAD (i.e. 1.1-SNAPSHOT), there is already a new <type> tag that you can use in your POM to define the type of your project. CVS HEAD it has all the bug fixes till Maven rc2 (but not the recent ones from rc3 - They will be merged very soon now).

        What don't you like with the solution I've proposed in my previous answer? It's not very complex I think.

        Show
        Vincent Massol added a comment - We cannot penalize users that are not using the multiproject plugin! Imagine all exciting projects that suddenly do not work because they have not set this multiproject property! Also, you have to realize that this multiproject type property is a hack. It is temporary and will be removed after Maven 1.0 is released. If you use Maven from CVS HEAD (i.e. 1.1-SNAPSHOT), there is already a new <type> tag that you can use in your POM to define the type of your project. CVS HEAD it has all the bug fixes till Maven rc2 (but not the recent ones from rc3 - They will be merged very soon now). What don't you like with the solution I've proposed in my previous answer? It's not very complex I think.
        Hide
        nicolas de loof added a comment -

        Didn't miss compatibility with non-multiproject maven users

        We can use something like this (without cactus.test.ear for lisibility) :

        <goal name="cactus:test" description="Run all Cactus tests">

        <j:set var="multiType"
        value="X$

        {context.getVariable('maven.multiproject.type')}

        "/>
        <!-- run cactus only if maven.multiproject.type is 'war' or not set -->
        <j:if test="$

        {multiType == 'X' or multiType == 'Xwar'}

        ">
        <attainGoal name="cactus:test-war"/>
        </j:if>
        </goal>

        Show
        nicolas de loof added a comment - Didn't miss compatibility with non-multiproject maven users We can use something like this (without cactus.test.ear for lisibility) : <goal name="cactus:test" description="Run all Cactus tests"> <j:set var="multiType" value="X$ {context.getVariable('maven.multiproject.type')} "/> <!-- run cactus only if maven.multiproject.type is 'war' or not set --> <j:if test="$ {multiType == 'X' or multiType == 'Xwar'} "> <attainGoal name="cactus:test-war"/> </j:if> </goal>
        Hide
        Vincent Massol added a comment -

        You know what would be even better? That the Cactus plugin finds out by itself if the project contains Cactus tests. Then it will decide or not to run the tests.

        That would be even better than all this, no?

        BTW, the war type would not be enough. Ejb/ear projects can also run Cactus projects.

        Show
        Vincent Massol added a comment - You know what would be even better? That the Cactus plugin finds out by itself if the project contains Cactus tests. Then it will decide or not to run the tests. That would be even better than all this, no? BTW, the war type would not be enough. Ejb/ear projects can also run Cactus projects.
        Hide
        nicolas de loof added a comment -

        That's so simple I just didn't think about such a solution.

        Show
        nicolas de loof added a comment - That's so simple I just didn't think about such a solution.
        Hide
        nicolas de loof added a comment -

        Don't run cactus if $

        {cactusSourcePresent}

        is not set (no test to run)

        Show
        nicolas de loof added a comment - Don't run cactus if $ {cactusSourcePresent} is not set (no test to run)
        Hide
        Vincent Massol added a comment -

        Applied. Thanks.

        Show
        Vincent Massol added a comment - Applied. Thanks.

          People

          • Assignee:
            Vincent Massol
            Reporter:
            nicolas de loof
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development