From d81011029f01e49072fb5ac2108668b6a5815a12 Mon Sep 17 00:00:00 2001 From: Matteo Mara Date: Wed, 11 Sep 2024 17:21:38 +0200 Subject: [PATCH] NO-JIRA Simplify the handling of sonar-application min/max archive size --- sonar-application/build.gradle | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/sonar-application/build.gradle b/sonar-application/build.gradle index ee484a67c46..a217fd7aab3 100644 --- a/sonar-application/build.gradle +++ b/sonar-application/build.gradle @@ -339,14 +339,20 @@ task zip(type: Zip, dependsOn: [configurations.compileClasspath]) { zip { mustRunAfter cyclonedxBom doLast { - def minLength = 342000000 - def maxLength = 750000000 - - def length = archiveFile.get().asFile.length() - if (length < minLength) - throw new GradleException("${archiveFileName.get()} size ($length) too small. Min is $minLength") - if (length > maxLength) - throw new GradleException("${destinationDirectory.get()}/${archiveFileName.get()} size ($length) too large. Max is $maxLength") + //When the archive size increases due to dependencies, the expected size should be updated as well. + //Bump the expected size by at least 10 more megabytes than what is strictly needed, this in conjunction with the + //tolerance will allow for some growth in the archive size. + def expectedSize = 760000000 + //We set a tolerance of 15MB to avoid failing the build for small differences in the archive size. + def tolerance = 15000000 + def minArchiveSize = expectedSize - tolerance + def maxArchiveSize = expectedSize + tolerance + + def archiveSize = archiveFile.get().asFile.length() + if (archiveSize < minArchiveSize) + throw new GradleException("${archiveFileName.get()} size ($archiveSize) too small. Min is $minArchiveSize") + if (archiveSize > maxArchiveSize) + throw new GradleException("${destinationDirectory.get()}/${archiveFileName.get()} size ($archiveSize) too large. Max is $maxArchiveSize") } } assemble.dependsOn zip -- 2.39.5