SonarSource/sonarqube · error · GradleException

${destinationDirectory.get()}/${archiveFileName.get()} size

Error message

${destinationDirectory.get()}/${archiveFileName.get()} size ($archiveSize) too small. Min is $minArchiveSize. If this is expected, update `expectedSize` to ${newExpectedSize} in sonar-application/build.gradle.

What it means

After building the distribution zip, the build enforces a minimum archive size (derived from expectedSize). If the zip is smaller than minArchiveSize while running in CI, it throws this GradleException, because an unexpectedly small artifact usually means the build silently excluded content (empty or broken distribution).

Source

Thrown at sonar-application/build.gradle:522

    // Non-release builds skip re-compressing already-compressed entries (see skipAlreadyCompressed above), which
    // trades a larger archive for a much faster build; release builds fully compress, staying close to the old size.
    def expectedSize = release ? 940_000_000 : 990_000_000
    // We set a tolerance to avoid failing the build for small differences in the archive size.
    def tolerance = 15_000_000
    def minArchiveSize = expectedSize - tolerance
    def maxArchiveSize = expectedSize + tolerance

    def archiveSize = archiveFile.get().asFile.length()
    def newExpectedSize = ((int)(archiveSize / 10_000_000)) * 10_000_000
    // When building with local snapshot artifacts (useLocalSca, useLocalArchitecture, etc.) the archive
    // will be larger than a published build because snapshot JARs include test classes and debug info.
    // Skip the upper-bound check in that case to avoid spurious failures during local development.
    def usingLocalArtifacts = ['useLocalSca', 'useLocalArchitecture', 'useLocalCagHub', 'useLocalMetrics', 'useLocalOrg',
                               'useLocalOnboarding', 'useLocalContactForm'].any {
      project.hasProperty(it) && project.property(it) == 'true'
    }
    if (archiveSize < minArchiveSize && System.getenv("CI") == "true")
      throw new GradleException("${destinationDirectory.get()}/${archiveFileName.get()} size ($archiveSize) too small. Min is $minArchiveSize. If this is expected, update `expectedSize` to ${newExpectedSize} in sonar-application/build.gradle.")
    if (archiveSize > maxArchiveSize && (!usingLocalArtifacts || System.getenv("CI") == "true"))
      throw new GradleException("${destinationDirectory.get()}/${archiveFileName.get()} size ($archiveSize) too large. Max is $maxArchiveSize. If this is expected, update `expectedSize` to ${newExpectedSize} in sonar-application/build.gradle.")
  }
}
assemble.dependsOn zip

// the script start.sh unpacks OSS distribution into $buildDir/distributions/sonarqube-oss.
// This directory should be deleted when the zip is changed.
task cleanLocalUnzippedDir(dependsOn: zip) {
  def unzippedDir = file("$buildDir/distributions/sonarqube-$version")
  inputs.files(file("$buildDir/distributions/sonar-application-${version}.zip"))
  outputs.upToDateWhen { true }
  outputs.cacheIf('Caching has not been enabled for the task.') { false }

  doLast {
    println("delete directory ${unzippedDir}")
    project.delete(unzippedDir)
  }

View on GitHub (pinned to 184c821202)

Solutions

  1. Investigate why the zip shrank (missing JREs, missing plugins, failed dependency inclusion)
  2. If the smaller size is intentional, update `expectedSize` in sonar-application/build.gradle so minArchiveSize covers it
  3. Re-run the build after fixing; locally you can bypass (check only fires with CI=true) but verify before merging

Example fix

// before (build.gradle)
expectedSize = 300 * 1024 * 1024
// after (build.gradle)
expectedSize = 250 * 1024 * 1024 // distribution intentionally smaller
Defensive patterns

Strategy: validation

Validate before calling

// shell: sanity-check distribution size before CI
ZIP=$(find sonar-application/build/distributions -name '*.zip' | head -1)
SIZE=$(stat -c%s "$ZIP")
MIN=$(( 250 * 1024 * 1024 )) # align with minArchiveSize
[ "$SIZE" -ge "$MIN" ] || { echo "zip too small: $SIZE"; exit 1; }

Prevention

When it happens

Trigger: CI (CI=true) zip task produces an archive whose size < minArchiveSize — e.g. dependencies failed to include, JREs missing, or the artifact genuinely shrank after a dependency removal without updating expectedSize.

Common situations: Removing/renaming a bundled dependency so the zip shrinks below the floor; a broken build producing a near-empty zip; intentionally slimming the distribution without updating expectedSize.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09). Data as JSON: /api/errors/c899eb91429796e2. Report an issue: GitHub.