You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Michael Owen <mi...@hotmail.com> on 2005/09/16 16:18:12 UTC
[m1.1b2] maven.test.skip not working
Hi,
I'm using Maven 1.1 beta 2 and I've got a goal which does a multiproject
build and creates a multiproject site. I would like the tests to only be run
once when running this "multi:all" and therefore I've created the goal
below:
<goal name="multi:all">
<!-- Only runs the tests while building the site -->
<attainGoal name="clean"/>
<j:set var="trueValue" value="true" />
${pom.getPluginContext('maven-test-plugin').setVariable('maven.test.skip',trueValue)}
<attainGoal name="multi:build" />
<j:set var="falseValue" value="false" />
${pom.getPluginContext('maven-test-plugin').setVariable('maven.test.skip',falseValue)}
<attainGoal name="multi:site" />
</goal>
However, the tests are still being run for the multi:build goal (note this
is just a custom multiproject build goal) because maven.test.skip is still
false. Any ideas how I can get this working without putting on
-Dmaven.test.skip=true on the command line or putting it in a properties
file.
Thanks in advance,
Mike
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: [m1.1b2] maven.test.skip not working
Posted by Andy Glick <an...@acm.org>.
Andy Glick wrote:
> I have had success doing the following:
>
> 1) add xmlns:artifact="artifact" to the maven.xml file's project tag
>
> 2) add the following preGoal code:
>
> <preGoal name="test:test">
> <echo message="test:test preGoal"/>
> <!-- -->
> <maven:set plugin="maven.test.plugin" property="maven.test.skip"
> value="true"/>
> <!-- -->
> </preGoal>
>
>
> I found that if the maven:set was commented out the tests ran, and when
> it was not, the tests did not run. I think that is what you want, yes?
>
> Hope that this helps.
Sorry, I think that I wasn't clear about which maven.xml file. When I have set the command line property -Dmaven.test.skip=true, then the testing phase never executes any tests in any subproject.
The example that I gave was to be applied per maven.xml file in each directory where you want to allow test execution to be turned off. You might want to think about adding a test for a property that you could set on the command line, which, if set, could cause the maven.test.skip property to be set to true.
>From my understanding, each time the test plugin is instantiated in a maven.xml file which executes its tests under normal conditions, you must explicitly set the variable maven.test.skip as the plugin is initialized. This is a Jelly issue, apparently the window of opportunity for setting plugin variables explicitly is quite small, which is why I used a preGoal on the test plugin to accomplish it.
see [http://jira.codehaus.org/browse/MAVEN-1656] for Brett's explanation about setting Maven plugin variables.
Again, this worked under M1.1b1, under M1.1b2 your mileage may vary.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: [m1.1b2] maven.test.skip not working
Posted by Andy Glick <an...@acm.org>.
I have had success doing the following:
1) add xmlns:artifact="artifact" to the maven.xml file's project tag
2) add the following preGoal code:
<preGoal name="test:test">
<echo message="test:test preGoal"/>
<!-- -->
<maven:set plugin="maven.test.plugin" property="maven.test.skip"
value="true"/>
<!-- -->
</preGoal>
I found that if the maven:set was commented out the tests ran, and when it
was not, the tests did not run. I think that is what you want, yes?
Hope that this helps.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: [m1.1b2] maven.test.skip not working
Posted by Arnaud HERITIER <ah...@gmail.com>.
It seems we have weird problems with variables scope in m1.1
your problem is certainly a side-effect of this issue :
http://jira.codehaus.org/browse/MAVEN-1691
It's a workaround you can use, waiting for a fix, but it's very dangerous to
use the parent scope.
You must check if it doesn't create another side-effect
Arnaud
On 9/19/05, Michael Owen <mi...@hotmail.com> wrote:
>
>
>
> I've solved the problem. The multiproject goal needed changing to:
>
> <goal name="multi:all">
>
> <!-- Only runs the tests while building the site -->
> <attainGoal name="clean"/>
>
> <j:set var="maven.disable.tests" value="true" scope="parent" />
>
> <attainGoal name="multi:build" />
>
> <j:set var="maven.disable.tests" value="false" scope="parent" />
>
> <attainGoal name="multi:site" />
>
> </goal>
>
> i.e. scope="parent" added.
>
>
>
>
> <BLOCKQUOTE style='PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT:
> #A0C6E5
> 2px solid; MARGIN-RIGHT: 0px'><font
> style='FONT-SIZE:11px;FONT-FAMILY:tahoma,sans-serif'><hr color=#A0C6E5
> size=1>
> From: <i>"Michael Owen"
> <mi...@hotmail.com></i><br>Reply-To: <i>"Maven Users
> List" <us...@maven.apache.org></i><br>To:
> <i>users@maven.apache.org</i><br>Subject: <i>Re: [m1.1b2] maven.test.skip
> not working</i><br>Date: <i>Mon, 19 Sep 2005 10:03:09
> +0100</i><br>>Hi,<br>><br>>Many thanks for your help. It is very
> appreciated. However, tried <br>>the code you suggest and it is still not
> working. Using the print
> <br>>statement:<br>><br>><ant:echo>(1) maven.disable.tests =
> <br>>${context.getVariable('maven.disable.tests')}</ant:echo><br>><br>>in
> the code (which is in a common maven.xml file):<br>><br>>
> <preGoal name="test:test"><br>><br>>
> <j:choose><br>> <j:when
> <br>>test="${context.getVariable('maven.disable.tests') ==
> 'true'}"><br>> <ant:echo>(1)
> maven.disable.tests =
> <br>>${context.getVariable('maven.disable.tests')}</ant:echo><br>>
> <maven:set plugin="maven-test-plugin"
> <br>>property="maven.test.skip" value="true"
> /><br>> </j:when><br>><br>>
> <j:otherwise><br>> <ant:echo>(2)
> maven.disable.tests =
> <br>>${context.getVariable('maven.disable.tests')}</ant:echo><br>>
> </j:otherwise><br>>
> </j:choose><br>><br>> </preGoal><br>><br>>The
> varaiable maven.disable.tests appears to be empty when running <br>>the
> goal multi:all, however, shouldn't be due to code in the <br>>buildsystem
> maven.xml, where the goal is executed from:<br>><br>> <goal
> name="multi:all"><br>><br>> <!-- Only runs the
> tests while building the site --><br>> <attainGoal
> name="clean"/><br>><br>> <j:set
> var="maven.disable.tests" value="true"
> /><br>><br>> <attainGoal name="multi:build"
> /><br>><br>> <j:set var="maven.disable.tests"
> value="false" /><br>><br>> <attainGoal
> name="multi:site" /><br>><br>>
> </goal><br>><br>>Tried changing the <j:set
> var="maven.disable.tests" value="true" />
> <br>>statement to ${context.setVariable('maven.disable.tests','true')}
> <br>>etc. with no luck.<br>><br>>Does anybody have any
> suggestions?<br>><br>>Thanks<br>><br>>Mike<br>><br>><br>><br>><br>>I
> finally worked out some Jelly code that I believe addresses your
> <br>>requirements using m1.1b2:<br>><br>>1) my earlier remarks
> about the artifact plugin's namespace can be <br>>ignored, it isn't
> required<br>><br>>2) in your multiproject context, if you add the
> preGoal logic to the <br>>top level maven.xml file it will be inherited
> by the subprojects, so <br>>it is required only once<br>><br>>3)
> the behavior varies based on the value of the Maven variable
> <br>>maven.disable.tests, which you can set programatically as
> needed<br>><br>>4) the echo statements were included to produce warm
> fuzzies<br>><br>><preGoal name="test:test"><br>>
> <j:choose><br>> <j:when
> test="${context.getVariable('maven.disable.tests') ==
> <br>>'true'}"><br>> <echo message="in test:test
> preGoal maven.disable.tests == <br>>true"/><br>>
> <maven:set plugin="maven-test-plugin"
> <br>>property="maven.test.skip"<br>>
> value="true"/><br>> </j:when><br>>
> <j:otherwise><br>> <echo message="in test:test
> preGoal maven.disable.tests != <br>>true"/><br>>
> </j:otherwise><br>>
> </j:choose><br>></preGoal><br>><br>>So your code could
> be modified as follows:<br>><br>><goal
> name="multi:all"><br>><br>> <!-- Only runs the
> tests while building the site --><br>> <attainGoal
> name="clean"/><br>><br>> <j:set
> var="maven.disable.tests" value="true" /><br>>
> <attainGoal name="multi:build" /><br>><br>>
> <j:set var="maven.disable.tests" value="false"
> /><br>><br>> <attainGoal name="multi:site"
>
> /><br>><br>></goal><br>><br>><br>>---------------------------------------------------------------------<br>>To
> unsubscribe, e-mail: users-unsubscribe@maven.apache.org<br>>For
> additional commands, e-mail:
> users-help@maven.apache.org
> <br>><br>><br>><br>>---------------------------------------------------------------------<br>>To
> unsubscribe, e-mail: users-unsubscribe@maven.apache.org<br>>For
> additional commands, e-mail:
> users-help@maven.apache.org<br>><br></font></BLOCKQUOTE>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
Re: [m1.1b2] maven.test.skip not working
Posted by Michael Owen <mi...@hotmail.com>.
I've solved the problem. The multiproject goal needed changing to:
<goal name="multi:all">
<!-- Only runs the tests while building the site -->
<attainGoal name="clean"/>
<j:set var="maven.disable.tests" value="true" scope="parent" />
<attainGoal name="multi:build" />
<j:set var="maven.disable.tests" value="false" scope="parent" />
<attainGoal name="multi:site" />
</goal>
i.e. scope="parent" added.
<BLOCKQUOTE style='PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #A0C6E5
2px solid; MARGIN-RIGHT: 0px'><font
style='FONT-SIZE:11px;FONT-FAMILY:tahoma,sans-serif'><hr color=#A0C6E5
size=1>
From: <i>"Michael Owen"
<michaelowenuk@hotmail.com></i><br>Reply-To: <i>"Maven Users
List" <users@maven.apache.org></i><br>To:
<i>users@maven.apache.org</i><br>Subject: <i>Re: [m1.1b2] maven.test.skip
not working</i><br>Date: <i>Mon, 19 Sep 2005 10:03:09
+0100</i><br>>Hi,<br>><br>>Many thanks for your help. It is very
appreciated. However, tried <br>>the code you suggest and it is still not
working. Using the print
<br>>statement:<br>><br>><ant:echo>(1) maven.disable.tests =
<br>>${context.getVariable('maven.disable.tests')}</ant:echo><br>><br>>in
the code (which is in a common maven.xml file):<br>><br>>
<preGoal name="test:test"><br>><br>>
<j:choose><br>> <j:when
<br>>test="${context.getVariable('maven.disable.tests') ==
'true'}"><br>> <ant:echo>(1)
maven.disable.tests =
<br>>${context.getVariable('maven.disable.tests')}</ant:echo><br>>
<maven:set plugin="maven-test-plugin"
<br>>property="maven.test.skip" value="true"
/><br>> </j:when><br>><br>>
<j:otherwise><br>> <ant:echo>(2)
maven.disable.tests =
<br>>${context.getVariable('maven.disable.tests')}</ant:echo><br>>
</j:otherwise><br>>
</j:choose><br>><br>> </preGoal><br>><br>>The
varaiable maven.disable.tests appears to be empty when running <br>>the
goal multi:all, however, shouldn't be due to code in the <br>>buildsystem
maven.xml, where the goal is executed from:<br>><br>> <goal
name="multi:all"><br>><br>> <!-- Only runs the
tests while building the site --><br>> <attainGoal
name="clean"/><br>><br>> <j:set
var="maven.disable.tests" value="true"
/><br>><br>> <attainGoal name="multi:build"
/><br>><br>> <j:set var="maven.disable.tests"
value="false" /><br>><br>> <attainGoal
name="multi:site" /><br>><br>>
</goal><br>><br>>Tried changing the <j:set
var="maven.disable.tests" value="true" />
<br>>statement to ${context.setVariable('maven.disable.tests','true')}
<br>>etc. with no luck.<br>><br>>Does anybody have any
suggestions?<br>><br>>Thanks<br>><br>>Mike<br>><br>><br>><br>><br>>I
finally worked out some Jelly code that I believe addresses your
<br>>requirements using m1.1b2:<br>><br>>1) my earlier remarks
about the artifact plugin's namespace can be <br>>ignored, it isn't
required<br>><br>>2) in your multiproject context, if you add the
preGoal logic to the <br>>top level maven.xml file it will be inherited
by the subprojects, so <br>>it is required only once<br>><br>>3)
the behavior varies based on the value of the Maven variable
<br>>maven.disable.tests, which you can set programatically as
needed<br>><br>>4) the echo statements were included to produce warm
fuzzies<br>><br>><preGoal name="test:test"><br>>
<j:choose><br>> <j:when
test="${context.getVariable('maven.disable.tests') ==
<br>>'true'}"><br>> <echo message="in test:test
preGoal maven.disable.tests == <br>>true"/><br>>
<maven:set plugin="maven-test-plugin"
<br>>property="maven.test.skip"<br>>
value="true"/><br>> </j:when><br>>
<j:otherwise><br>> <echo message="in test:test
preGoal maven.disable.tests != <br>>true"/><br>>
</j:otherwise><br>>
</j:choose><br>></preGoal><br>><br>>So your code could
be modified as follows:<br>><br>><goal
name="multi:all"><br>><br>> <!-- Only runs the
tests while building the site --><br>> <attainGoal
name="clean"/><br>><br>> <j:set
var="maven.disable.tests" value="true" /><br>>
<attainGoal name="multi:build" /><br>><br>>
<j:set var="maven.disable.tests" value="false"
/><br>><br>> <attainGoal name="multi:site"
/><br>><br>></goal><br>><br>><br>>---------------------------------------------------------------------<br>>To
unsubscribe, e-mail: users-unsubscribe@maven.apache.org<br>>For
additional commands, e-mail:
users-help@maven.apache.org<br>><br>><br>><br>>---------------------------------------------------------------------<br>>To
unsubscribe, e-mail: users-unsubscribe@maven.apache.org<br>>For
additional commands, e-mail:
users-help@maven.apache.org<br>><br></font></BLOCKQUOTE>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: [m1.1b2] maven.test.skip not working
Posted by Michael Owen <mi...@hotmail.com>.
Hi,
Many thanks for your help. It is very appreciated. However, tried the code
you suggest and it is still not working. Using the print statement:
<ant:echo>(1) maven.disable.tests =
${context.getVariable('maven.disable.tests')}</ant:echo>
in the code (which is in a common maven.xml file):
<preGoal name="test:test">
<j:choose>
<j:when test="${context.getVariable('maven.disable.tests') ==
'true'}">
<ant:echo>(1) maven.disable.tests =
${context.getVariable('maven.disable.tests')}</ant:echo>
<maven:set plugin="maven-test-plugin"
property="maven.test.skip" value="true" />
</j:when>
<j:otherwise>
<ant:echo>(2) maven.disable.tests =
${context.getVariable('maven.disable.tests')}</ant:echo>
</j:otherwise>
</j:choose>
</preGoal>
The varaiable maven.disable.tests appears to be empty when running the goal
multi:all, however, shouldn't be due to code in the buildsystem maven.xml,
where the goal is executed from:
<goal name="multi:all">
<!-- Only runs the tests while building the site -->
<attainGoal name="clean"/>
<j:set var="maven.disable.tests" value="true" />
<attainGoal name="multi:build" />
<j:set var="maven.disable.tests" value="false" />
<attainGoal name="multi:site" />
</goal>
Tried changing the <j:set var="maven.disable.tests" value="true" />
statement to ${context.setVariable('maven.disable.tests','true')} etc. with
no luck.
Does anybody have any suggestions?
Thanks
Mike
I finally worked out some Jelly code that I believe addresses your
requirements using m1.1b2:
1) my earlier remarks about the artifact plugin's namespace can be ignored,
it isn't required
2) in your multiproject context, if you add the preGoal logic to the top
level maven.xml file it will be inherited by the subprojects, so it is
required only once
3) the behavior varies based on the value of the Maven variable
maven.disable.tests, which you can set programatically as needed
4) the echo statements were included to produce warm fuzzies
<preGoal name="test:test">
<j:choose>
<j:when test="${context.getVariable('maven.disable.tests') == 'true'}">
<echo message="in test:test preGoal maven.disable.tests == true"/>
<maven:set plugin="maven-test-plugin" property="maven.test.skip"
value="true"/>
</j:when>
<j:otherwise>
<echo message="in test:test preGoal maven.disable.tests != true"/>
</j:otherwise>
</j:choose>
</preGoal>
So your code could be modified as follows:
<goal name="multi:all">
<!-- Only runs the tests while building the site -->
<attainGoal name="clean"/>
<j:set var="maven.disable.tests" value="true" />
<attainGoal name="multi:build" />
<j:set var="maven.disable.tests" value="false" />
<attainGoal name="multi:site" />
</goal>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: [m1.1b2] maven.test.skip not working
Posted by Andy Glick <an...@acm.org>.
I finally worked out some Jelly code that I believe addresses your requirements using m1.1b2:
1) my earlier remarks about the artifact plugin's namespace can be ignored, it isn't required
2) in your multiproject context, if you add the preGoal logic to the top level maven.xml file it will be inherited by the subprojects, so it is required only once
3) the behavior varies based on the value of the Maven variable maven.disable.tests, which you can set programatically as needed
4) the echo statements were included to produce warm fuzzies
<preGoal name="test:test">
<j:choose>
<j:when test="${context.getVariable('maven.disable.tests') == 'true'}">
<echo message="in test:test preGoal maven.disable.tests == true"/>
<maven:set plugin="maven-test-plugin" property="maven.test.skip"
value="true"/>
</j:when>
<j:otherwise>
<echo message="in test:test preGoal maven.disable.tests != true"/>
</j:otherwise>
</j:choose>
</preGoal>
So your code could be modified as follows:
<goal name="multi:all">
<!-- Only runs the tests while building the site -->
<attainGoal name="clean"/>
<j:set var="maven.disable.tests" value="true" />
<attainGoal name="multi:build" />
<j:set var="maven.disable.tests" value="false" />
<attainGoal name="multi:site" />
</goal>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: [m1.1b2] maven.test.skip not working
Posted by Michael Owen <mi...@hotmail.com>.
Thanks for you help, but after changing it to:
<goal name="multi:all">
<!-- Only runs the tests while building the site -->
<attainGoal name="clean"/>
<maven:set plugin="maven-test-plugin" property="maven.test.skip"
value="true"/>
<attainGoal name="multi:build" />
<maven:set plugin="maven-test-plugin" property="maven.test.skip"
value="false"/>
<attainGoal name="multi:site" />
</goal>
it still didn't work. Any more ideas? :)
Mike
>>Did you try something like
>>
>><maven:set plugin="maven-test-plugin" property="maven.test.skip"
>>value="true"/>
>>instead of
>><j:set var="trueValue" value="true" />
>>
>>${pom.getPluginContext('maven-test-plugin').setVariable('maven.test.skip
>>',trueValue)}
>>
>>or just :
>><j:set var="maven.test.skip" value="true"/>
>>
>>Arnaud
On 9/16/05, Michael Owen <mi...@hotmail.com> wrote:
>
>Hi,
>
>I'm using Maven 1.1 beta 2 and I've got a goal which does a multiproject
>build and creates a multiproject site. I would like the tests to only be
>run
>once when running this "multi:all" and therefore I've created the goal
>below:
>
><goal name="multi:all">
>
><!-- Only runs the tests while building the site -->
><attainGoal name="clean"/>
>
><j:set var="trueValue" value="true" />
>
>${pom.getPluginContext('maven-test-plugin').setVariable('maven.test.skip
>',trueValue)}
>
><attainGoal name="multi:build" />
>
><j:set var="falseValue" value="false" />
>
>${pom.getPluginContext('maven-test-plugin').setVariable('maven.test.skip
>',falseValue)}
>
><attainGoal name="multi:site" />
>
></goal>
>
>However, the tests are still being run for the multi:build goal (note this
>is just a custom multiproject build goal) because maven.test.skip is still
>false. Any ideas how I can get this working without putting on
>-Dmaven.test.skip=true on the command line or putting it in a properties
>file.
>
>Thanks in advance,
>
>Mike
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>For additional commands, e-mail: users-help@maven.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: [m1.1b2] maven.test.skip not working
Posted by Arnaud HERITIER <ah...@gmail.com>.
Did you try something like
<maven:set plugin="maven-test-plugin" property="maven.test.skip"
value="true"/>
instead of
<j:set var="trueValue" value="true" />
${pom.getPluginContext('maven-test-plugin').setVariable('maven.test.skip
',trueValue)}
or just :
<j:set var="maven.test.skip" value="true"/>
Arnaud
On 9/16/05, Michael Owen <mi...@hotmail.com> wrote:
>
> Hi,
>
> I'm using Maven 1.1 beta 2 and I've got a goal which does a multiproject
> build and creates a multiproject site. I would like the tests to only be
> run
> once when running this "multi:all" and therefore I've created the goal
> below:
>
> <goal name="multi:all">
>
> <!-- Only runs the tests while building the site -->
> <attainGoal name="clean"/>
>
> <j:set var="trueValue" value="true" />
>
> ${pom.getPluginContext('maven-test-plugin').setVariable('maven.test.skip
> ',trueValue)}
>
> <attainGoal name="multi:build" />
>
> <j:set var="falseValue" value="false" />
>
> ${pom.getPluginContext('maven-test-plugin').setVariable('maven.test.skip
> ',falseValue)}
>
> <attainGoal name="multi:site" />
>
> </goal>
>
> However, the tests are still being run for the multi:build goal (note this
> is just a custom multiproject build goal) because maven.test.skip is still
> false. Any ideas how I can get this working without putting on
> -Dmaven.test.skip=true on the command line or putting it in a properties
> file.
>
> Thanks in advance,
>
> Mike
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>