You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by jstrachan <ja...@gmail.com> on 2010/08/03 09:24:59 UTC

invoking surefire:test from an incremental compile Mojo

I've seen the "how do I call a Mojo from a Mojo" question asked a number of
times before on the list and the typical answer seems to be something like
"you don't", "you're doing it wrong" or "create your own lifecycle" etc. In
my case though I really do want to :)

Here's the use case; I'm trying to do this
http://github.com/davidB/maven-scala-plugin/issues#issue/35

basically SBT has an incremental test mode which detects if you change any
source files then it recompiles whatever is required and if the build
succeeds it can automatically run all the tests, test which match a
particular pattern or run just tests that failed last time.

This is an amazingly useful feature; I find myself using it a lot. 

The maven-scala-plugin already has a good incremental test goal (mvn
scala:cc) which watches source files and recompiles whatever needs to be
recompiled. I've added a hook so on a successful build we can do something
like run the tests.

However what I want to do is run the tests using the current pom.xml test
configuration (so folks don't have to configure surefire twice). So really I
just want maven to run "surefire:test" from inside the continuous compile
mojo - on demand whenever a continuous build is completed - rather than
explicitly depend on surefire and configure its mojo manually myself etc.

Whats the current best practice way to try do this from a Mojo? Using Maven
Embedder? 

Any help greatly appreciated!
-- 
View this message in context: http://maven.40175.n5.nabble.com/invoking-surefire-test-from-an-incremental-compile-Mojo-tp2262642p2262642.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: invoking surefire:test from an incremental compile Mojo

Posted by jstrachan <ja...@gmail.com>.
Thanks Stephen! Seems to work too! Yay!

On 3 August 2010 09:46, stephenconnolly [via Maven]
<ml...@n5.nabble.com> wrote:
> Use the maven-invoker component (which is also used by the
> maven-invoker-plugin so you can see examples of how to use it in that code
> base)
>
> On 3 August 2010 08:24, jstrachan <[hidden email]> wrote:
>
>>
>> I've seen the "how do I call a Mojo from a Mojo" question asked a number
>> of
>> times before on the list and the typical answer seems to be something like
>> "you don't", "you're doing it wrong" or "create your own lifecycle" etc.
>> In
>> my case though I really do want to :)
>>
>> Here's the use case; I'm trying to do this
>> http://github.com/davidB/maven-scala-plugin/issues#issue/35
>>
>> basically SBT has an incremental test mode which detects if you change any
>> source files then it recompiles whatever is required and if the build
>> succeeds it can automatically run all the tests, test which match a
>> particular pattern or run just tests that failed last time.
>>
>> This is an amazingly useful feature; I find myself using it a lot.
>>
>> The maven-scala-plugin already has a good incremental test goal (mvn
>> scala:cc) which watches source files and recompiles whatever needs to be
>> recompiled. I've added a hook so on a successful build we can do something
>> like run the tests.
>>
>> However what I want to do is run the tests using the current pom.xml test
>> configuration (so folks don't have to configure surefire twice). So really
>> I
>> just want maven to run "surefire:test" from inside the continuous compile
>> mojo - on demand whenever a continuous build is completed - rather than
>> explicitly depend on surefire and configure its mojo manually myself etc.
>>
>> Whats the current best practice way to try do this from a Mojo? Using
>> Maven
>> Embedder?
>>
>> Any help greatly appreciated!
>> --
>> View this message in context:
>>
>> http://maven.40175.n5.nabble.com/invoking-surefire-test-from-an-incremental-compile-Mojo-tp2262642p2262642.html
>> Sent from the Maven - Users mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
>
> ________________________________
> View message @
> http://maven.40175.n5.nabble.com/invoking-surefire-test-from-an-incremental-compile-Mojo-tp2262642p2262701.html
> To unsubscribe from invoking surefire:test from an incremental compile Mojo,
> click here.
>



-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

-- 
View this message in context: http://maven.40175.n5.nabble.com/invoking-surefire-test-from-an-incremental-compile-Mojo-tp2262642p2262732.html
Sent from the Maven - Users mailing list archive at Nabble.com.

Re: invoking surefire:test from an incremental compile Mojo

Posted by Stephen Connolly <st...@gmail.com>.
Use the maven-invoker component (which is also used by the
maven-invoker-plugin so you can see examples of how to use it in that code
base)

On 3 August 2010 08:24, jstrachan <ja...@gmail.com> wrote:

>
> I've seen the "how do I call a Mojo from a Mojo" question asked a number of
> times before on the list and the typical answer seems to be something like
> "you don't", "you're doing it wrong" or "create your own lifecycle" etc. In
> my case though I really do want to :)
>
> Here's the use case; I'm trying to do this
> http://github.com/davidB/maven-scala-plugin/issues#issue/35
>
> basically SBT has an incremental test mode which detects if you change any
> source files then it recompiles whatever is required and if the build
> succeeds it can automatically run all the tests, test which match a
> particular pattern or run just tests that failed last time.
>
> This is an amazingly useful feature; I find myself using it a lot.
>
> The maven-scala-plugin already has a good incremental test goal (mvn
> scala:cc) which watches source files and recompiles whatever needs to be
> recompiled. I've added a hook so on a successful build we can do something
> like run the tests.
>
> However what I want to do is run the tests using the current pom.xml test
> configuration (so folks don't have to configure surefire twice). So really
> I
> just want maven to run "surefire:test" from inside the continuous compile
> mojo - on demand whenever a continuous build is completed - rather than
> explicitly depend on surefire and configure its mojo manually myself etc.
>
> Whats the current best practice way to try do this from a Mojo? Using Maven
> Embedder?
>
> Any help greatly appreciated!
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/invoking-surefire-test-from-an-incremental-compile-Mojo-tp2262642p2262642.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>