Repository navigation
Compile plugins with -parameters to retain parameter names in spec - #28
Conversation
pditommaso
left a comment
There was a problem hiding this comment.
Thanks, the approach is right. One gap: Java sources compiled jointly with Groovy (i.e. .java files under src/main/groovy) still lose their parameter names.
Those files are compiled by compileGroovy, not compileJava. Gradle passes them to javac with GroovyCompile.options.compilerArgs; groovyOptions.parameters only affects the Groovy compiler and is never forwarded to javac.
I verified this with a small project (one .java and one .groovy class under src/main/groovy), checking the output with javap -v:
GroovyCompile config |
G.groovy |
J.java |
|---|---|---|
groovyOptions.parameters = true only (this PR) |
alpha ✅ |
no MethodParameters ❌ → arg0, arg1 |
+ options.compilerArgs.add('-parameters') |
alpha ✅ |
provenance, result ✅ |
Suggested fix:
project.tasks.withType(GroovyCompile).configureEach { task ->
task.groovyOptions.parameters = true
// Java sources jointly compiled with Groovy
task.options.compilerArgs.add('-parameters')
}and in the test:
project.tasks.compileGroovy.options.compilerArgs.contains('-parameters')Minor: worth a changelog note that plugins need to rebuild with the new gradle plugin version to get correct names in spec.json; already published plugins keep arg0.
|
Good catch, thanks. I reproduced it: a Java Applied your suggestion in acd384b: I'll add the changelog note (plugins must rebuild with the new version to get real names in |
pditommaso
left a comment
There was a problem hiding this comment.
LGTM. Verified end to end via includeBuild: Groovy, Java, and jointly compiled Java @Functions now get real parameter names in spec.json (previously arg0, arg1), and all Nextflow core plugins still build cleanly.
Nice to have: guard against adding -parameters twice when a plugin build already sets it (e.g. if (!args.contains('-parameters')) args.add('-parameters')). Harmless as is.
Closes #27
Plugins were compiled without method parameter metadata, so
generateSpec(viaFunctionSpec, which usesParameter.getName()) wrotearg0,arg1, … intospec.json, and the language server showed those names for plugin functions.This enables
-parametersfor allJavaCompiletasks andgroovyOptions.parametersfor allGroovyCompiletasks.Verified with a minimal plugin (one Groovy and one Java
@Function) built against this checkout:[{"name": "arg0", "type": "Path"}, {"name": "arg1", "type": "Path"}][{"name": "provenance", "type": "Path"}, {"name": "result", "type": "Path"}]Added a unit test for the compile options;
./gradlew testpasses.