@@ -62,24 +62,33 @@ def grapeBridgeCache = (findProperty('groovy.grape.bridge-cache') ?:
6262tasks. withType(Test ). configureEach {
6363 def fs = objects. newInstance(TestServices ). fileSystemOperations
6464 def grapeDirectory = new File (temporaryDir, ' .groovy' )
65- // GROOVY-12005 / 2026-05: Maven Central (Fastly) returns HTTP 404 with a 1-byte
66- // body for requests bearing the JDK URLConnection default User-Agent ("Java/<version>"),
67- // which Ivy's BasicURLHandler relies on. We must set http.agent as a JVM argument
68- // here rather than via systemProperty / a static initializer in GrapeIvy: by the
69- // time GrapeIvy's class init runs (lazily on first @Grab), the test JVM has already
70- // loaded HttpURLConnection and its agent is locked in. Passing it as `-Dhttp.agent`
71- // on the JVM command line guarantees it's set before any class is initialized.
72- // Tests pass with literally any non-"Java/*" value; see also the matching static
73- // initializer in GrapeIvy for CLI / standalone-script coverage.
7465 def options = [' -ea' , " -Xms${ groovyJUnit_ms} " , " -Xmx${ groovyJUnit_mx} " ,
75- ' -Duser.language=en' , ' -Duser.country=US' ,
76- ' -Dhttp.agent=Apache-Ivy_Groovy-Grape' ]
66+ ' -Duser.language=en' , ' -Duser.country=US' ]
7767 jvmArgs(* options)
68+ // GROOVY-12005 / 2026-05: Maven Central (Fastly) returns HTTP 404 with a
69+ // 1-byte body for requests bearing the JDK URLConnection default User-Agent
70+ // ("Java/<version>"), which Ivy 2.5.3's BasicURLHandler relies on. We adopt
71+ // a Maven-shaped UA — Maven Resolver's HTTP transport sends this and the CDN
72+ // doesn't 404 it. The Maven version string is decorative; the CDN's filter
73+ // is on the bare "Java/<version>" default, not on Maven's specific version.
74+ //
75+ // http.agent must reach the test JVM as `-Dhttp.agent=...` on the command
76+ // line: by the time GrapeIvy's matching static initializer runs (lazily on
77+ // first @Grab), HttpURLConnection's userAgent static is already populated
78+ // and our value would arrive too late. Using `systemProperty` rather than
79+ // raw `jvmArgs` preserves the space-containing value as a single argument.
80+ systemProperty ' http.agent' ,
81+ " Apache-Maven/3.9.14 (Java ${ System.getProperty('java.version')} ; ${ System.getProperty('os.name')} ${ System.getProperty('os.version')} )"
7882 systemProperty ' groovy.force.illegal.access' , findProperty(' groovy.force.illegal.access' )
7983 def testdb = System . properties[' groovy.testdb.props' ]
8084 if (testdb) {
8185 systemProperty ' groovy.testdb.props' , testdb
8286 }
87+ // Forward StrictLocalM2Resolver opt-in to test JVMs. Accepts -P or -D.
88+ def strictLocalM2 = findProperty(' groovy.grape.strict-localm2' ) ?: System . properties[' groovy.grape.strict-localm2' ]
89+ if (strictLocalM2) {
90+ systemProperty ' groovy.grape.strict-localm2' , strictLocalM2
91+ }
8392 def headless = System . properties[' java.awt.headless' ]
8493 if (headless == ' true' ) {
8594 systemProperty ' java.awt.headless' , ' true'
@@ -105,7 +114,7 @@ tasks.withType(Test).configureEach {
105114 println " Using ${ executable} to run tests"
106115 }
107116
108- forkEvery = 50
117+ forkEvery = 40
109118 maxParallelForks = sharedConfiguration. isRunningOnCI ? 1 : (Runtime . runtime. availableProcessors(). intdiv(2 ) ?: 1 )
110119 scanForTestClasses = true
111120 ignoreFailures = false
0 commit comments