-
Notifications
You must be signed in to change notification settings - Fork 402
Migrate to Groovy 4 which supports Java 25 #732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| distributionBase=GRADLE_USER_HOME | ||
| distributionPath=wrapper/dists | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip | ||
| networkTimeout=10000 | ||
| zipStoreBase=GRADLE_USER_HOME | ||
| zipStorePath=wrapper/dists |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -437,6 +437,8 @@ class PipelineTestHelper { | |
|
|
||
| configuration.setDefaultScriptExtension(scriptExtension) | ||
| configuration.setScriptBaseClass(scriptBaseClass.getName()) | ||
| //This makes the NonCPS calling CPS fail correctly | ||
| configuration.getOptimizationOptions().put(org.codehaus.groovy.control.CompilerConfiguration.INVOKEDYNAMIC, false) | ||
|
|
||
| gse = new GroovyScriptEngine(scriptRoots, cLoader) | ||
| gse.setConfig(configuration) | ||
|
|
@@ -488,6 +490,10 @@ class PipelineTestHelper { | |
| * @param args method arguments | ||
| */ | ||
| protected void registerMethodCall(Object target, int stackDepth, String name, Object... args) { | ||
| if (name.equalsIgnoreCase('getBinding')) { | ||
| // ignore getBinding calls | ||
| return | ||
| } | ||
| MethodCall call = new MethodCall() | ||
| call.target = target | ||
| call.methodName = name | ||
|
|
@@ -566,12 +572,32 @@ class PipelineTestHelper { | |
| Script loadInlineScript(String scriptText, Binding binding) { | ||
| Objects.requireNonNull(binding, "Binding cannot be null.") | ||
| Objects.requireNonNull(gse, "GroovyScriptEngine is not initialized: Initialize the helper by calling init().") | ||
| GroovyShell shell = new GroovyShell(gse.getParentClassLoader(), binding, gse.getConfig()) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The load inline was completely broken, it was just hanging - so used existing logic to treat as file scripts |
||
| Script script = shell.parse(scriptText) | ||
| // make sure to set global vars after parsing the script as it will trigger library loads, otherwise library methods will be unregistered | ||
| setGlobalVars(binding) | ||
| InterceptingGCL.interceptClassMethods(script.metaClass, this, binding) | ||
| return script | ||
|
|
||
| // Ensure we have a mutable list of roots | ||
| if (scriptRoots == null) { | ||
| scriptRoots = new String[0] | ||
| } | ||
|
|
||
| // Inline script root under target (ephemeral, not committed) | ||
| String inlineRootRel = "target/pipeline-inline" | ||
| File inlineRootDir = Paths.get(baseScriptRoot, inlineRootRel).toFile() | ||
| inlineRootDir.mkdirs() | ||
|
|
||
| // Dynamically add inline root to scriptRoots if missing | ||
| if (!scriptRoots.contains(inlineRootRel)) { | ||
| scriptRoots = (scriptRoots + inlineRootRel) as String[] | ||
| // Reconfigure GroovyScriptEngine with the updated roots | ||
| gse = new GroovyScriptEngine(scriptRoots, gse.groovyClassLoader) | ||
| gse.setConfig(gse.config) | ||
| } | ||
|
|
||
| // Unique file name | ||
| String fileName = "__inline__${System.nanoTime()}.${scriptExtension}" | ||
| File inlineFile = new File(inlineRootDir, fileName) | ||
| inlineFile.text = scriptText | ||
|
|
||
| // Load relative to the newly added root | ||
| return loadScript(fileName, binding) | ||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ abstract class GenericPipelineDeclaration { | |
| // declare componentInstance as final to prevent any multithreaded issues, since it is used inside closure | ||
| final def componentInstance = componentType.newInstance() | ||
| def rehydrate = closure.rehydrate(componentInstance, closure, componentInstance) | ||
| rehydrate.resolveStrategy = DELEGATE_FIRST | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Helped with the majority of the issues of switching... |
||
| if (binding && componentInstance.hasProperty('binding') && componentInstance.binding != binding) { | ||
| componentInstance.binding = binding | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,7 +99,7 @@ class LibraryLoader { | |
| def urls = library.retriever.retrieve(library.name, version ?: library.defaultVersion, library.targetPath) | ||
| def record = new LibraryRecord(library, version ?: library.defaultVersion, urls.path) | ||
| libRecords.put(record.getIdentifier(), record) | ||
| def globalVars = [:] | ||
| Map<String, Object> globalVars = [:] | ||
| urls.forEach { URL url -> | ||
| def file = new File(url.toURI()) | ||
|
|
||
|
|
@@ -115,7 +115,7 @@ class LibraryLoader { | |
| ds.map { it.toFile() } | ||
| .filter ({File it -> it.name.endsWith('.groovy') } as Predicate<File>) | ||
| .map { FilenameUtils.getBaseName(it.name) } | ||
| .filter ({String it -> !globalVars.containsValue(it) } as Predicate<String>) | ||
| .filter ({String it -> !globalVars.containsKey(it) } as Predicate<String>) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed for upgrade, but was clearly an error |
||
| .forEach ({ String it -> | ||
| def clazz = groovyClassLoader.loadClass(it) | ||
| // instantiate by invokeConstructor to avoid interception | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| parameters.run() | ||
| parameters.booleanParam({name=myBooleanParam, description=My boolean typed parameter}) | ||
| parameters.string({name=myStringParam, defaultValue=my default value, description=My string typed parameter}) | ||
| parameters.booleanParam([name:myBooleanParam, description:My boolean typed parameter]) | ||
| parameters.string([name:myStringParam, defaultValue:my default value, description:My string typed parameter]) | ||
| parameters.parameters([null, null]) | ||
| parameters.properties([null]) | ||
| parameters.echo('myStringParam' value is default: my default value) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| withCredentialsAndParameters.run() | ||
| withCredentialsAndParameters.booleanParam({name=myBooleanParam, description=My boolean typed parameter}) | ||
| withCredentialsAndParameters.string({name=myStringParam, defaultValue=my default value, description=My string typed parameter}) | ||
| withCredentialsAndParameters.booleanParam([name:myBooleanParam, description:My boolean typed parameter]) | ||
| withCredentialsAndParameters.string([name:myStringParam, defaultValue:my default value, description:My string typed parameter]) | ||
| withCredentialsAndParameters.parameters([null, null]) | ||
| withCredentialsAndParameters.properties([null]) | ||
| withCredentialsAndParameters.echo('myStringParam' value is default: my default value) | ||
| withCredentialsAndParameters.string({credentialsId=my-gitlab-api-token, variable=GITLAB_API_TOKEN}) | ||
| withCredentialsAndParameters.string([credentialsId:my-gitlab-api-token, variable:GITLAB_API_TOKEN]) | ||
| withCredentialsAndParameters.withCredentials([GITLAB_API_TOKEN], groovy.lang.Closure) | ||
| withCredentialsAndParameters.echo('my-gitlab-api-token' credential variable value: GITLAB_API_TOKEN) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These suddenly filled the stack output