Issue Details (XML | Word | Printable)

Key: CACTUS-102
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Vincent Massol
Reporter: nicolas de loof
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Cactus

support for maven multiproject plugin

Created: 21/Apr/04 04:13 PM   Updated: 22/Apr/04 08:52 PM
Return to search
Component/s: Maven Integration
Affects Version/s: None
Fix Version/s: 1.6

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works patch.txt 2004-04-22 12:26 PM nicolas de loof 1 kB
Environment: maven multiproject

Resolution Date: 22/Apr/04 08:52 PM


 Description  « Hide
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>



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Vincent Massol added a comment - 21/Apr/04 06:40 PM
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

Vincent Massol made changes - 21/Apr/04 06:40 PM
Field Original Value New Value
Assignee Vincent Massol [ vmassol ]
Vincent Massol made changes - 21/Apr/04 07:09 PM
Fix Version/s 1.6 [ 10691 ]
nicolas de loof added a comment - 22/Apr/04 06:55 AM
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.

Vincent Massol added a comment - 22/Apr/04 11:26 AM
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.

nicolas de loof added a comment - 22/Apr/04 11:35 AM
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>

Vincent Massol added a comment - 22/Apr/04 11:42 AM
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.

nicolas de loof added a comment - 22/Apr/04 12:12 PM
That's so simple I just didn't think about such a solution.



nicolas de loof added a comment - 22/Apr/04 12:26 PM
Don't run cactus if ${cactusSourcePresent} is not set (no test to run)

nicolas de loof made changes - 22/Apr/04 12:26 PM
Attachment patch.txt [ 14420 ]
Vincent Massol added a comment - 22/Apr/04 08:52 PM
Applied. Thanks.

Vincent Massol made changes - 22/Apr/04 08:52 PM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Closed [ 6 ]