Skip to content

Remove undeclared dependencies from Gradle build - #177

Merged
bentsherman merged 2 commits into
nextflow-io:mainfrom
pjones:pjones/deps
Sep 4, 2026
Merged

Remove undeclared dependencies from Gradle build#177
bentsherman merged 2 commits into
nextflow-io:mainfrom
pjones:pjones/deps

Conversation

@pjones

@pjones pjones commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

While creating a package for NixOS/nixpkgs I discovered a few undeclared dependencies. Builds using Nix happen in an isolated sandbox with no network connection. Without these dependencies the build would fail.

It's not clear to me why builds succeed for others. Perhaps these dependencies are cached or maybe just downloaded as needed. Either way I thought I'd open a PR.

pjones and others added 2 commits September 3, 2026 12:46
These are a few dependencies that are missing and cause the build to
fail when no network connection is available.
@bentsherman

bentsherman commented Sep 3, 2026

Copy link
Copy Markdown
Member

Thanks for digging into this — your diagnosis is right, and I traced where those five modules actually come from.

Nothing in the project requests them. They are pulled in by Gradle's Groovy plugin: GroovyRuntime.inferGroovyClasspath() sees org.apache.groovy:groovy on the compile classpath and assembles a detached configuration with the matching groovy-* companion modules for the compiler itself. Detached configurations belong to no project configuration, which is why ./gradlew dependencies shows no trace of them while a clean build downloads them anyway — presumably also why the Nix prefetch step, which resolves the declared configurations, never records them.

With a scratch GRADLE_USER_HOME so every fetch is logged, on main:

compileJava   -> groovy-json, groovy-yaml                                  (declared deps)
compileGroovy -> groovy-ant, groovy-astbuilder, groovy-datetime,
                 groovy-dateutil, groovy-groovydoc, groovy-docgenerator,
                 groovy-nio, groovy-templates, groovy-xml

compileGroovy fires because of src/test/groovy (Spock) and src/spec/groovy; src/main is pure Java.

The catch with declaring them as implementation is that they land on runtimeClasspath and so go into the shadow JAR. groovy-ant drags in Ant 1.10.15 and groovy-groovydoc drags in javaparser + qdox:

size entries
main 15,185,152 (14.5 MiB) 9,134
this PR 19,636,150 (18.7 MiB) 11,482
delta +4,450,998 (+29%) +2,348

Since the modules are only needed by the Groovy compiler, the build can just say so and stop inferring. I pushed a commit to this branch that drops the five implementation lines and pins the compiler classpath instead:

configurations {
  groovyCompiler
  nextflowRuntime
}

tasks.withType(GroovyCompile).configureEach {
  groovyClasspath = configurations.groovyCompiler
}

dependencies {
  groovyCompiler 'org.apache.groovy:groovy:4.0.31'
  ...
}

Verified in a clean GRADLE_USER_HOME running shadowJar test: groovy-ant, -astbuilder, -datetime, -dateutil, -groovydoc, -docgenerator, javaparser and qdox are no longer fetched at all, tests pass, and the JAR stays at 15,185,152 bytes. What still gets fetched is genuine: groovy, groovy-json, groovy-nio, groovy-templates, groovy-xml, groovy-yaml, all real dependencies of nf-lang/nextflow or declared runtimeOnly. Ant still appears in the log, but only from plugins.gradle.org as a dependency of the shadow plugin itself, which is equally true on main.

Could you confirm this builds in the Nix sandbox? Nothing undeclared should be requested now, so the packaging shouldn't need the extra dependencies at all.

@bentsherman

Copy link
Copy Markdown
Member

@pjones can you verify that my edits still work in your NixOS environment?

@pjones

pjones commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@bentsherman Yes, your changes work in Nix build.

Thank you!

@bentsherman bentsherman changed the title Add previously undeclared dependencies Remove undeclared dependencies from Gradle build Sep 4, 2026
@bentsherman
bentsherman merged commit 1d589f8 into nextflow-io:main Sep 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants