<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" 
  xmlns:content="http://purl.org/rss/1.0/modules/content/" 
  xmlns:dc="http://purl.org/dc/elements/1.1/" 
  xmlns:atom="http://www.w3.org/2005/Atom" 
  xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" 
  xmlns:media="http://search.yahoo.com/mrss/">
  <channel>
    <title>spock-2.0 on Solid Soft</title>
    <link>https://blog.solidsoft.pl/tags/spock-2.0/</link>
    <description>Recent content in spock-2.0 on Solid Soft</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <copyright>©{year}, All Rights Reserved</copyright>
    <lastBuildDate>Fri, 19 Nov 2021 00:10:00 +0200</lastBuildDate>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>2</sy:updateFrequency>
    
        <atom:link href="https://blog.solidsoft.pl/tags/spock-2.0/index.xml" rel="self" type="application/rss+xml" />
    
    
    

      
      <item>
        <title>Running Spock with unsupported Groovy version (Gradle &#43; Maven)</title>
        <link>https://blog.solidsoft.pl/2021/11/19/running-spock-with-unsupported-groovy-version-gradle-maven/</link>
        <pubDate>Fri, 19 Nov 2021 00:10:00 +0200</pubDate>
        
        <atom:modified>Wed, 02 Feb 2022 23:50:00 +0100</atom:modified>
        <guid>https://blog.solidsoft.pl/2021/11/19/running-spock-with-unsupported-groovy-version-gradle-maven/</guid>
        <description>Stuck with the &amp;lsquo;The Spock compiler plugin cannot execute because Spock 1.3-groovy-2.5 (3.0) is not compatible with Groovy 3.0 (4.0)&amp;rsquo; error message? Find out what can be done about that (using Gradle and Maven).
  Historical background In the dim and distance past, when Groovy 1.x occasionally had some unpleasant (also runtime) backward compatibility issues, Spock had started to be built for the particular Groovy version individually. There were spock-0.</description>
        <content:encoded>&lt;blockquote&gt;
&lt;p&gt;Stuck with the &amp;lsquo;The Spock compiler plugin cannot execute because Spock 1.3-groovy-2.5 (3.0) is not compatible with Groovy 3.0 (4.0)&amp;rsquo; error message? Find out what can be done about that (using Gradle and Maven).&lt;/p&gt;
&lt;/blockquote&gt;


&lt;figure &gt;
  
    &lt;img src=&#34;https://blog.solidsoft.pl/images/posts/2021/spock2-groovy4.jpg&#34;  style=&#34;width:;height:;&#34;/&gt;
  
  
&lt;/figure&gt;

&lt;h2 id=&#34;historical-background&#34;&gt;Historical background&lt;/h2&gt;
&lt;p&gt;In the dim and distance past, when Groovy 1.x occasionally had some unpleasant (also runtime) backward compatibility issues, Spock had started to be built for the particular Groovy version individually. There were &lt;code&gt;spock-0.5-groovy-1.6&lt;/code&gt;, &lt;code&gt;spock-0.5-groovy-1.7&lt;/code&gt; and &lt;code&gt;spock-0.5-groovy-1.8&lt;/code&gt; for instance. To help people choose the right Spock and the Groovy versions, the runtime check was added to fail the compilation (at the AST transformation level) with the meaningful error message, in the situation Spock was compiled with the different Groovy version that is available at runtime, e.g.:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;The Spock compiler plugin refused to run because Spock 1.3-groovy-2.5 is not compatible with Groovy 3.0.4. For more information,
see http://versioncheck.spockframework.org Spock location: .../spock-1.3-groovy-2.5.jar, Groovy location: .../groovy-3.0.4.jar
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The error message is very clear. The reasoning behind this decision is good, and definitely it can help developers to detect problems with the dependencies. However, it can also greatly complicate development, especially taking into account rather rarely released new Spock versions.&lt;/p&gt;
&lt;p&gt;If you are here, because of that error visible in your build, jump to the proper section to see what can be done about the problem.&lt;/p&gt;
&lt;h2 id=&#34;possible-options&#34;&gt;Possible options&lt;/h2&gt;
&lt;h3 id=&#34;spock-13-and-groovy-30&#34;&gt;Spock 1.3 and Groovy 3.0&lt;/h3&gt;
&lt;p&gt;Unfortunately, you are out of luck. If you stuck with Spock 1.3 (e.g. migration to Spock 2.0 is blocked for some reasons) there are two (mediocre) options:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Switch to &lt;code&gt;Spock 1.3-SNAPSHOT&lt;/code&gt;. The version compatibility check is relaxed in the SNAPSHOT builds of Spock 1.3. What&amp;rsquo;s more, there were multiple reports that (in the majority of cases - some corner cases remains) Spock &lt;code&gt;1.3-groovy-2.5-SNAPSHOT&lt;/code&gt; works fine with Groovy &lt;code&gt;3.0.x&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;There are no plans to release any new maintenance release of Spock 1.x. However, you can still &lt;a href=&#34;https://github.com/spockframework/spock/issues&#34; target=&#34;_blank&#34;&gt;create a new issue on GitHub&lt;/a&gt;
 and try to convince The Spock Developers to make 1.3.1 with that change :-).&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;spock-20-and-groovy-30&#34;&gt;Spock 2.0+ and Groovy 3.0&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;The Spock compiler plugin refused to run because Spock 2.0-groovy-2.5 is not compatible with Groovy 3.0.9.
For more information (including enforce mode), see http://docs.spockframework.org (section &#39;Known Issues&#39;). 
Spock location: .../spock-2.0-groovy-2.5.jar
Groovy location: .../groovy-3.0.9.jar
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;That a trivial case. Just change Spock version from 2.0-groovy-2.5 to 2.0-groovy-3.0, and you are set.&lt;/p&gt;
&lt;h3 id=&#34;spock-2021-and-groovy-40&#34;&gt;Spock 2.0/2.1 and Groovy 4.0&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;The Spock compiler plugin refused to run because Spock 2.0-groovy-3.0 is not compatible with Groovy 4.0.0-beta-2.
For more information (including enforce mode), see http://docs.spockframework.org (section &#39;Known Issues&#39;). 
Spock location: .../spock-2.0-groovy-3.0.jar
Groovy location: .../groovy-4.0.0-beta-2.jar
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This variant assumes that you use Groovy 4 (SNAPSHOT, beta or a regular version) and Spock 2.0-groovy-3.0 (or 2.1). The error message is even more precise than in Spock 1.3, suggesting the &lt;a href=&#34;http://spockframework.org/spock/docs/2.0-M3/known_issues.html#_groovy_version_compatibility&#34; target=&#34;_blank&#34;&gt;&amp;lsquo;Known Issues&amp;rsquo;&lt;/a&gt;
 section in the Spock documentation. We can leverage a brand-new system property &lt;code&gt;spock.iKnowWhatImDoing.disableGroovyVersionCheck&lt;/code&gt;, introduced right in Spock 2.0-M3, which allows to disable the version check - of course, at your own risk :-).&lt;/p&gt;
&lt;p&gt;Btw, if you in a hurry (e.g. just to test something), it is also possible just to switch Spock to SNAPSHOT version which accepts (almost) any Groovy version.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Btw2, if you prefer to just jump into code, there is a &lt;a href=&#34;https://github.com/szpak/code-examples-and-poc/tree/master/spock2-groovy4-gradle-maven&#34; target=&#34;_blank&#34;&gt;code repository&lt;/a&gt;
 with working examples for Gradle and Maven.&lt;/strong&gt;&lt;/p&gt;
&lt;h4 id=&#34;gradle&#34;&gt;Gradle&lt;/h4&gt;
&lt;div class=&#34;alert alert-warning&#34; role=&#34;alert&#34; data-dir=&#34;ltr&#34;&gt;&lt;p&gt;As Groovy 4 changed its &lt;code&gt;groupId&lt;/code&gt; from &lt;code&gt;org.codehaus.groovy&lt;/code&gt; to &lt;code&gt;org.apache.groovy&lt;/code&gt; it is required to &lt;strong&gt;add implicit exclusion for spock-2.0-groovy-3.0 transitive dependencies&lt;/strong&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;testImplementation(&amp;quot;org.spockframework:spock-core:2.0-groovy-3.0&amp;quot;) {
    exclude group: &#39;org.codehaus.groovy&#39;
}
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;to avoid conflicting Groovy versions on a classpath (it&amp;rsquo;s nice that Gradle is able to detect that!):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt; Task :compileTestGroovy FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task &#39;:compileTestGroovy&#39;.
&amp;gt; Could not resolve all files for configuration &#39;:testCompileClasspath&#39;.
   &amp;gt; Could not resolve org.apache.groovy:groovy:4.0.0-beta-2.
     Required by:
         project :
         project : &amp;gt; org.apache.groovy:groovy:4.0.0-beta-2 &amp;gt; org.apache.groovy:groovy-bom:4.0.0-beta-2
      &amp;gt; Module &#39;org.apache.groovy:groovy&#39; has been rejected:
           Cannot select module with conflict on capability &#39;org.codehaus.groovy:groovy:4.0.0-beta-2&#39; also provided by [org.codehaus.groovy:groovy:3.0.8(compile)]
   &amp;gt; Could not resolve org.codehaus.groovy:groovy:3.0.8.
     Required by:
         project : &amp;gt; org.spockframework:spock-core:2.0-groovy-3.0
      &amp;gt; Module &#39;org.codehaus.groovy:groovy&#39; has been rejected:
           Cannot select module with conflict on capability &#39;org.codehaus.groovy:groovy:3.0.8&#39; also provided by [org.apache.groovy:groovy:4.0.0-beta-2(groovyApiElements)]
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;It won&amp;rsquo;t be required for Spock 2.0-groovy-4.0, once available.&lt;/p&gt;
&lt;/div&gt;

&lt;div class=&#34;alert alert-info&#34; role=&#34;alert&#34; data-dir=&#34;ltr&#34;&gt;&lt;p&gt;&lt;strong&gt;To be able use Groovy 4, Gradle 6.7+ is &lt;a href=&#34;https://github.com/gradle/gradle/issues/13657&#34;&gt;required&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;With earlier Gradle version you might got some misleading errors about not resolvable dependency to &lt;code&gt;org.codehaus.groovy:groovy:4.0.0-beta-2&lt;/code&gt;, even though you configured &lt;code&gt;org.apache.groovy:groovy:4.0.0-beta-2&lt;/code&gt; with the correct, changed group id.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Execution failed for task &#39;:compileTestGroovy&#39;.
&amp;gt; Could not resolve all files for configuration &#39;:detachedConfiguration1&#39;.
   &amp;gt; Could not find org.codehaus.groovy:groovy:4.0.0-beta-2.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The obvious way to add system properties to the Gradle execution itself is:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;./gradlew check -Dspock.iKnowWhatImDoing.disableGroovyVersionCheck=true     //wrong way
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Unfortunately it doesn&amp;rsquo;t work:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt; Task :compileTestGroovy FAILED
startup failed:
Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at jar:file:/home/foobar/.m2/repository/org/spockframework/spock-core/2.0-groovy-3.0/spock-core-2.0-groovy-3.0.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation  because of exception org.spockframework.util.IncompatibleGroovyVersionException: The Spock compiler plugin cannot execute because Spock 2.0-groovy-3.0 is not compatible with Groovy 4.0.0-beta-2. For more information (including enforce mode), see http://docs.spockframework.org (section &#39;Known Issues&#39;).
Spock artifact: file:/home/foobar/.m2/repository/org/spockframework/spock-core/2.0-groovy-3.0/.../spock-core-2.0-groovy-3.0.jar
Groovy artifact: file:/home/foobar/.gradle/caches/modules-2/files-2.1/org.apache.groovy/groovy/4.0.0-beta-2/.../groovy-4.0.0-beta-2.jar

1 error


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task &#39;:compileTestGroovy&#39;.
&amp;gt; Compilation failed; see the compiler error output for details.
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;After some searching on the Internet, we can find out that tests in Gradle are (by default) executed in a separate JVM, to it is required to pass the aforementioned system property to the &lt;code&gt;test&lt;/code&gt; task:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-groovy&#34; data-lang=&#34;groovy&#34;&gt;&lt;span class=&#34;n&#34;&gt;test&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;n&#34;&gt;systemProperty&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;spock.iKnowWhatImDoing.disableGroovyVersionCheck&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;true&amp;#34;&lt;/span&gt;   &lt;span class=&#34;c1&#34;&gt;//doesn&amp;#39;t work
&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;However, it still fails:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt; Task :compileTestGroovy FAILED
startup failed:
Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at ...
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Hmm, maybe it would be better to refer the Gradle test task by type?&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-groovy&#34; data-lang=&#34;groovy&#34;&gt;&lt;span class=&#34;n&#34;&gt;tasks&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;withType&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Test&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;).&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;configureEach&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;n&#34;&gt;systemProperty&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;spock.iKnowWhatImDoing.disableGroovyVersionCheck&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;true&amp;#34;&lt;/span&gt;   &lt;span class=&#34;c1&#34;&gt;//doesn&amp;#39;t work either
&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;It fails with the same error message :-/. What is wrong?&lt;/p&gt;
&lt;p&gt;The key difference - quite easy to miss - is the fact the exception is thrown not during the test execution, but during the compilation phrase. Then, the main Spock AST transformation checks if it could be applied:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt; Task :compileTestGroovy FAILED   &amp;lt;--------- :compileTestGroovy not :test !
startup failed:
...
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;It is definitely less popular case, and I had a problem to find any sensible source of wisdom proposing a complete solution. One of the possible option (which I talk about deeper in the article about &lt;a href=&#34;https://blog.solidsoft.pl/2020/03/02/enable-java-14-preview-features-in-gradle-maven-and-idea/&#34;&gt;enabling preview features&lt;/a&gt;
 of the new Java versions) is &lt;code&gt;CompileOptions&lt;/code&gt; (e.g. &lt;code&gt;options.compilerArgs.add(&#39;--enable-preview&#39;)&lt;/code&gt; in the &lt;a href=&#34;https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/compile/GroovyCompile.html&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;GroovyCompile&lt;/code&gt;&lt;/a&gt;
 task. The second might be &lt;code&gt;GroovyCompileOptions&lt;/code&gt; also in &lt;code&gt;GroovyCompile&lt;/code&gt;. However, it does not bring expected result. After some digging, I was able to find out, that as the Groovy compilation is performed in the forked JVM and the right way to achieve the goal is:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-groovy&#34; data-lang=&#34;groovy&#34;&gt;&lt;span class=&#34;n&#34;&gt;tasks&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;withType&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;GroovyCompile&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;).&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;configureEach&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;n&#34;&gt;options&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;forkOptions&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;jvmArgs&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;-Dspock.iKnowWhatImDoing.disableGroovyVersionCheck=true&amp;#39;&lt;/span&gt;    &lt;span class=&#34;c1&#34;&gt;//it works! But be aware that &amp;#34;options&amp;#34; not &amp;#34;groovyOptions&amp;#34;!
&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;And it works as expected:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt; Task :compileTestGroovy
Executing Spock 2.0-groovy-3.0 with NOT compatible Groovy version 4.0.0-beta-2 due to set spock.iKnowWhatImDoing.disableGroovyVersionCheck system property set. This is unsupported and may result in weird runtime errors!

&amp;gt; Task :test
...
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;displaying a nice disclaimer :). Spock 2.0-groovy-3.0 is used together with Groovy 4.&lt;/p&gt;
&lt;p&gt;Btw, if you see just not very helpful error message:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at
jar:file:/.../spock-core-.../org.codehaus.groovy.transform.ASTTransformation
because of exception java.lang.reflect.InvocationTargetException
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;it is caused by &lt;a href=&#34;https://issues.apache.org/jira/browse/GROOVY-9469&#34; target=&#34;_blank&#34;&gt;GROOVY-9469&lt;/a&gt;
 which affects Groovy 3 and was fixed in 3.0.3. Upgrade Groovy to see more verbose error message.&lt;/p&gt;
&lt;h4 id=&#34;maven&#34;&gt;Maven&lt;/h4&gt;
&lt;div class=&#34;alert alert-warning&#34; role=&#34;alert&#34; data-dir=&#34;ltr&#34;&gt;&lt;p&gt;As Groovy 4 changed its &lt;code&gt;groupId&lt;/code&gt; from &lt;code&gt;org.codehaus.groovy&lt;/code&gt; to &lt;code&gt;org.apache.groovy&lt;/code&gt; it is required to &lt;strong&gt;add implicit exclusion for spock-2.0-groovy-3.0 transitive dependencies&lt;/strong&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;dependencies&amp;gt;
    &amp;lt;dependency&amp;gt;
        &amp;lt;groupId&amp;gt;org.spockframework&amp;lt;/groupId&amp;gt;
        &amp;lt;artifactId&amp;gt;spock-core&amp;lt;/artifactId&amp;gt;
        &amp;lt;version&amp;gt;${spock.version}&amp;lt;/version&amp;gt;
        &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
        &amp;lt;exclusions&amp;gt;
            &amp;lt;!-- to do not have conflicting Groovy versions - Groovy 4 changed groupId from &amp;quot;org.codehaus.groovy&amp;quot; to &amp;quot;org.apache.groovy&amp;quot; --&amp;gt;
            &amp;lt;exclusion&amp;gt;
                &amp;lt;groupId&amp;gt;org.codehaus.groovy&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;*&amp;lt;/artifactId&amp;gt;
            &amp;lt;/exclusion&amp;gt;
        &amp;lt;/exclusions&amp;gt;
    &amp;lt;/dependency&amp;gt;
    &amp;lt;dependency&amp;gt;
        &amp;lt;groupId&amp;gt;org.apache.groovy&amp;lt;/groupId&amp;gt;
        &amp;lt;artifactId&amp;gt;groovy&amp;lt;/artifactId&amp;gt;
        &amp;lt;version&amp;gt;4.0.0-beta-2&amp;lt;/version&amp;gt;
    &amp;lt;/dependency&amp;gt;
&amp;lt;/dependencies&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;to have your tests executed with Groovy 4 instead of (silently) with Groovy 3, taken from a transitive dependency of Spock 2.0-groovy-3.0!&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[INFO] --- gmavenplus-plugin:1.13.0:compileTests (default) @ spock2-groovy4-maven ---
[INFO] Using isolated classloader, without GMavenPlus classpath.
[INFO] Using Groovy 3.0.8 to perform compileTests.     &amp;lt;---- Without exclusion, it is executed &amp;quot;silently&amp;quot; with old Groovy! 
[INFO] Parallel parsing disabled.
[INFO] Compiled 1 file.
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;It won&amp;rsquo;t be required for Spock 2.0-groovy-4.0, once available.&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;Writing my Spock, Groovy and modern Java related tutorials, I try to cover also the Maven users, which still is quite popular build tool :-). Usually, it takes much more (XML) lines to achieve the same in Maven in comparison to Gradle, however, sometimes it just works flawlessly without any additional effort. Unfortunately, it was not the case this time.&lt;/p&gt;
&lt;p&gt;The build with Spock-2.0-groovy-3.0 and Groovy 4.0.0 by default fails with:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[ERROR] Failed to execute goal org.codehaus.gmavenplus:gmavenplus-plugin:1.8.1:compileTests (default) on project spock2-migration-maven: Error occurred while calling a method on a Groovy class from classpath. InvocationTargetException: startup failed:
[ERROR] Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at jar:file:/home/foobar/.m2/repository/org/spockframework/spock-core/2.0-groovy-3.0/spock-core-2.0-groovy-3.0.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation  because of exception org.spockframework.util.IncompatibleGroovyVersionException: The Spock compiler plugin cannot execute because Spock 2.0-groovy-3.0 is not compatible with Groovy 4.0.0-beta-2. For more information (including enforce mode), see http://docs.spockframework.org (section &#39;Known Issues&#39;).
[ERROR] Spock artifact: file:/home/foobar/.m2/repository/org/spockframework/spock-core/2.0-groovy-3.0/spock-core-2.0-groovy-3.0.jar
[ERROR] Groovy artifact: file:/home/foobar/.m2/repository/org/apache/groovy/groovy/4.0.0-beta-2/groovy-4.0.0-beta-2.jar
[ERROR] 
[ERROR] 1 error
[ERROR] -&amp;gt; [Help 1]
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To make the long story short, I started with the plain Maven properties:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;8
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-xml&#34; data-lang=&#34;xml&#34;&gt;&lt;span class=&#34;nt&#34;&gt;&amp;lt;project&amp;gt;&lt;/span&gt;
...
  &lt;span class=&#34;nt&#34;&gt;&amp;lt;properties&amp;gt;&lt;/span&gt;
     &lt;span class=&#34;c&#34;&gt;&amp;lt;!-- doesn&amp;#39;t work --&amp;gt;&lt;/span&gt;
     &lt;span class=&#34;nt&#34;&gt;&amp;lt;spock.iKnowWhatImDoing.disableGroovyVersionCheck&amp;gt;&lt;/span&gt;true&lt;span class=&#34;nt&#34;&gt;&amp;lt;/spock.iKnowWhatImDoing.disableGroovyVersionCheck&amp;gt;&lt;/span&gt;
  &lt;span class=&#34;nt&#34;&gt;&amp;lt;/properties&amp;gt;&lt;/span&gt;
...
&lt;span class=&#34;nt&#34;&gt;&amp;lt;/project&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;It fails. Next, I added the following to the compiler parameters:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;12
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;13
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;14
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;15
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;16
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;17
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;18
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;19
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-xml&#34; data-lang=&#34;xml&#34;&gt;    &lt;span class=&#34;c&#34;&gt;&amp;lt;!-- ... --&amp;gt;&lt;/span&gt;
    &lt;span class=&#34;nt&#34;&gt;&amp;lt;build&amp;gt;&lt;/span&gt;
        &lt;span class=&#34;nt&#34;&gt;&amp;lt;plugins&amp;gt;&lt;/span&gt;
            &lt;span class=&#34;nt&#34;&gt;&amp;lt;plugin&amp;gt;&lt;/span&gt;
                &lt;span class=&#34;nt&#34;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.apache.maven.plugins&lt;span class=&#34;nt&#34;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
                &lt;span class=&#34;nt&#34;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;maven-compiler-plugin&lt;span class=&#34;nt&#34;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
                &lt;span class=&#34;nt&#34;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;3.8.1&lt;span class=&#34;nt&#34;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
                &lt;span class=&#34;nt&#34;&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;
                    &lt;span class=&#34;c&#34;&gt;&amp;lt;!-- doesn&amp;#39;t work --&amp;gt;&lt;/span&gt;
                    &lt;span class=&#34;nt&#34;&gt;&amp;lt;compilerArgs&amp;gt;&lt;/span&gt;
                        &lt;span class=&#34;nt&#34;&gt;&amp;lt;arg&amp;gt;&lt;/span&gt;-v&lt;span class=&#34;nt&#34;&gt;&amp;lt;/arg&amp;gt;&lt;/span&gt;
                        &lt;span class=&#34;nt&#34;&gt;&amp;lt;arg&amp;gt;&lt;/span&gt;-Dspock.iKnowWhatImDoing.disableGroovyVersionCheck=true&lt;span class=&#34;nt&#34;&gt;&amp;lt;/arg&amp;gt;&lt;/span&gt;
                    &lt;span class=&#34;nt&#34;&gt;&amp;lt;/compilerArgs&amp;gt;&lt;/span&gt;
                &lt;span class=&#34;nt&#34;&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;
            &lt;span class=&#34;nt&#34;&gt;&amp;lt;/plugin&amp;gt;&lt;/span&gt;
            &lt;span class=&#34;c&#34;&gt;&amp;lt;!-- ... --&amp;gt;&lt;/span&gt;
        &lt;span class=&#34;nt&#34;&gt;&amp;lt;/plugins&amp;gt;&lt;/span&gt;
    &lt;span class=&#34;nt&#34;&gt;&amp;lt;/build&amp;gt;&lt;/span&gt;
    &lt;span class=&#34;c&#34;&gt;&amp;lt;!-- ... --&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;however, it doesn&amp;rsquo;t affect Groovy compilation itself. I even took a look at the &lt;code&gt;gmavenplus&lt;/code&gt; plugin parameters and Groovy&amp;rsquo;s &lt;a href=&#34;https://docs.groovy-lang.org/latest/html/api/org/codehaus/groovy/control/CompilerConfiguration.html&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;CompilerConfiguration&lt;/code&gt;&lt;/a&gt;
