SonarSource/sonarqube · error · GradleException

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

Error message

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

What it means

Companion upper-bound check to error 587: the distribution zip must not exceed maxArchiveSize. This guard throws both in CI and locally (unless local-dev properties useLocalSca/useLocalArchitecture/etc. are set, which relaxes it locally) when archiveSize > maxArchiveSize, catching accidental bloat like debug artifacts or extra files in the distribution.

Source

Thrown at sonar-application/build.gradle:524

    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)
  }
}
assemble.dependsOn cleanLocalUnzippedDir

View on GitHub (pinned to 184c821202)

Solutions

  1. Check what got added to the zip (unzip -l) and remove unintended content
  2. If the growth is intentional, update `expectedSize` in sonar-application/build.gradle so maxArchiveSize accommodates it
  3. For local development of bundled modules, enable the relevant useLocal* property to skip the upper-bound check locally

Example fix

// before (build.gradle)
expectedSize = 300 * 1024 * 1024
// after (build.gradle)
expectedSize = 350 * 1024 * 1024 // intentional growth from new bundled plugin
Defensive patterns

Strategy: validation

Validate before calling

// shell: sanity-check distribution size locally before upload
ZIP=$(find sonar-application/build/distributions -name '*.zip' | head -1)
SIZE=$(stat -c%s "$ZIP")
MAX=$(( 400 * 1024 * 1024 )) # align with maxArchiveSize
[ "$SIZE" -le "$MAX" ] || { echo "zip too large: $SIZE"; exit 1; }

Prevention

When it happens

Trigger: Zip grows beyond maxArchiveSize after adding dependencies or bundled files without updating expectedSize; running the zip task locally without any useLocal* property; a CI build that accidentally includes extra content.

Common situations: Adding a large new bundled dependency; accidentally including build artifacts/sources in the zip; intentionally growing the distribution without bumping 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/8073b88b4404aa74. Report an issue: GitHub.