{"record":{"id":"c899eb91429796e2","repo":"SonarSource/sonarqube","slug":"destinationdirectory-get-archivefilename-ge","errorCode":null,"errorMessage":"${destinationDirectory.get()}/${archiveFileName.get()} size ($archiveSize) too small. Min is $minArchiveSize. If this is expected, update `expectedSize` to ${newExpectedSize} in sonar-application/build.gradle.","messagePattern":"(.+?)/(.+?) size \\(\\$archiveSize\\) too small\\. Min is \\$minArchiveSize\\. 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":522,"sourceCode":"    // Non-release builds skip re-compressing already-compressed entries (see skipAlreadyCompressed above), which\n    // trades a larger archive for a much faster build; release builds fully compress, staying close to the old size.\n    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  }","sourceCodeStart":504,"sourceCodeEnd":540,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/sonar-application/build.gradle#L504-L540","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Investigate why the zip shrank (missing JREs, missing plugins, failed dependency inclusion)","If the smaller size is intentional, update `expectedSize` in sonar-application/build.gradle so minArchiveSize covers it","Re-run the build after fixing; locally you can bypass (check only fires with CI=true) but verify before merging"],"exampleFix":"// before (build.gradle)\nexpectedSize = 300 * 1024 * 1024\n// after (build.gradle)\nexpectedSize = 250 * 1024 * 1024 // distribution intentionally smaller","handlingStrategy":"validation","validationCode":"// shell: sanity-check distribution size before CI\nZIP=$(find sonar-application/build/distributions -name '*.zip' | head -1)\nSIZE=$(stat -c%s \"$ZIP\")\nMIN=$(( 250 * 1024 * 1024 )) # align with minArchiveSize\n[ \"$SIZE\" -ge \"$MIN\" ] || { echo \"zip too small: $SIZE\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Update expectedSize in sonar-application/build.gradle whenever the distribution's content changes","Inspect the zip (unzip -l) when it shrinks to find what went missing","Keep CI workspaces clean so all bundled content is produced"],"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-14T05:17:10.506Z"}