, but without any effect. In the end, I was able to achieve that with another plugin &lt;code&gt;properties-maven&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;12
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;13
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;14
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;15
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;16
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;17
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;18
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;19
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;20
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;21
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-xml&#34; data-lang=&#34;xml&#34;&gt;    &lt;span class=&#34;nt&#34;&gt;&amp;lt;plugin&amp;gt;&lt;/span&gt;
        &lt;span class=&#34;nt&#34;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.codehaus.mojo&lt;span class=&#34;nt&#34;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
        &lt;span class=&#34;nt&#34;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;properties-maven-plugin&lt;span class=&#34;nt&#34;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
        &lt;span class=&#34;nt&#34;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;1.0.0&lt;span class=&#34;nt&#34;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
        &lt;span class=&#34;nt&#34;&gt;&amp;lt;executions&amp;gt;&lt;/span&gt;
            &lt;span class=&#34;nt&#34;&gt;&amp;lt;execution&amp;gt;&lt;/span&gt;
                &lt;span class=&#34;nt&#34;&gt;&amp;lt;goals&amp;gt;&lt;/span&gt;
                    &lt;span class=&#34;nt&#34;&gt;&amp;lt;goal&amp;gt;&lt;/span&gt;set-system-properties&lt;span class=&#34;nt&#34;&gt;&amp;lt;/goal&amp;gt;&lt;/span&gt;
                &lt;span class=&#34;nt&#34;&gt;&amp;lt;/goals&amp;gt;&lt;/span&gt;
                &lt;span class=&#34;nt&#34;&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;
                    &lt;span class=&#34;nt&#34;&gt;&amp;lt;properties&amp;gt;&lt;/span&gt;
                        &lt;span class=&#34;c&#34;&gt;&amp;lt;!-- works fine --&amp;gt;&lt;/span&gt;
                        &lt;span class=&#34;nt&#34;&gt;&amp;lt;property&amp;gt;&lt;/span&gt;
                            &lt;span class=&#34;nt&#34;&gt;&amp;lt;name&amp;gt;&lt;/span&gt;spock.iKnowWhatImDoing.disableGroovyVersionCheck&lt;span class=&#34;nt&#34;&gt;&amp;lt;/name&amp;gt;&lt;/span&gt;
                            &lt;span class=&#34;nt&#34;&gt;&amp;lt;value&amp;gt;&lt;/span&gt;true&lt;span class=&#34;nt&#34;&gt;&amp;lt;/value&amp;gt;&lt;/span&gt;
                        &lt;span class=&#34;nt&#34;&gt;&amp;lt;/property&amp;gt;&lt;/span&gt;
                    &lt;span class=&#34;nt&#34;&gt;&amp;lt;/properties&amp;gt;&lt;/span&gt;
                &lt;span class=&#34;nt&#34;&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;
            &lt;span class=&#34;nt&#34;&gt;&amp;lt;/execution&amp;gt;&lt;/span&gt;
        &lt;span class=&#34;nt&#34;&gt;&amp;lt;/executions&amp;gt;&lt;/span&gt;
    &lt;span class=&#34;nt&#34;&gt;&amp;lt;/plugin&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;resulting in:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[INFO] --- gmavenplus-plugin:1.8.1:compileTests (default) @ spock2-migration-maven ---
[INFO] Using isolated classloader, without GMavenPlus classpath.
[INFO] Using Groovy 4.0.0-beta-2 to perform compileTests.
Executing Spock 2.0-groovy-3.0 with NOT compatible Groovy version 4.0.0-beta-2 due to set spock.iKnowWhatImDoing.disableGroovyVersionCheck system property set. This is unsupported and may result in weird runtime errors!
[INFO] Compiled 10 files.
[INFO] 
[INFO] --- maven-surefire-plugin:3.0.0-M4:test (default-test) @ spock2-migration-maven ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
...
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;It turned out to be quite easy (if you know what to use :-) ), but - unless I missed something - it is somehow not much covered in the existing tutorials or documentation.&lt;/p&gt;
&lt;h3 id=&#34;potential-issue-in-intellij-idea&#34;&gt;Potential issue in IntelliJ IDEA&lt;/h3&gt;
&lt;p&gt;Even though, having your up-and-running Maven project configured as above, you might still encounter the incompatibility error after importing it in Idea:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Groovyc: While compiling [tests of spock2-groovy4-gradle.test]: Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at jar:file:/home/&amp;hellip;/spock-core-2.0-groovy-3.0.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation because of exception java.lang.NullPointerException: Cannot invoke &amp;ldquo;java.net.URL.toString()&amp;rdquo; because the return value of &amp;ldquo;java.security.CodeSource.getLocation()&amp;rdquo; is null&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;del&gt;The problem is caused by a limitation of Idea (&lt;a href=&#34;https://youtrack.jetbrains.com/issue/IDEA-287642&#34; target=&#34;_blank&#34;&gt;IDEA-287642&lt;/a&gt;
), which does not allow providing custom system properties for groovyc compilation (just for javac). You might want to vote for that issue.&lt;/del&gt; In fact, as &lt;a href=&#34;https://youtrack.jetbrains.com/issue/IDEA-287642#focus=Comments-27-5733123.0-0&#34; target=&#34;_blank&#34;&gt;Paul King&lt;/a&gt;
 pointed out, there is a way to set that property for all the compilers used in the project with &lt;code&gt;Settings → Compiler → Shared build process VM options&lt;/code&gt;. In the context of Spock, it should be enough.&lt;/p&gt;
&lt;p&gt;The error itself is not very meaningful (&lt;code&gt;NullPointerException&lt;/code&gt;) which in turn is caused by an unexpected behavior of Idea, reported as &lt;a href=&#34;https://youtrack.jetbrains.com/issue/IDEA-287643&#34; target=&#34;_blank&#34;&gt;IDEA-287643&lt;/a&gt;
.&lt;/p&gt;
&lt;p&gt;It is worth to mention, the same problem might occur also with Gradle, once &amp;ldquo;Build and run&amp;rdquo; is manually set to &amp;ldquo;Idea&amp;rdquo; (instead of &amp;ldquo;Gradle&amp;rdquo; - default behavior, but not the fastest one).&lt;/p&gt;
&lt;h2 id=&#34;summary&#34;&gt;Summary&lt;/h2&gt;
&lt;p&gt;The main reason, I implemented that feature in Spock was development of Groovy 4. I didn&amp;rsquo;t feel comfortable seeing The Groovy Team to be forced to use the Spock snapshot version in the master (Groovy 4.x) builds. With Spock-2.0-M3 it was &lt;a href=&#34;https://github.com/apache/groovy/pull/1281&#34; target=&#34;_blank&#34;&gt;simplified&lt;/a&gt;
. The same construction can be used in your project while playing with Groovy 4 (in beta as of XI 2021), in the way I precised for Gradle and Maven (which in turn can be really confusing on their own way which motivated me to write this short post :-) ). There is &lt;a href=&#34;https://github.com/spockframework/spock/issues/1374#issuecomment-932374972&#34; target=&#34;_blank&#34;&gt;a plan&lt;/a&gt;
 to add the official support for Groovy 4 in Spock, once it is closer to Groovy 4.0.0-final.&lt;/p&gt;
&lt;p&gt;Btw, there is a &lt;a href=&#34;https://github.com/szpak/code-examples-and-poc/tree/master/spock2-groovy4-gradle-maven&#34; target=&#34;_blank&#34;&gt;code repository&lt;/a&gt;
 with working examples for Gradle and Maven.&lt;/p&gt;
&lt;p&gt;P.S. If you bumped into that topic during Spock 1.3 -&amp;gt; 2.0 migration, there is a dedicated &lt;a href=&#34;https://blog.solidsoft.pl/2020/01/02/migrating-spock-1.3-tests-to-spock-2.0/&#34;&gt;migration guide article&lt;/a&gt;
.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Updated 2021-01-31&lt;/strong&gt;. Added section about potential issue with IntelliJ IDEA.&lt;br /&gt;
&lt;strong&gt;Updated 2021-02-02&lt;/strong&gt;. Add workaround suggested by &lt;a href=&#34;https://twitter.com/paulk_asert&#34; target=&#34;_blank&#34;&gt;Paul King&lt;/a&gt;
 about the potential issue with IntelliJ IDEA.&lt;/p&gt;
