You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Martin Desruisseaux <ma...@geomatys.com> on 2024/07/22 16:52:21 UTC

Way to skip tests when nothing has changed?

Hello again

This is a side-effect of the work on maven-compiler-plugin. The 
"incremental build" mechanism is reviewed as a side-effect, for fixing 
MCOMPILER-209 [1] among others. When the compiler has detected that no 
source file, no dependency and no compiler option has changed, is there 
away to notify other plugins (in particular maven-surefire-plugin) so 
that they can skip e.g. tests if configured to do so?

If there is no existing mechanism, could the 
org.apache.maven.api.plugin.Mojo interface be modified for returning an 
enumeration value instead of void? Maybe something like:

    public interface Mojo {
         enum Status {
             EXECUTED,

             UNCHANGED,

             SKIPPED
         }

         Status execute();
    }

Together with some API, maybe in Session, telling what the previous 
plugins returned? For example, Surefire could skip the tests if all 
previous plugins (in particular the compiler plugin) returned 
Status.UNCHANGED. This behavior would be optional, through some 
configuration option.

     Martin

[1]https://issues.apache.org/jira/browse/MCOMPILER-209

Re: Way to skip tests when nothing has changed?

Posted by Martin Desruisseaux <ma...@geomatys.com>.
Le 2024-07-23 à 01 h 21, Guillaume Nodet a écrit :
>
> FWIW, I started working on an API derived from the takari incremental 
> build. This is available at [1] with usage snippets available at [2]. 
> But the API is much more complex that just a status flag but it would 
> allow automatically skipping any plugin work for which the inputs have 
> not changed at all.
>
Thanks! If such API is targeted for Maven 4, then it is fine for me to 
just wait for it. There is plenty other work to do in the meantime.

     Martin



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


Re: Way to skip tests when nothing has changed?

Posted by Guillaume Nodet <gn...@apache.org>.
FWIW, I started working on an API derived from the takari incremental
build. This is available at [1] with usage snippets available at [2].
But the API is much more complex that just a status flag but it would
allow automatically skipping any plugin work for which the inputs have
not changed at all.

[1] https://github.com/apache/maven/pull/1118
[2] https://github.com/gnodet/maven/blob/build-context/maven-core/src/test/java/org/apache/maven/internal/build/impl/Snippets.java

Le lun. 22 juil. 2024 à 18:53, Martin Desruisseaux
<ma...@geomatys.com> a écrit :
>
> Hello again
>
> This is a side-effect of the work on maven-compiler-plugin. The
> "incremental build" mechanism is reviewed as a side-effect, for fixing
> MCOMPILER-209 [1] among others. When the compiler has detected that no
> source file, no dependency and no compiler option has changed, is there
> away to notify other plugins (in particular maven-surefire-plugin) so
> that they can skip e.g. tests if configured to do so?
>
> If there is no existing mechanism, could the
> org.apache.maven.api.plugin.Mojo interface be modified for returning an
> enumeration value instead of void? Maybe something like:
>
>     public interface Mojo {
>          enum Status {
>              EXECUTED,
>
>              UNCHANGED,
>
>              SKIPPED
>          }
>
>          Status execute();
>     }
>
> Together with some API, maybe in Session, telling what the previous
> plugins returned? For example, Surefire could skip the tests if all
> previous plugins (in particular the compiler plugin) returned
> Status.UNCHANGED. This behavior would be optional, through some
> configuration option.
>
>      Martin
>
> [1]https://issues.apache.org/jira/browse/MCOMPILER-209



-- 
------------------------
Guillaume Nodet

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


Re: Way to skip tests when nothing has changed?

Posted by Martin Desruisseaux <ma...@geomatys.com>.
Le 2024-07-22 à 21 h 14, Romain Manni-Bucau a écrit :
>
> you must not skip surefire is compiler execution is skipped. Surefire 
> has its own inputs and even if the overlap with compiler can be 
> important it is also far to be 1-1 (…snip…) surefire can have custom 
> paths, must consider the env, props etc...
>
Skipping the tests when nothing changed would be optional, controlled by 
Surefire plugin configuration. "Nothing to recompile" is one condition 
that Surefire is free to use or ignore or combine with other criteria. 
The issue is simply about making that information available outside the 
compiler plugin.

I have no strong opinion about return value versus a flag to set 
somewhere, as they both work. However, a flag is likely to be forgotten 
by a lot of plugins, while a return value forces each plugin to at least 
said if they did any work. An enumeration with 3 values may be simple 
enough for not being a burden.

     Martin


Re: Way to skip tests when nothing has changed?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
API could - theorically you can use a flag in the session already....but
you must not skip surefire is compiler execution is skipped.
Surefire has its own inputs and even if the overlap with compiler can be
important it is also far to be 1-1 so you skip surefire if nothing changed
for surefire not a random other plugin (surefire can have custom paths,
must consider the env, props etc...).
A shared "did this artifact/folder changed" tool with a shared hash per
execution can be a good way like in the build extension we have but no
shortcut please until you do a new surefire which does not support all
current use cases.

Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>


Le lun. 22 juil. 2024 à 18:53, Martin Desruisseaux <
martin.desruisseaux@geomatys.com> a écrit :

> Hello again
>
> This is a side-effect of the work on maven-compiler-plugin. The
> "incremental build" mechanism is reviewed as a side-effect, for fixing
> MCOMPILER-209 [1] among others. When the compiler has detected that no
> source file, no dependency and no compiler option has changed, is there
> away to notify other plugins (in particular maven-surefire-plugin) so
> that they can skip e.g. tests if configured to do so?
>
> If there is no existing mechanism, could the
> org.apache.maven.api.plugin.Mojo interface be modified for returning an
> enumeration value instead of void? Maybe something like:
>
>     public interface Mojo {
>          enum Status {
>              EXECUTED,
>
>              UNCHANGED,
>
>              SKIPPED
>          }
>
>          Status execute();
>     }
>
> Together with some API, maybe in Session, telling what the previous
> plugins returned? For example, Surefire could skip the tests if all
> previous plugins (in particular the compiler plugin) returned
> Status.UNCHANGED. This behavior would be optional, through some
> configuration option.
>
>      Martin
>
> [1]https://issues.apache.org/jira/browse/MCOMPILER-209
>