At 08:32 PM 9/26/2005, Anthony Kong wrote:

2) To proceed, I hardcoded the value in the <maven:set/> tag.

It is something like:

            <maven:set plugin="maven-test-plugin"
                property="maven.test.skip"
                value="true"/>

Then there is an runtime error:

You must define an attribute called 'value' for this tag.


Anthony,

You might want to try adding the artifact namespace to your project tag. As in xmlns:artifact="artifact". I have found that with M1 1.0.2 and 1.1b1 that the artifact namespace was necessary in order to set values in plugins.

I realized that I did have an existing project on which I could experiment. I've included a fragment of a maven.xml file, but I'm using Maven 1.1b2 so your mileage may vary.

The coverage goal will execute the jblanket, jcoverage, and emma coverage tools. Coverage tools instrument the code under test and then run the testcases and report the % of the CUT that is covered. In this case, using preGoals from the coverage tools I first checked to see if maven.test.skip.value was not empty and removed it if it was and then set the value of maven.test.skip.value to true. In the postGoal for test:test I changed the value of maven.test.skip.value to false. So in this example I am varying the value of the Jelly variable serving as a sentinel and setting the a plugin variable's value. If you are interested, I've got a trace of the execution of this maven.xml file which I'm willing to mail to you.

Hope that this helps.



<project default="coverage"
    xmlns:j="jelly:core"
    xmlns:license="license"
    xmlns:maven="jelly:maven"
    xmlns:util="jelly:util"
    xmlns:ant="jelly:ant">>

  <goal name="coverage">
    <attainGoal name="jblanket:coverage"/>
    <attainGoal name="jcoverage"/>
    <attainGoal name="emma:report"/>
  </goal>

  <preGoal name="jblanket:coverage">
<echo message="value of maven.test.skip.value is ${maven.test.skip.value}"/>
    <j:if test="${!empty(maven.test.skip.value)}">
      <j:remove var="maven.test.skip.value"/>
      <echo message="executing j:remove of maven.test.skip.value"/>
    </j:if>
    <j:set var="maven.test.skip.value" value="true"/>
  </preGoal>

  <preGoal name="jcoverage:on">
<echo message="value of maven.test.skip.value is ${maven.test.skip.value}"/>
    <j:if test="${!empty(maven.test.skip.value)}">
      <j:remove var="maven.test.skip.value"/>
      <echo message="executing j:remove of maven.test.skip.value"/>
    </j:if>

    <j:set var="maven.test.skip.value" value="true"/>
  </preGoal>

  <preGoal name="emma:init">
<echo message="value of maven.test.skip.value is ${maven.test.skip.value}"/>
    <j:if test="${!empty(maven.test.skip.value)}">
      <j:remove var="maven.test.skip.value"/>
      <echo message="executing j:remove of maven.test.skip.value"/>
    </j:if>
    <j:set var="maven.test.skip.value" value="true"/>
  </preGoal>

  <preGoal name="test:test">
<echo message="value of maven.test.skip.value is ${maven.test.skip.value}"/> <maven:set plugin="maven-test-plugin" property="maven.test.skip" value="${maven.test.skip.value}"/> <maven:get plugin="maven-test-plugin" property="maven.test.skip" var="reported.maven.test.skip"/> <echo message="value of reported.maven.test.skip is ${reported.maven.test.skip}"/>
  </preGoal>

  <postGoal name="test:test">
    <j:if test="${!empty(maven.test.skip.value)}">
      <echo message="maven.test.skip.value is ${maven.test.skip.value}"/>
      <j:set var="maven.test.skip.value" value="false"/>
    </j:if>
  </postGoal>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to