&lt;span style=&#34;opacity: 0.6&#34;&gt;Lead photo by &lt;a href=&#34;https://pixabay.com/users/geralt-9301/&#34;&gt;geralt&lt;/a&gt;, published in &lt;a href=&#34;https://pixabay.com/illustrations/place-name-sign-plan-success-749613/&#34;&gt;Pixabay&lt;/a&gt;, Pixabay License.&lt;/span&gt;
</content:encoded>
        <dc:creator>Marcin Zajączkowski</dc:creator>
        <media:content url="https://blog.solidsoft.pl/images/posts/2021/spock2-groovy4-thumbnail.jpg" medium="image"><media:title type="html">featured image</media:title></media:content>
        
        <media:content url="https://blog.solidsoft.pl/images/posts/2021/spock2-groovy4-ratio.jpg" medium="image"><media:title type="html">meta image</media:title></media:content>
        
          
            
              <category>spock</category>
            
          
            
              <category>spock2</category>
            
          
            
              <category>spock-2.0</category>
            
          
            
              <category>testing</category>
            
          
            
              <category>groovy</category>
            
          
            
              <category>groovy4</category>
            
          
            
              <category>gradle</category>
            
          
            
              <category>maven</category>
            
          
        
        
          
            
              <category>Tools</category>
            
          
        
        
      </item>
      
      <item>
        <title>What happened to Groovy dependencies in Spock 2.0?</title>
        <link>https://blog.solidsoft.pl/2020/06/16/what-happened-to-groovy-dependencies-in-spock-2.0/</link>
        <pubDate>Tue, 16 Jun 2020 10:00:00 +0200</pubDate>
        
        <atom:modified>Tue, 16 Jun 2020 10:00:00 +0200</atom:modified>
        <guid>https://blog.solidsoft.pl/2020/06/16/what-happened-to-groovy-dependencies-in-spock-2.0/</guid>
        <description>Spock 2.0(-M3) reduced number of provided Groovy dependencies. If you started to get various Groovy-related ClassNotFoundExceptions after migration and wonder why and what to do, read on.
  Historical background Originally Groovy was just one jar to rule them all. However, in process of time, that jar became bigger and bigger. Groovy 2 was the first version promoting the usage of (several at that time) Groovy modules, as a supplemental to groovy.</description>
        <content:encoded>&lt;blockquote&gt;
&lt;p&gt;Spock 2.0(-M3) reduced number of provided Groovy dependencies. If you started to get various Groovy-related &lt;code&gt;ClassNotFoundException&lt;/code&gt;s after migration and wonder why and what to do, read on.&lt;/p&gt;
&lt;/blockquote&gt;


&lt;figure &gt;
  
    &lt;img src=&#34;https://blog.solidsoft.pl/images/posts/2020/spock-groovy-dependencies.jpg&#34;  style=&#34;width:;height:;&#34;/&gt;
  
  
&lt;/figure&gt;

&lt;h2 id=&#34;historical-background&#34;&gt;Historical background&lt;/h2&gt;
&lt;p&gt;Originally Groovy was just one &lt;code&gt;jar&lt;/code&gt; to rule them all. However, in process of time, that jar became bigger and bigger. Groovy 2 was the first version promoting the usage of (several at that time) Groovy modules, as a supplemental to &lt;code&gt;groovy.jar&lt;/code&gt;. However the adoption of that approach was slowly and &lt;code&gt;groovy-all&lt;/code&gt; remained prevalent in &lt;code&gt;pom.xml&lt;/code&gt; and &lt;code&gt;build.gradle&lt;/code&gt; files.&lt;/p&gt;
&lt;p&gt;What even worse, having some projects use &lt;code&gt;groovy.jar&lt;/code&gt; plus some modules (e.g. &lt;code&gt;groovy-json.jar&lt;/code&gt; or &lt;code&gt;groovy-xml.jar&lt;/code&gt;) while some other preferring good old &lt;code&gt;groovy-all.jar&lt;/code&gt; could lead to version clashes as for Maven or Gradle those were independent packages. To avoid that it was quite common to see the defensive Groovy exclusions:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;12
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;13
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;14
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;15
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;16
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;17
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;18
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-xml&#34; data-lang=&#34;xml&#34;&gt;&lt;span class=&#34;nt&#34;&gt;&amp;lt;dependencies&amp;gt;&lt;/span&gt;
    &lt;span class=&#34;nt&#34;&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
        &lt;span class=&#34;nt&#34;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.codehaus.gmaven.runtime&lt;span class=&#34;nt&#34;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
        &lt;span class=&#34;nt&#34;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;YYY&lt;span class=&#34;nt&#34;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
        &lt;span class=&#34;nt&#34;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;1.2&lt;span class=&#34;nt&#34;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
        &lt;span class=&#34;nt&#34;&gt;&amp;lt;exclusions&amp;gt;&lt;/span&gt;
            &lt;span class=&#34;nt&#34;&gt;&amp;lt;exclusion&amp;gt;&lt;/span&gt;
                &lt;span class=&#34;nt&#34;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.codehaus.groovy&lt;span class=&#34;nt&#34;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
                &lt;span class=&#34;nt&#34;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;*&lt;span class=&#34;nt&#34;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
            &lt;span class=&#34;nt&#34;&gt;&amp;lt;/exclusion&amp;gt;&lt;/span&gt;
        &lt;span class=&#34;nt&#34;&gt;&amp;lt;/exclusions&amp;gt;&lt;/span&gt;
    &lt;span class=&#34;nt&#34;&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;
    &lt;span class=&#34;nt&#34;&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
        &lt;span class=&#34;nt&#34;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.codehaus.groovy&lt;span class=&#34;nt&#34;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
        &lt;span class=&#34;nt&#34;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;groovy-all&lt;span class=&#34;nt&#34;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
        &lt;span class=&#34;nt&#34;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;${groovy.version}&lt;span class=&#34;nt&#34;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
    &lt;span class=&#34;nt&#34;&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;
&lt;span class=&#34;nt&#34;&gt;&amp;lt;/dependencies&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;and declare all required Groovy dependencies on their own.&lt;/p&gt;
&lt;p&gt;Groovy 2.5 switched to the model of Maven&amp;rsquo;s BOM (Bill Of Materials) where &lt;code&gt;groovy-all&lt;/code&gt; isn&amp;rsquo;t a binary jar itself, but rather has the official Groovy modules as dependencies. Thanks to that, Maven and Gradle have easier to keep the versioning of the particular modules consistent. This holds for Groovy 3 which still provides the &lt;code&gt;groovy-all&lt;/code&gt; BOM.&lt;/p&gt;
&lt;h2 id=&#34;groovy-dependencies-in-spock-13&#34;&gt;Groovy dependencies in Spock 1.3&lt;/h2&gt;
&lt;p&gt;Spock 1.2 switched from &lt;code&gt;groovy-all.jar&lt;/code&gt; to &lt;code&gt;groovy.jar&lt;/code&gt; + modules. Unfortunately due to historical reasons it was a lot of modules:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;testRuntimeClasspath - Runtime classpath of source set &#39;test&#39;.
+--- org.spockframework:spock-core:2.0-M2-groovy-3.0
|    +--- org.codehaus.groovy:groovy:3.0.0
|    +--- org.codehaus.groovy:groovy-json:3.0.0
|    |    \--- org.codehaus.groovy:groovy:3.0.0
|    +--- org.codehaus.groovy:groovy-nio:3.0.0
|    |    \--- org.codehaus.groovy:groovy:3.0.0
|    +--- org.codehaus.groovy:groovy-macro:3.0.0
|    |    \--- org.codehaus.groovy:groovy:3.0.0
|    +--- org.codehaus.groovy:groovy-templates:3.0.0
|    |    +--- org.codehaus.groovy:groovy-xml:3.0.0
|    |    |    \--- org.codehaus.groovy:groovy:3.0.0
|    |    \--- org.codehaus.groovy:groovy:3.0.0
|    +--- org.codehaus.groovy:groovy-test:3.0.0
|    |    \--- org.codehaus.groovy:groovy:3.0.0
|    +--- org.codehaus.groovy:groovy-sql:3.0.0
|    |    \--- org.codehaus.groovy:groovy:3.0.0
|    +--- org.codehaus.groovy:groovy-xml:3.0.0 (*)
|    \--- org.junit.platform:junit-platform-engine:1.5.2
|         ...
...
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;As a result the following was quite common:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;6
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-groovy&#34; data-lang=&#34;groovy&#34;&gt;&lt;span class=&#34;n&#34;&gt;test&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;org.spockframework:spock-core:1.3-groovy-2.5&amp;#39;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;n&#34;&gt;exclude&lt;/span&gt; &lt;span class=&#34;nl&#34;&gt;group:&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;org.codehaus.groovy&amp;#39;&lt;/span&gt;    &lt;span class=&#34;c1&#34;&gt;//get rid of all dependant groovy modules
&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;span class=&#34;n&#34;&gt;test&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;org.codehaus.groovy:groovy:2.5.11&amp;#39;&lt;/span&gt;    &lt;span class=&#34;c1&#34;&gt;//apply only those needed
&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;test&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;org.codehaus.groovy:groovy-json:2.5.11&amp;#39;&lt;/span&gt;
&lt;span class=&#34;n&#34;&gt;test&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;org.codehaus.groovy:groovy-templates:2.5.11&amp;#39;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;However, it turned out that in fact all those extra modules are not needed internally for &lt;code&gt;spock-core&lt;/code&gt; and they were rather provided as a convenience for end users.&lt;/p&gt;
&lt;h2 id=&#34;groovy-dependencies-in-spock-20&#34;&gt;Groovy dependencies in Spock 2.0+&lt;/h2&gt;
&lt;p&gt;Starting with Spock 2.0-M3 the Groovy dependencies were &lt;a href=&#34;https://github.com/spockframework/spock/pull/1109&#34; target=&#34;_blank&#34;&gt;simplified&lt;/a&gt;
 to just &lt;code&gt;groovy.jar&lt;/code&gt;. Thanks to that you safe some bandwidth on the initial build (what is well-timed ;-) ) and the CI builds without proper caching take slightly shorter.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;testCompileClasspath - Compile classpath for source set &#39;test&#39;.
+--- org.spockframework:spock-core:2.0-M3-groovy-3.0
|    +--- org.codehaus.groovy:groovy:3.0.4
|    +--- org.junit.platform:junit-platform-engine:1.7.1-M1
|         ...
...
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;As a downside, after the migration to Spock-2.0-M3+, in rare cases you might get &lt;code&gt;ClassNotFoundException: groovy.sql.Sql&lt;/code&gt;, &lt;code&gt;ClassNotFoundException: groovy.json.JsonSlurper&lt;/code&gt; or &lt;code&gt;ClassNotFoundException: groovy.util.XmlParser&lt;/code&gt;. That error suggest that you use those classes somewhere in your tests, but the corresponding dependency is not declared implicitly in your build configuration (and it&amp;rsquo;s not accidentally provided by &lt;code&gt;spock-core&lt;/code&gt; any longer). The quick fix is to add &lt;code&gt;org.codehaus.groovy:groovy-sql:3.0.X&lt;/code&gt;, &lt;code&gt;org.codehaus.groovy:groovy-json:3.0.X&lt;/code&gt; or similar explicitly.&lt;/p&gt;
&lt;p&gt;P.S. If you bumped into that topic during Spock 1.3 -&amp;gt; 2.0 migration, there is a dedicated &lt;a href=&#34;https://blog.solidsoft.pl/2020/01/02/migrating-spock-1.3-tests-to-spock-2.0/&#34;&gt;migration guide article&lt;/a&gt;
.&lt;/p&gt;
&lt;span style=&#34;opacity: 0.6&#34;&gt;Lead photo by &lt;a href=&#34;https://pixabay.com/users/tumisu-148124/&#34;&gt;Tumisu&lt;/a&gt;, published in &lt;a href=&#34;https://pixabay.com/photos/magnifying-glass-detective-looking-4340698/&#34;&gt;Pixabay&lt;/a&gt;, Pixabay License.&lt;/span&gt;
</content:encoded>
        <dc:creator>Marcin Zajączkowski</dc:creator>
        <media:content url="https://blog.solidsoft.pl/images/posts/2020/spock-groovy-dependencies-thumbnail.jpg" medium="image"><media:title type="html">featured image</media:title></media:content>
        
        <media:content url="https://blog.solidsoft.pl/images/posts/2020/spock-groovy-dependencies-ratio.jpg" medium="image"><media:title type="html">meta image</media:title></media:content>
        
          
            
              <category>spock</category>
            
          
            
              <category>spock2</category>
            
          
            
              <category>spock-2.0</category>
            
          
            
              <category>testing</category>
            
          
            
              <category>groovy</category>
            
          
        
        
          
            
              <category>Tools</category>
            
          
        
        
      </item>
      
      <item>
        <title>Migrating Spock 1.3 tests to Spock 2.0</title>
        <link>https://blog.solidsoft.pl/2020/01/02/migrating-spock-1.3-tests-to-spock-2.0/</link>
        <pubDate>Thu, 02 Jan 2020 10:00:00 +0200</pubDate>
        
        <atom:modified>Wed, 11 Mar 2020 22:21:00 +0200</atom:modified>
        <guid>https://blog.solidsoft.pl/2020/01/02/migrating-spock-1.3-tests-to-spock-2.0/</guid>
        <description>Get know what you can expect from Spock 2.0 M2 (based on JUnit 5), how to migrate to it in Gradle and Maven, and why it is important to report spotted problems :).
 Important note. I definitely do not encourage you to migrate your serious real-life project to Spock 2.0 M1 or M2 for good! This is the first (pre-)release of 2.x with not finalized API, intended to gather user feedback related to internal Spock migration to JUnit Platform.</description>
        <content:encoded>&lt;blockquote&gt;
&lt;p&gt;Get know what you can expect from Spock 2.0 M2 (based on JUnit 5), how to migrate to it in Gradle and Maven, and why it is important to report spotted problems :).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;Important note&lt;/strong&gt;. I definitely do &lt;strong&gt;not&lt;/strong&gt; encourage you to migrate your serious real-life project to Spock 2.0 M1 or M2 for good! This is the first (pre-)release of 2.x with not finalized API, intended to gather user feedback related to internal Spock migration to JUnit Platform.&lt;/p&gt;
&lt;p&gt;This blog post arose to try to encourage you to make a &lt;strong&gt;test&lt;/strong&gt; migration of your projects to Spock 2.0, see what started to fail, fix it (if caused by your tests) or report it (if it is a regression in Spock itself). As a result - at the Spock side - it will be possible to improve the code base before Milestone 2. The benefit for you - in addition to contribution to the FOSS project :-) - will be awareness of required changes (kept in a side branch) and readiness to migration once Spock 2.0 is more mature.&lt;/p&gt;
&lt;p&gt;I plan to update this blog post when the next Spock 2 versions are available.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Updated 2020-02-10 to cover Spock 2.0 M2 with a dedicated Groovy 3 support.&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Updated 2020-03-05&lt;/strong&gt;. New point about dealing with &lt;code&gt;NoClassDefFoundError: LambdaExpression&lt;/code&gt;.&lt;br /&gt;
&lt;strong&gt;Updated 2020-03-11&lt;/strong&gt;. Detecting &amp;ldquo;no tests&amp;rdquo; issue with multiple test tasks.&lt;/p&gt;


&lt;figure &gt;
  
    &lt;img src=&#34;https://blog.solidsoft.pl/images/posts/2020/spock2-junit5-logo-grey-horiz.png&#34; alt=&#34;Spock 2 &amp;#43; JUnit 5 with Gradle and Maven&#34; style=&#34;width:;height:;&#34;/&gt;
  
  
&lt;/figure&gt;

