{"record":{"id":"8073b88b4404aa74","repo":"SonarSource/sonarqube","slug":"destinationdirectory-get-archivefilename-ge-8073b8","errorCode":null,"errorMessage":"${destinationDirectory.get()}/${archiveFileName.get()} size ($archiveSize) too large. Max is $maxArchiveSize. If this is expected, update `expectedSize` to ${newExpectedSize} in sonar-application/build.gradle.","messagePattern":"(.+?)/(.+?) size \\(\\$archiveSize\\) too large\\. Max is \\$maxArchiveSize\\. If this is expected, update `expectedSize` to (.+?) in sonar-application/build\\.gradle\\.","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"sonar-application/build.gradle","lineNumber":524,"sourceCode":"    def expectedSize = release ? 940_000_000 : 990_000_000\n    // We set a tolerance to avoid failing the build for small differences in the archive size.\n    def tolerance = 15_000_000\n    def minArchiveSize = expectedSize - tolerance\n    def maxArchiveSize = expectedSize + tolerance\n\n    def archiveSize = archiveFile.get().asFile.length()\n    def newExpectedSize = ((int)(archiveSize / 10_000_000)) * 10_000_000\n    // When building with local snapshot artifacts (useLocalSca, useLocalArchitecture, etc.) the archive\n    // will be larger than a published build because snapshot JARs include test classes and debug info.\n    // Skip the upper-bound check in that case to avoid spurious failures during local development.\n    def usingLocalArtifacts = ['useLocalSca', 'useLocalArchitecture', 'useLocalCagHub', 'useLocalMetrics', 'useLocalOrg',\n                               'useLocalOnboarding', 'useLocalContactForm'].any {\n      project.hasProperty(it) && project.property(it) == 'true'\n    }\n    if (archiveSize < minArchiveSize && System.getenv(\"CI\") == \"true\")\n      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.\")\n    if (archiveSize > maxArchiveSize && (!usingLocalArtifacts || System.getenv(\"CI\") == \"true\"))\n      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.\")\n  }\n}\nassemble.dependsOn zip\n\n// the script start.sh unpacks OSS distribution into $buildDir/distributions/sonarqube-oss.\n// This directory should be deleted when the zip is changed.\ntask cleanLocalUnzippedDir(dependsOn: zip) {\n  def unzippedDir = file(\"$buildDir/distributions/sonarqube-$version\")\n  inputs.files(file(\"$buildDir/distributions/sonar-application-${version}.zip\"))\n  outputs.upToDateWhen { true }\n  outputs.cacheIf('Caching has not been enabled for the task.') { false }\n\n  doLast {\n    println(\"delete directory ${unzippedDir}\")\n    project.delete(unzippedDir)\n  }\n}\nassemble.dependsOn cleanLocalUnzippedDir","sourceCodeStart":506,"sourceCodeEnd":542,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/sonar-application/build.gradle#L506-L542","documentation":"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.","triggerScenarios":"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.","commonSituations":"Adding a large new bundled dependency; accidentally including build artifacts/sources in the zip; intentionally growing the distribution without bumping expectedSize.","solutions":["Check what got added to the zip (unzip -l) and remove unintended content","If the growth is intentional, update `expectedSize` in sonar-application/build.gradle so maxArchiveSize accommodates it","For local development of bundled modules, enable the relevant useLocal* property to skip the upper-bound check locally"],"exampleFix":"// before (build.gradle)\nexpectedSize = 300 * 1024 * 1024\n// after (build.gradle)\nexpectedSize = 350 * 1024 * 1024 // intentional growth from new bundled plugin","handlingStrategy":"validation","validationCode":"// shell: sanity-check distribution size locally before upload\nZIP=$(find sonar-application/build/distributions -name '*.zip' | head -1)\nSIZE=$(stat -c%s \"$ZIP\")\nMAX=$(( 400 * 1024 * 1024 )) # align with maxArchiveSize\n[ \"$SIZE\" -le \"$MAX\" ] || { echo \"zip too large: $SIZE\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Diff zip contents (unzip -l) after adding dependencies to catch bloat","Update expectedSize when the distribution intentionally grows","Don't include debug/intermediate artifacts in the distribution","Set useLocal* properties only for local iteration, never in CI"],"tags":["gradle","build","artifact-size","ci"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}