diff options
author | Alain Kermis <alain.kermis@sonarsource.com> | 2024-02-19 13:36:47 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-02-20 20:02:45 +0000 |
commit | 91841b996da676b769a45dc831d6104465e2fc41 (patch) | |
tree | 38e0867097fc130141cd9fbd6b8d8f16e0ef02c3 | |
parent | 172288cc06ac9da7918f99ed217ddb3c0382679a (diff) | |
download | sonarqube-91841b996da676b769a45dc831d6104465e2fc41.tar.gz sonarqube-91841b996da676b769a45dc831d6104465e2fc41.zip |
SONAR-19498 Backport handling ElasticSearch as a regular gradle dependency
-rw-r--r-- | gradle.properties | 6 | ||||
-rw-r--r-- | sonar-application/build.gradle | 37 |
2 files changed, 15 insertions, 28 deletions
diff --git a/gradle.properties b/gradle.properties index 90e03b1cbf4..2a0e987ed24 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,9 +5,5 @@ projectTitle=SonarQube org.gradle.jvmargs=-Xmx2048m org.gradle.caching=true org.gradle.vfs.watch=true -# https://www.elastic.co/downloads/elasticsearch-no-jdk -elasticsearchDownloadUrlPath=https://artifacts.elastic.co/downloads/elasticsearch/ -elasticsearchDownloadRepoxUrlPath=https://repox.jfrog.io/artifactory/sonarsource-bucket/sonarqube/elasticsearch/ -elasticsearchDownloadUrlFile=elasticsearch-7.17.15-no-jdk-linux-x86_64.tar.gz -elasticsearchDownloadSha512=554869c7b420ae25a21477962d9edc0d6f4c256247c03a59927282f6a908639c3aec30b27237c1fd8bd496b31d1027056fbdf83b3eaaa6d002b0e1eddf02a232 +elasticsearchVersion=7.17.15 projectType=application diff --git a/sonar-application/build.gradle b/sonar-application/build.gradle index 34aceda221c..df7fe0ad391 100644 --- a/sonar-application/build.gradle +++ b/sonar-application/build.gradle @@ -16,6 +16,7 @@ sonar { } configurations { + zipDist zip scanner web @@ -73,6 +74,14 @@ dependencies { jdbc_h2 'com.h2database:h2' jdbc_mssql 'com.microsoft.sqlserver:mssql-jdbc' jdbc_postgresql 'org.postgresql:postgresql' + + def artifactoryUsername = System.env.'ARTIFACTORY_PRIVATE_USERNAME' ?: (project.hasProperty('artifactoryUsername') ? project.getProperty('artifactoryUsername') : '') + def artifactoryPassword = System.env.'ARTIFACTORY_PRIVATE_PASSWORD' ?: (project.hasProperty('artifactoryPassword') ? project.getProperty('artifactoryPassword') : '') + if (artifactoryUsername && artifactoryPassword) { + zipDist "sonarqube:elasticsearch:${elasticsearchVersion}-no-jdk-linux-x86_64@tar.gz" + } else { + zipDist "sonarqube:elasticsearch:${elasticsearchVersion}-linux-x86_64@tar.gz" + } } // declare dependencies in configuration bundledPlugin to be packaged in lib/extensions @@ -91,32 +100,11 @@ task verifySonarProperties(type: Verify) { } } -task verifyElasticSearchDownload(type: Verify) { - src new File(buildDir, "$elasticsearchDownloadUrlFile") - algorithm 'SHA-512' - checksum elasticsearchDownloadSha512 -} - -task downloadElasticSearch(type: Download) { - def artifactoryUsername = System.env.'ARTIFACTORY_PRIVATE_USERNAME' ?: (project.hasProperty('artifactoryUsername') ? project.getProperty('artifactoryUsername') : '') - def artifactoryPassword = System.env.'ARTIFACTORY_PRIVATE_PASSWORD' ?: (project.hasProperty('artifactoryPassword') ? project.getProperty('artifactoryPassword') : '') - if (artifactoryUsername && artifactoryPassword) { - src "$elasticsearchDownloadRepoxUrlPath$elasticsearchDownloadUrlFile" - username artifactoryUsername - password artifactoryPassword - } else { - src "$elasticsearchDownloadUrlPath$elasticsearchDownloadUrlFile" - } - dest "$buildDir/$elasticsearchDownloadUrlFile" - onlyIfModified true - finalizedBy verifyElasticSearchDownload -} - downloadLicenses { dependencyConfiguration = 'appLicenses' } -task zip(type: Zip, dependsOn: [configurations.compileClasspath, downloadElasticSearch, verifyElasticSearchDownload]) { +task zip(type: Zip, dependsOn: [configurations.compileClasspath]) { duplicatesStrategy DuplicatesStrategy.EXCLUDE def archiveDir = "sonarqube-$project.version" @@ -155,7 +143,10 @@ task zip(type: Zip, dependsOn: [configurations.compileClasspath, downloadElastic } - from(tarTree(downloadElasticSearch.dest)) { + ResolvedArtifact elasticSearchArtifact = configurations.zipDist.resolvedConfiguration.resolvedArtifacts.find { + it.moduleVersion.id.name == "elasticsearch" + } + from(tarTree(elasticSearchArtifact.file)) { eachFile { fcd -> def path = fcd.relativePath.segments - fcd.relativeSourcePath.segments + fcd.relativeSourcePath.segments.drop(1) fcd.relativePath = new RelativePath(true, *path) |