&lt;h2 id=&#34;powered-by-junit-platform&#34;&gt;Powered by JUnit Platform&lt;/h2&gt;
&lt;p&gt;The main change in Spock 2.0 M1 is migration to JUnit 5 (precisely speaking to execute tests with JUnit Platform 1.5, part of JUnit 5 instead of the JUnit 4 runner API). This is very convenient as Spock tests should be automatically recognized and executed everywhere the JUnit Platform is supported (IDEs, build tools, quality tools, etc.). In addition, the features provided by the platform itself (such as parallel test execution) should be (eventually) available also for Spock.&lt;/p&gt;
&lt;h3 id=&#34;gradle&#34;&gt;Gradle&lt;/h3&gt;
&lt;p&gt;To bring Spock 2 to a Gradle project it is needed to bump the Spock version:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-groovy&#34; data-lang=&#34;groovy&#34;&gt;&lt;span class=&#34;n&#34;&gt;testImplementation&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;org.spockframework:spock-core:2.0-M2-groovy-2.5&amp;#39;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and activate tests execution by JUnit Platform:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-groovy&#34; data-lang=&#34;groovy&#34;&gt;&lt;span class=&#34;n&#34;&gt;test&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;n&#34;&gt;useJUnitPlatform&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;()&lt;/span&gt;
&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Update 20200218&lt;/strong&gt;. It is enough, but as Tomek Przybysz reminded in his comment, Gradle by default doesn&amp;rsquo;t fail if not tests are found. It may lead to a situation when after making that switch a build finished successfully, giving a false sense of security, while there are no tests executed at all.&lt;br /&gt;
It is a &lt;a href=&#34;https://github.com/gradle/gradle/issues/7452&#34; target=&#34;_blank&#34;&gt;known issue&lt;/a&gt;
 in Gradle, not only limited to Spock. As a workaround the aforementioned configuration might to extended to:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-groovy&#34; data-lang=&#34;groovy&#34;&gt;&lt;span class=&#34;n&#34;&gt;test&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;n&#34;&gt;useJUnitPlatform&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;()&lt;/span&gt;

    &lt;span class=&#34;n&#34;&gt;afterSuite&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;desc&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;result&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;-&amp;gt;&lt;/span&gt;
        &lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;(!&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;desc&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;parent&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
            &lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;result&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;testCount&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;==&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
                &lt;span class=&#34;k&#34;&gt;throw&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;new&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;IllegalStateException&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;No tests were found. Failing the build&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;
            &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
        &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
    &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Or the more sophisticated version for multiple test tasks (e.g. unit/integration and functional):&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;12
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;13
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-groovy&#34; data-lang=&#34;groovy&#34;&gt;&lt;span class=&#34;n&#34;&gt;tasks&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;withType&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Test&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;).&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;configureEach&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;testTask&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;-&amp;gt;&lt;/span&gt;
    &lt;span class=&#34;n&#34;&gt;testTask&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;configure&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
        &lt;span class=&#34;n&#34;&gt;useJUnitPlatform&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;()&lt;/span&gt;

        &lt;span class=&#34;n&#34;&gt;afterSuite&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;desc&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;result&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;-&amp;gt;&lt;/span&gt;
            &lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;(!&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;desc&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;parent&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
                &lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;result&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;testCount&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;==&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
                    &lt;span class=&#34;k&#34;&gt;throw&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;new&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;IllegalStateException&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;No tests were found. Failing the build&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;
                &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
            &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
        &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
    &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h3 id=&#34;maven&#34;&gt;Maven&lt;/h3&gt;
&lt;p&gt;With Maven on the other hand, it is still required to switch to a never Spock version:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-xml&#34; data-lang=&#34;xml&#34;&gt;&lt;span class=&#34;nt&#34;&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
  &lt;span class=&#34;nt&#34;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.spockframework&lt;span class=&#34;nt&#34;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
  &lt;span class=&#34;nt&#34;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;spock-core&lt;span class=&#34;nt&#34;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
  &lt;span class=&#34;nt&#34;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;2.0-M2-groovy-2.5&lt;span class=&#34;nt&#34;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
  &lt;span class=&#34;nt&#34;&gt;&amp;lt;scope&amp;gt;&lt;/span&gt;test&lt;span class=&#34;nt&#34;&gt;&amp;lt;/scope&amp;gt;&lt;/span&gt;
&lt;span class=&#34;nt&#34;&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;but that is all. The Surefire plugin (if you use version 3.0.0+) executes JUnit Platform tests by default, if junit-platform-engine (a transitive dependency of Spock 2) is found.&lt;/p&gt;
&lt;p&gt;The minimal working project for Gradle i Maven is available from &lt;a href=&#34;https://github.com/szpak/code-examples-and-poc/tree/master/spock2-migration-gradle-maven&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt;
.&lt;/p&gt;
&lt;h2 id=&#34;other-changes&#34;&gt;Other changes&lt;/h2&gt;
&lt;p&gt;Having such big change as migration to JUnit Platform, number of other changes in Spock 2.0 M1 is limited, to make finding a reason of potential regressions a little bit easier. As a side effects of the migration itself, the required Java version is 8.&lt;/p&gt;
&lt;p&gt;In addition, all parameterized tests are (finally) &amp;ldquo;unrolled&amp;rdquo; automatically. That is great, however, currently there is &lt;a href=&#34;https://github.com/spockframework/spock/issues/967&#34; target=&#34;_blank&#34;&gt;no way&lt;/a&gt;
 to &amp;ldquo;roll&amp;rdquo; particular tests, as known from &lt;a href=&#34;https://github.com/szpak/spock-global-unroll&#34; target=&#34;_blank&#34;&gt;spock-global-unroll&lt;/a&gt;
 for Spock 1.x.&lt;/p&gt;
&lt;p&gt;Some other changes (such as temporarily disabled &lt;code&gt;SpockReportingExtension&lt;/code&gt;) can be found in the &lt;a href=&#34;https://github.com/spockframework/spock/blob/master/docs/release_notes.adoc#20-m1-31122019&#34; target=&#34;_blank&#34;&gt;release notes&lt;/a&gt;
.&lt;/p&gt;
&lt;p&gt;More (possibly breaking) changes are expected to be merged into Milestone 2.&lt;/p&gt;
&lt;h2 id=&#34;issue-with-junit-4-rules&#34;&gt;Issue with JUnit 4 rules&lt;/h2&gt;
&lt;p&gt;The tests using JUnit 4 &lt;code&gt;@Rule&lt;/code&gt;s (or &lt;code&gt;@ClassRule&lt;/code&gt;s) are expected to fail with an error message suggesting that requested objects were not created/initialized before a test (e.g. &lt;code&gt;NullPointerException&lt;/code&gt; or &lt;code&gt;IllegalStateException: the temporary folder has not yet been created&lt;/code&gt;) or were not verified/cleaned up after it (e.g. soft assertions from AssertJ). The Rules API is no longer supported by JUnit Platform. However, to make the migration easier (&lt;code&gt;@TemporaryFolder&lt;/code&gt; is probably very often used in Spock-based integration tests), there is a dedicated &lt;code&gt;spock-junit4&lt;/code&gt; which internally wraps JUnit 4 rules into the Spock extensions and executes it in the Spock&amp;rsquo;s lifecycle. As it is implemented as a global extension, the only required thing to add is another dependency. In Gradle:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-groovy&#34; data-lang=&#34;groovy&#34;&gt;&lt;span class=&#34;n&#34;&gt;testImplementation&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;org.spockframework:spock-junit4:2.0-M2-groovy-2.5&amp;#39;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;or in Maven:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-xml&#34; data-lang=&#34;xml&#34;&gt;&lt;span class=&#34;nt&#34;&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
    &lt;span class=&#34;nt&#34;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.spockframework&lt;span class=&#34;nt&#34;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
    &lt;span class=&#34;nt&#34;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;spock-junit4&lt;span class=&#34;nt&#34;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
    &lt;span class=&#34;nt&#34;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;2.0-M2-groovy-2.5&lt;span class=&#34;nt&#34;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
    &lt;span class=&#34;nt&#34;&gt;&amp;lt;scope&amp;gt;&lt;/span&gt;test&lt;span class=&#34;nt&#34;&gt;&amp;lt;/scope&amp;gt;&lt;/span&gt;
&lt;span class=&#34;nt&#34;&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;That makes migration easier, but it is good to think about a switch to native Spock counterpart, if available/feasible.&lt;/p&gt;
&lt;h2 id=&#34;groovy-3-support&#34;&gt;Groovy 3 support&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Updated 2020-02-10&lt;/strong&gt;. The whole Groovy 3 section was added to cover changes in Spock 2.0 Milestone 2.&lt;/p&gt;
&lt;p&gt;After my complains about runtime failure when Spock 2.0 M1 is used with Groovy 3.0, I rolled up my sleeves to check how hard would it be to provide that support. It took me some time, however, after after &lt;a href=&#34;https://github.com/spockframework/spock/pull/1075&#34; target=&#34;_blank&#34;&gt;23 (multiple times rebased) commits&lt;/a&gt;
, constructive feedback from other Spock contributors and fruitful discussion with the Groovy developers, the support for Groovy 3 has been merged and is available as the main feature of Spock 2.0 M2, released right after Groovy 3.0.0 final.&lt;/p&gt;
&lt;p&gt;To use Spock 2.0 M2 with Groovy 3 it is enough to just use the &lt;code&gt;spock-*-2.0-M1&lt;/code&gt; artifacts with the &lt;code&gt;-groovy-3.0&lt;/code&gt; suffix.&lt;/p&gt;
&lt;p&gt;It is worth noting that Groovy 3 is not backward compatible with Groovy 2. To keep one Spock codebase, there is a layer of abstraction in Spock to allow to build (and use) the project with both Groovy 2 and 3. As a result, an extra artifact &lt;code&gt;spock-groovy2-compat&lt;/code&gt; is (automatically) used in projects with Groovy 2. It is &lt;strong&gt;very important&lt;/strong&gt; to &lt;strong&gt;do not mix&lt;/strong&gt; the &lt;code&gt;spock-*-2.x-groovy-2.5&lt;/code&gt; artifacts with the &lt;code&gt;groovy-*-3.x&lt;/code&gt; artifacts on a classpath. This may result in weird runtime errors.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m really happy that developers can immediately start testing the new Groovy 3.0.0 with Spock 2.0-M2 in their projects. In addition, as Spock is quite important (and low level) project in the Groovy ecosystem, it was nice to confirm that Groovy 3 works properly with it (and to report - along the way - a few minor detected issues to make Groovy even better ;-) ).&lt;/p&gt;
&lt;h2 id=&#34;other-issues-and-limitations&#34;&gt;Other issues and limitations&lt;/h2&gt;
&lt;h3 id=&#34;noclassdeffounderror-lambdaexpression-with-groovy-25&#34;&gt;NoClassDefFoundError: LambdaExpression with Groovy 2.5&lt;/h3&gt;
&lt;p&gt;Using Spock 2.0-M2 with Groovy 2.5 it is possible to get the following errors:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;java.lang.NoClassDefFoundError: org/codehaus/groovy/ast/expr/LambdaExpression
java.lang.NoClassDefFoundError: org/codehaus/groovy/ast/expr/MethodReferenceExpression
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;As Groovy 2 and 3 are not backward compatible, there is an abstraction layer which allows to build (and use) Spock with two different Groovy versions. However, to achieve that it was necessary to add dummy &lt;code&gt;LambdaExpression&lt;/code&gt; and &lt;code&gt;MethodReferenceExpression&lt;/code&gt; in an extra Spock dependency &lt;code&gt;spock-groovy2-compat&lt;/code&gt; used in the &lt;code&gt;-groovy-2.5&lt;/code&gt; variant.&lt;/p&gt;
&lt;p&gt;It is automatically fetched by Maven/Gradle for &lt;code&gt;spock-core&lt;/code&gt;, but in the situation you disabled transitive dependency for Spock:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-groovy&#34; data-lang=&#34;groovy&#34;&gt;&lt;span class=&#34;n&#34;&gt;dependencies&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;n&#34;&gt;testImplementation&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;org.spockframework:spock-core:2.0-M2-groovy-2.5&amp;#39;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
        &lt;span class=&#34;n&#34;&gt;transitive&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;kc&#34;&gt;false&lt;/span&gt;
    &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
    &lt;span class=&#34;o&#34;&gt;...&lt;/span&gt;
&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;or&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-groovy&#34; data-lang=&#34;groovy&#34;&gt;&lt;span class=&#34;nd&#34;&gt;@Grab&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;org.spockframework:spock-core:2.0-M2-groovy-2.5;transitive=false&amp;#39;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;they are missing. In that case you might want to add &lt;code&gt;spock-groovy2-compat&lt;/code&gt; dependency explicitly, e.g.:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-groovy&#34; data-lang=&#34;groovy&#34;&gt;&lt;span class=&#34;n&#34;&gt;dependencies&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;n&#34;&gt;testImplementation&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;org.spockframework:spock-core:2.0-M2-groovy-2.5&amp;#39;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
        &lt;span class=&#34;n&#34;&gt;transitive&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;kc&#34;&gt;false&lt;/span&gt;
    &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
    &lt;span class=&#34;n&#34;&gt;testImplementation&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;org.spockframework:spock-groovy2-compat:2.0-M2-groovy-2.5&amp;#39;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;
&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;or exclude just Groovy dependencies (not all of them):&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-groovy&#34; data-lang=&#34;groovy&#34;&gt;&lt;span class=&#34;n&#34;&gt;dependencies&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;n&#34;&gt;testImplementation&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;org.spockframework:spock-core:2.0-M2-groovy-2.5&amp;#39;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
        &lt;span class=&#34;n&#34;&gt;exclude&lt;/span&gt; &lt;span class=&#34;nl&#34;&gt;group:&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;org.codehaus.groovy&amp;#39;&lt;/span&gt;
    &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Thanks to &lt;a href=&#34;https://twitter.com/paulk_asert&#34; target=&#34;_blank&#34;&gt;Paul King&lt;/a&gt;
 for suggesting that point.&lt;/p&gt;
&lt;h3 id=&#34;missing-groovy-3-support&#34;&gt;&lt;del&gt;Missing Groovy 3 support&lt;/del&gt;&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Updated 2020-02-10&lt;/strong&gt;. This section originally refereed to limitations of Spock 2.0 M1. Milestone 2 supports Groovy 3.&lt;/p&gt;
&lt;span style=&#34;opacity: 0.6&#34;&gt;&lt;p&gt;Spock 2.0 M1 is compiled and tested only with Groovy 2.5.8. As of M1, execution with Groovy 3.0 is currently blocked at runtime. Unfortunately, instead of a clear error message about incompatible Groovy version there is only a very cryptic error message:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at
jar:file:/.../spock-core-2.0-M1-groovy-2.5.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation
because of exception java.lang.reflect.InvocationTargetException
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;It is already &lt;a href=&#34;https://github.com/spockframework/spock/issues/1067&#34;&gt;reported&lt;/a&gt; and should be enhanced by M2.&lt;/p&gt;
&lt;/span&gt;
&lt;div class=&#34;expand&#34;&gt;
  &lt;button type=&#34;button&#34; class=&#34;expand__button&#34; aria-label=&#34;Expand Button&#34;&gt;
    &lt;span class=&#34;expand-icon expand-icon__right&#34;&gt;
        &lt;svg xmlns=&#34;http://www.w3.org/2000/svg&#34; width=&#34;24&#34; height=&#34;24&#34; viewBox=&#34;0 0 24 24&#34;&gt;&lt;path fill=&#34;currentColor&#34; d=&#34;M9.29 15.88L13.17 12 9.29 8.12c-.39-.39-.39-1.02 0-1.41.39-.39 1.02-.39 1.41 0l4.59 4.59c.39.39.39 1.02 0 1.41L10.7 17.3c-.39.39-1.02.39-1.41 0-.38-.39-.39-1.03 0-1.42z&#34;/&gt;&lt;/svg&gt;
    &lt;/span&gt;
    Click here to expand outdated information about lack of Groovy 3 support in Spock 2.0-M1
  &lt;/button&gt;
  &lt;div class=&#34;expand__content&#34;&gt;
    &lt;span style=&#34;opacity: 0.6&#34;&gt;Sadly, the limitation to Groovy 2.5 only, reduces potential feedback from people experimenting with Groovy 3 which is pretty close to a stable version (RC2 as of 2019/2020). It’s especially inconvenient as many Spock tests just work with Groovy 3 (of course there are some corner cases). There is a chance that Spock 2 before getting final will be adjusted to changes in Groovy 3 or at least the aforementioned hard limitation will be lifted. In the meantime, it is required to test Groovy 3 support with the snapshot version - &lt;code&gt;2.0-groovy-2.5-SNAPSHOT&lt;/code&gt; (which has that check disabled).&lt;/span&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;summary&#34;&gt;Summary&lt;/h2&gt;
&lt;p&gt;The action to do after reading this post is simple. Try to &lt;em&gt;temporarily&lt;/em&gt; play with Spock 2.0 M2 in your projects and &lt;a href=&#34;https://github.com/spockframework/spock/issues&#34; target=&#34;_blank&#34;&gt;report&lt;/a&gt;
 any spotted issues, to help make Spock 2.0 even better :).&lt;/p&gt;
</content:encoded>
        <dc:creator>Marcin Zajączkowski</dc:creator>
        <media:content url="https://blog.solidsoft.pl/images/posts/2020/spock2-junit5-logo-grey-horiz.png" medium="image"><media:title type="html">featured image</media:title></media:content>
        
        <media:content url="https://blog.solidsoft.pl/images/posts/2020/spock2-junit5-logo-grey-horiz-ratio.png" medium="image"><media:title type="html">meta image</media:title></media:content>
        
          
            
              <category>gradle</category>
            
          
            
              <category>junit5</category>
            
          
            
              <category>maven</category>
            
          
            
              <category>migration</category>
            
          
            
              <category>spock</category>
            
          
            
              <category>spock2</category>
            
          
            
              <category>spock-2.0</category>
            
          
            
              <category>testing</category>
            
          
            
              <category>tests</category>
            
          
        
        
          
            
              <category>Tools</category>
            
          
        
        
      </item>
      

    
  </channel>
</rss>