You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build.gradle 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. plugins {
  2. // Ordered alphabeticly
  3. id 'com.github.ben-manes.versions' version '0.33.0'
  4. id 'com.github.hierynomus.license' version '0.15.0'
  5. id "com.github.hierynomus.license-report" version"0.15.0" apply false
  6. id 'com.github.johnrengelman.shadow' version '5.2.0' apply false
  7. id 'com.google.protobuf' version '0.8.13' apply false
  8. id 'com.jfrog.artifactory' version '4.21.0'
  9. id 'com.github.node-gradle.node' version '2.2.4' apply false
  10. id 'io.spring.dependency-management' version '1.0.10.RELEASE'
  11. id "com.asarkar.gradle.build-time-tracker" version "2.0.4" apply false
  12. id 'org.sonarqube' version '3.3'
  13. id "de.undercouch.download" version "4.1.1" apply false
  14. }
  15. // display a summary of task durations at the end of the build
  16. if (project.hasProperty('time-tracker')) {
  17. apply plugin: 'com.asarkar.gradle.build-time-tracker'
  18. buildTimeTracker {
  19. sort = true
  20. maxWidth = 80
  21. minTaskDuration = Duration.ofSeconds(1)
  22. }
  23. }
  24. if (!JavaVersion.current().java11Compatible) {
  25. throw new GradleException("JDK 11+ is required to perform this build. It's currently " + System.getProperty("java.home") + ".")
  26. }
  27. allprojects {
  28. apply plugin: 'com.jfrog.artifactory'
  29. apply plugin: 'maven-publish'
  30. ext.versionInSources = version
  31. ext.buildNumber = System.getProperty("buildNumber")
  32. // when no buildNumber is provided, then project version must end with '-SNAPSHOT'
  33. if (ext.buildNumber == null) {
  34. version = "${version}-SNAPSHOT".toString()
  35. ext.versionWithoutBuildNumber = version
  36. } else {
  37. ext.versionWithoutBuildNumber = version
  38. version = (version.toString().count('.') == 1 ? "${version}.0.${ext.buildNumber}" : "${version}.${ext.buildNumber}").toString()
  39. }
  40. ext {
  41. release = project.hasProperty('release') && project.getProperty('release')
  42. official = project.hasProperty('official') && project.getProperty('official')
  43. }
  44. repositories {
  45. def repository = project.hasProperty('qa') ? 'sonarsource-qa' : 'sonarsource'
  46. maven {
  47. // The environment variables ARTIFACTORY_PRIVATE_USERNAME and ARTIFACTORY_PRIVATE_PASSWORD are used on QA env (Jenkins)
  48. // On local box, please add artifactoryUsername and artifactoryPassword to ~/.gradle/gradle.properties
  49. def artifactoryUsername = System.env.'ARTIFACTORY_PRIVATE_USERNAME' ?: (project.hasProperty('artifactoryUsername') ? project.getProperty('artifactoryUsername') : '')
  50. def artifactoryPassword = System.env.'ARTIFACTORY_PRIVATE_PASSWORD' ?: (project.hasProperty('artifactoryPassword') ? project.getProperty('artifactoryPassword') : '')
  51. if (artifactoryUsername && artifactoryPassword) {
  52. credentials {
  53. username artifactoryUsername
  54. password artifactoryPassword
  55. }
  56. } else {
  57. // Workaround for artifactory
  58. // https://www.jfrog.com/jira/browse/RTFACT-13797
  59. repository = 'public'
  60. }
  61. url "https://repox.jfrog.io/repox/${repository}"
  62. }
  63. }
  64. task allDependencies {
  65. dependsOn 'dependencies'
  66. }
  67. artifactory {
  68. clientConfig.setIncludeEnvVars(true)
  69. clientConfig.setEnvVarsExcludePatterns('*password*,*PASSWORD*,*secret*,*MAVEN_CMD_LINE_ARGS*,sun.java.command,*token*,*TOKEN*,*LOGIN*,*login*,*key*,*KEY*,*signing*')
  70. contextUrl = System.getenv('ARTIFACTORY_URL')
  71. publish {
  72. repository {
  73. repoKey = System.getenv('ARTIFACTORY_DEPLOY_REPO')
  74. username = System.getenv('ARTIFACTORY_DEPLOY_USERNAME') ?: project.properties.artifactoryUsername
  75. password = System.getenv('ARTIFACTORY_DEPLOY_PASSWORD') ?: project.properties.artifactoryPaswword
  76. }
  77. defaults {
  78. properties = [
  79. 'build.name': 'sonar-enterprise',
  80. 'build.number': System.getenv('BUILD_NUMBER'),
  81. 'pr.branch.target': System.getenv('GITHUB_BASE_BRANCH'),
  82. 'pr.number': System.getenv('PULL_REQUEST'),
  83. 'vcs.branch': System.getenv('GITHUB_BRANCH'),
  84. 'vcs.revision': System.getenv('GIT_SHA1'),
  85. 'version': version
  86. ]
  87. publications('mavenJava')
  88. publishPom = true
  89. publishIvy = false
  90. }
  91. }
  92. clientConfig.info.setBuildName('sonar-enterprise')
  93. clientConfig.info.setBuildNumber(System.getenv('BUILD_NUMBER'))
  94. // Define the artifacts to be deployed to https://binaries.sonarsource.com on releases
  95. clientConfig.info.addEnvironmentProperty('ARTIFACTS_TO_PUBLISH',
  96. "${project.group}:sonar-application:zip," +
  97. "com.sonarsource.sonarqube:sonarqube-developer:zip," +
  98. "com.sonarsource.sonarqube:sonarqube-datacenter:zip," +
  99. "com.sonarsource.sonarqube:sonarqube-enterprise:zip")
  100. // The name of this variable is important because it's used by the delivery process when extracting version from Artifactory build info.
  101. clientConfig.info.addEnvironmentProperty('PROJECT_VERSION', "${version}")
  102. }
  103. }
  104. apply plugin: 'org.sonarqube'
  105. sonarqube {
  106. properties {
  107. property 'sonar.projectName', projectTitle
  108. property 'sonar.projectVersion', "${versionInSources}-SNAPSHOT"
  109. property 'sonar.buildString', version
  110. }
  111. }
  112. tasks.named('wrapper') {
  113. distributionType = Wrapper.DistributionType.ALL
  114. }
  115. subprojects {
  116. apply plugin: 'com.github.hierynomus.license'
  117. apply plugin: 'io.spring.dependency-management'
  118. apply plugin: 'jacoco'
  119. apply plugin: 'java'
  120. apply plugin: 'idea'
  121. apply plugin: 'signing'
  122. sourceCompatibility = 1.8
  123. targetCompatibility = 1.8
  124. // do not deploy to Artifactory by default
  125. artifactoryPublish.skip = true
  126. def testFixtureSrc = 'src/testFixtures'
  127. if (file(testFixtureSrc).exists()) {
  128. apply plugin: 'java-test-fixtures'
  129. }
  130. ext {
  131. protobufVersion = '3.21.0'
  132. }
  133. sonarqube {
  134. properties {
  135. property 'sonar.moduleKey', project.group + ':' + project.name
  136. }
  137. }
  138. // Central place for definition dependency versions and exclusions.
  139. dependencyManagement {
  140. dependencies {
  141. // bundled plugin list -- keep it alphabetically ordered
  142. dependency 'com.sonarsource.abap:sonar-abap-plugin:3.9.1.3127'
  143. dependency 'com.sonarsource.cobol:sonar-cobol-plugin:4.6.2.4876'
  144. dependency 'com.sonarsource.cpp:sonar-cfamily-plugin:6.20.5.49286'
  145. dependency 'com.sonarsource.pli:sonar-pli-plugin:1.11.1.2727'
  146. dependency 'com.sonarsource.plsql:sonar-plsql-plugin:3.6.1.3873'
  147. dependency 'com.sonarsource.plugins.vb:sonar-vb-plugin:2.7.1.2721'
  148. dependency 'com.sonarsource.rpg:sonar-rpg-plugin:2.5.1.2575'
  149. dependency 'com.sonarsource.security:sonar-security-csharp-frontend-plugin:8.9.0.11439'
  150. dependency 'com.sonarsource.security:sonar-security-java-frontend-plugin:8.9.0.11439'
  151. dependency 'com.sonarsource.security:sonar-security-php-frontend-plugin:8.9.0.11439'
  152. dependency 'com.sonarsource.security:sonar-security-plugin:8.9.0.11439'
  153. dependency 'com.sonarsource.security:sonar-security-python-frontend-plugin:8.9.0.11439'
  154. dependency 'com.sonarsource.security:sonar-security-js-frontend-plugin:8.9.0.11439'
  155. dependency 'com.sonarsource.slang:sonar-apex-plugin:1.8.3.2219'
  156. dependency 'com.sonarsource.swift:sonar-swift-plugin:4.3.1.4892'
  157. dependency 'com.sonarsource.tsql:sonar-tsql-plugin:1.5.1.4340'
  158. dependency 'org.sonarsource.css:sonar-css-plugin:1.4.2.2002'
  159. dependency 'org.sonarsource.dotnet:sonar-csharp-plugin:8.22.0.31243'
  160. dependency 'org.sonarsource.dotnet:sonar-vbnet-plugin:8.22.0.31243'
  161. dependency 'org.sonarsource.flex:sonar-flex-plugin:2.6.1.2564'
  162. dependency 'org.sonarsource.html:sonar-html-plugin:3.4.0.2754'
  163. dependency 'org.sonarsource.jacoco:sonar-jacoco-plugin:1.1.1.1157'
  164. dependency 'org.sonarsource.java:sonar-java-plugin:6.15.1.26025'
  165. dependency 'org.sonarsource.javascript:sonar-javascript-plugin:7.4.4.15624'
  166. dependency 'org.sonarsource.php:sonar-php-plugin:3.17.0.7439'
  167. dependency 'org.sonarsource.python:sonar-python-plugin:3.4.1.8066'
  168. dependency 'org.sonarsource.slang:sonar-go-plugin:1.8.3.2219'
  169. dependency 'org.sonarsource.slang:sonar-kotlin-plugin:1.8.3.2219'
  170. dependency 'org.sonarsource.slang:sonar-ruby-plugin:1.8.3.2219'
  171. dependency 'org.sonarsource.slang:sonar-scala-plugin:1.8.3.2219'
  172. dependency 'org.sonarsource.xml:sonar-xml-plugin:2.2.0.2973'
  173. // please keep this list alphabetically ordered
  174. dependencySet(group: 'ch.qos.logback', version: '1.2.3') {
  175. entry 'logback-access'
  176. entry 'logback-classic'
  177. entry 'logback-core'
  178. }
  179. dependency('commons-beanutils:commons-beanutils:1.8.3') {
  180. exclude 'commons-logging:commons-logging'
  181. }
  182. dependency 'commons-codec:commons-codec:1.14'
  183. dependency 'commons-dbutils:commons-dbutils:1.7'
  184. dependency 'commons-io:commons-io:2.8.0'
  185. dependency 'commons-lang:commons-lang:2.6'
  186. imports { mavenBom 'com.fasterxml.jackson:jackson-bom:2.13.2.20220328' }
  187. dependency 'com.eclipsesource.minimal-json:minimal-json:0.9.5'
  188. dependencySet(group: 'com.github.scribejava', version: '6.9.0') {
  189. entry 'scribejava-apis'
  190. entry 'scribejava-core'
  191. }
  192. dependency 'com.github.everit-org.json-schema:org.everit.json.schema:1.12.2'
  193. // This project is no longer maintained and was forked
  194. // by https://github.com/java-diff-utils/java-diff-utils
  195. // (io.github.java-diff-utils:java-diff-utils).
  196. dependency 'com.googlecode.java-diff-utils:diffutils:1.2'
  197. dependency('com.googlecode.json-simple:json-simple:1.1.1') {
  198. exclude 'junit:junit'
  199. }
  200. dependency 'com.google.code.findbugs:jsr305:3.0.2'
  201. dependency 'com.google.code.gson:gson:2.9.0'
  202. dependency('com.google.guava:guava:28.2-jre') {
  203. exclude 'com.google.errorprone:error_prone_annotations'
  204. exclude 'com.google.guava:listenablefuture'
  205. exclude 'com.google.j2objc:j2objc-annotations'
  206. exclude 'org.checkerframework:checker-qual'
  207. exclude 'org.codehaus.mojo:animal-sniffer-annotations'
  208. }
  209. dependency "com.google.protobuf:protobuf-java:${protobufVersion}"
  210. // Do not upgrade H2 to 1.4.200 because of instability: https://github.com/h2database/h2database/issues/2205
  211. dependency 'com.h2database:h2:1.4.199'
  212. dependencySet(group: 'com.hazelcast', version: '4.2') {
  213. entry 'hazelcast'
  214. }
  215. dependency 'com.ibm.icu:icu4j:3.4.4'
  216. dependency 'com.microsoft.sqlserver:mssql-jdbc:9.2.0.jre11'
  217. dependency 'com.oracle.database.jdbc:ojdbc8:19.3.0.0'
  218. // upgrade okhttp3 dependency kotlin to get rid of not exploitable CVE-2020-29582
  219. dependency 'org.jetbrains.kotlin:kotlin-stdlib-common:1.4.21'
  220. dependency 'org.jetbrains.kotlin:kotlin-stdlib:1.4.21'
  221. dependencySet(group: 'com.squareup.okhttp3', version: '4.9.0') {
  222. entry 'okhttp'
  223. entry 'mockwebserver'
  224. }
  225. dependency 'com.tngtech.java:junit-dataprovider:1.13.1'
  226. dependency 'info.picocli:picocli:3.6.1'
  227. dependencySet(group: 'io.jsonwebtoken', version: '0.11.2') {
  228. entry 'jjwt-api'
  229. entry 'jjwt-impl'
  230. entry 'jjwt-jackson'
  231. }
  232. dependency 'com.auth0:java-jwt:3.10.3'
  233. dependency 'io.netty:netty-all:4.1.48.Final'
  234. dependency 'com.sun.mail:javax.mail:1.5.6'
  235. dependency 'javax.annotation:javax.annotation-api:1.3.2'
  236. dependency 'javax.servlet:javax.servlet-api:3.1.0'
  237. dependency 'javax.xml.bind:jaxb-api:2.3.0'
  238. dependency 'junit:junit:4.13.1'
  239. dependency 'org.junit.jupiter:junit-jupiter-api:5.6.0'
  240. dependency 'org.xmlunit:xmlunit-core:2.6.4'
  241. dependency 'org.xmlunit:xmlunit-matchers:2.6.4'
  242. dependency 'net.jpountz.lz4:lz4:1.3.0'
  243. dependency 'net.lightbody.bmp:littleproxy:1.1.0-beta-bmp-17'
  244. dependency 'org.awaitility:awaitility:4.0.2'
  245. dependency 'org.apache.commons:commons-csv:1.7'
  246. dependency 'org.apache.commons:commons-email:1.5'
  247. dependency 'org.apache.commons:commons-dbcp2:2.7.0'
  248. dependency('org.apache.httpcomponents:httpclient:4.5.13'){
  249. exclude 'commons-logging:commons-logging'
  250. }
  251. // Be aware that Log4j is used by Elasticsearch client
  252. dependencySet(group: 'org.apache.logging.log4j', version: '2.17.0') {
  253. entry 'log4j-core'
  254. entry 'log4j-api'
  255. entry 'log4j-to-slf4j'
  256. }
  257. dependencySet(group: 'org.apache.tomcat.embed', version: '8.5.68') {
  258. entry 'tomcat-embed-core'
  259. entry('tomcat-embed-jasper') {
  260. exclude 'org.eclipse.jdt.core.compiler:ecj'
  261. }
  262. }
  263. dependency 'org.assertj:assertj-core:3.15.0'
  264. dependency 'org.assertj:assertj-guava:3.3.0'
  265. dependency('org.codehaus.sonar:sonar-channel:4.2') {
  266. exclude 'org.slf4j:slf4j-api'
  267. }
  268. dependency 'org.codehaus.sonar:sonar-classloader:1.0'
  269. dependency('org.codehaus.woodstox:woodstox-core-lgpl:4.4.1') {
  270. exclude 'javax.xml.stream:stax-api'
  271. }
  272. dependency('org.codehaus.staxmate:staxmate:2.0.1') {
  273. exclude 'org.codehaus.woodstox:stax2-api'
  274. exclude 'stax:stax-api'
  275. exclude 'org.codehaus.woodstox:woodstox-core-asl'
  276. }
  277. dependency('org.codehaus.woodstox:stax2-api:3.1.4') {
  278. exclude 'stax:stax-api'
  279. }
  280. dependencySet(group: 'org.eclipse.jetty', version: '9.4.6.v20170531') {
  281. entry 'jetty-proxy'
  282. entry 'jetty-server'
  283. entry 'jetty-servlet'
  284. }
  285. dependency('org.elasticsearch.client:elasticsearch-rest-high-level-client:7.16.0') {
  286. exclude 'org.apache.logging.log4j:log4j-core'
  287. }
  288. dependency 'org.elasticsearch.plugin:transport-netty4-client:7.16.0'
  289. dependency 'org.elasticsearch:mocksocket:1.0'
  290. dependency 'org.codelibs.elasticsearch.module:analysis-common:7.16.0'
  291. dependency 'org.codelibs.elasticsearch.module:reindex:7.16.0'
  292. dependency 'org.eclipse.jgit:org.eclipse.jgit:5.9.0.202009080501-r'
  293. dependency 'org.tmatesoft.svnkit:svnkit:1.10.1'
  294. dependency 'org.hamcrest:hamcrest-all:1.3'
  295. dependency 'org.jsoup:jsoup:1.13.1'
  296. dependency 'org.mindrot:jbcrypt:0.4'
  297. dependency('org.mockito:mockito-core:3.3.3') {
  298. exclude 'org.hamcrest:hamcrest-core'
  299. }
  300. dependency 'org.mybatis:mybatis:3.5.6'
  301. dependency 'org.nanohttpd:nanohttpd:2.3.1'
  302. dependency 'org.picocontainer:picocontainer:2.15'
  303. dependencySet(group: 'org.slf4j', version: '1.7.30') {
  304. entry 'jcl-over-slf4j'
  305. entry 'jul-to-slf4j'
  306. entry 'log4j-over-slf4j'
  307. entry 'slf4j-api'
  308. }
  309. dependency 'org.postgresql:postgresql:42.3.3'
  310. dependency 'org.reflections:reflections:0.9.12'
  311. dependency 'org.simpleframework:simple:4.1.21'
  312. dependency 'org.sonarsource.orchestrator:sonar-orchestrator:3.35.1.2719'
  313. dependency 'org.sonarsource.update-center:sonar-update-center-common:1.23.0.723'
  314. dependency 'org.subethamail:subethasmtp:3.1.7'
  315. dependency 'org.yaml:snakeyaml:1.26'
  316. dependency 'xml-apis:xml-apis:1.4.01'
  317. // please keep this list alphabetically ordered
  318. }
  319. }
  320. // global exclusions
  321. configurations.all {
  322. // do not conflict with com.sun.mail:javax.mail
  323. exclude group: 'javax.mail', module: 'mail'
  324. }
  325. tasks.withType(JavaCompile) {
  326. options.compilerArgs.addAll(['--release', '8'])
  327. options.encoding = 'UTF-8'
  328. }
  329. tasks.withType(Javadoc) {
  330. options.addStringOption('Xdoclint:none', '-quiet')
  331. options.encoding = 'UTF-8'
  332. title = project.name + ' ' + versionWithoutBuildNumber
  333. }
  334. task sourcesJar(type: Jar, dependsOn: classes) {
  335. classifier = 'sources'
  336. from sourceSets.main.allSource
  337. }
  338. task javadocJar(type: Jar, dependsOn: javadoc) {
  339. classifier = 'javadoc'
  340. from javadoc.destinationDir
  341. }
  342. // generate code before opening project in IDE (Eclipse or Intellij)
  343. task ide() {
  344. // empty by default. Dependencies are added to the task
  345. // when needed (see protobuf modules for example)
  346. }
  347. jacocoTestReport {
  348. reports {
  349. xml.enabled true
  350. csv.enabled false
  351. html.enabled false
  352. }
  353. }
  354. normalization {
  355. runtimeClasspath {
  356. // Following classpath resources contain volatile data that changes in each CI build (build number, commit id, time),
  357. // so we exclude them from calculation of build cache key of test tasks:
  358. ignore 'META-INF/MANIFEST.MF'
  359. ignore 'sonar-api-version.txt'
  360. ignore 'sq-version.txt'
  361. }
  362. }
  363. ext.failedTests = []
  364. test {
  365. jvmArgs '-Dfile.encoding=UTF8'
  366. maxHeapSize = '1G'
  367. systemProperty 'java.awt.headless', true
  368. testLogging {
  369. events "skipped", "failed" // verbose log for failed and skipped tests (by default the name of the tests are not logged)
  370. exceptionFormat 'full' // log the full stack trace (default is the 1st line of the stack trace)
  371. }
  372. jacoco {
  373. enabled = true // do not disable recording of code coverage, so that remote Gradle cache entry can be used locally
  374. includes = ['com.sonar.*', 'com.sonarsource.*', 'org.sonar.*', 'org.sonarqube.*', 'org.sonarsource.*']
  375. }
  376. if (project.hasProperty('maxParallelTests')) {
  377. maxParallelForks = project.maxParallelTests as int
  378. }
  379. if (project.hasProperty('parallelTests')) {
  380. // See https://guides.gradle.org/performance/#parallel_test_execution
  381. maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
  382. }
  383. afterTest { descriptor, result ->
  384. if (result.resultType == TestResult.ResultType.FAILURE) {
  385. String failedTest = " ${descriptor.className} > ${descriptor.name}"
  386. failedTests << failedTest
  387. }
  388. }
  389. }
  390. gradle.buildFinished {
  391. if (!failedTests.empty) {
  392. println "\nFailed tests:"
  393. failedTests.each { failedTest ->
  394. println failedTest
  395. }
  396. println ""
  397. }
  398. }
  399. def protoMainSrc = 'src/main/protobuf'
  400. def protoTestSrc = 'src/test/protobuf'
  401. if (file(protoMainSrc).exists() || file(protoTestSrc).exists()) {
  402. // protobuf must be applied after java
  403. apply plugin: 'com.google.protobuf'
  404. sourceSets.main.proto.srcDir protoMainSrc // in addition to the default 'src/main/proto'
  405. sourceSets.test.proto.srcDir protoTestSrc // in addition to the default 'src/test/proto'
  406. protobuf {
  407. protoc {
  408. artifact = "com.google.protobuf:protoc:${protobufVersion}"
  409. }
  410. }
  411. jar {
  412. exclude('**/*.proto')
  413. }
  414. idea {
  415. module {
  416. sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java")
  417. testSourceDirs += file("${protobuf.generatedFilesBaseDir}/test/java")
  418. generatedSourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java")
  419. generatedSourceDirs += file("${protobuf.generatedFilesBaseDir}/test/java")
  420. }
  421. }
  422. ide.dependsOn(['generateProto', 'generateTestProto'])
  423. }
  424. if (file('package.json').exists()) {
  425. apply plugin: 'com.github.node-gradle.node'
  426. node {
  427. version = '10.22.1'
  428. yarnVersion = '1.22.0'
  429. download = true
  430. }
  431. }
  432. if (official) {
  433. jar {
  434. // do not break incremental build on non official versions
  435. manifest {
  436. attributes(
  437. 'Version': "${version}",
  438. 'Implementation-Build': System.getenv('GIT_SHA1'),
  439. 'Build-Time': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  440. )
  441. }
  442. }
  443. }
  444. license {
  445. header = rootProject.file('HEADER')
  446. encoding = 'UTF-8'
  447. strictCheck true
  448. mapping {
  449. java = 'SLASHSTAR_STYLE'
  450. js = 'SLASHSTAR_STYLE'
  451. ts = 'SLASHSTAR_STYLE'
  452. tsx = 'SLASHSTAR_STYLE'
  453. css = 'SLASHSTAR_STYLE'
  454. }
  455. includes(['**/*.java', '**/*.js', '**/*.ts', '**/*.tsx', '**/*.css'])
  456. }
  457. tasks.withType(GenerateModuleMetadata) {
  458. enabled = false
  459. }
  460. publishing {
  461. publications {
  462. mavenJava(MavenPublication) {
  463. pom {
  464. name = 'SonarQube'
  465. description = project.description
  466. url = 'http://www.sonarqube.org/'
  467. organization {
  468. name = 'SonarSource'
  469. url = 'http://www.sonarsource.com'
  470. }
  471. licenses {
  472. license {
  473. name = 'GNU LGPL 3'
  474. url = 'http://www.gnu.org/licenses/lgpl.txt'
  475. distribution = 'repo'
  476. }
  477. }
  478. scm {
  479. url = 'https://github.com/SonarSource/sonarqube'
  480. }
  481. developers {
  482. developer {
  483. id = 'sonarsource-team'
  484. name = 'SonarSource Team'
  485. }
  486. }
  487. }
  488. }
  489. }
  490. }
  491. signing {
  492. def signingKeyId = findProperty("signingKeyId")
  493. def signingKey = findProperty("signingKey")
  494. def signingPassword = findProperty("signingPassword")
  495. useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
  496. required {
  497. def branch = System.getenv()["CIRRUS_BRANCH"]
  498. return (branch == 'master' || branch ==~ 'branch-[\\d.]+') &&
  499. gradle.taskGraph.hasTask(":artifactoryPublish")
  500. }
  501. sign publishing.publications
  502. }
  503. tasks.withType(Sign) {
  504. onlyIf {
  505. def branch = System.getenv()["CIRRUS_BRANCH"]
  506. return !artifactoryPublish.skip &&
  507. (branch == 'master' || branch ==~ 'branch-[\\d.]+') &&
  508. gradle.taskGraph.hasTask(":artifactoryPublish")
  509. }
  510. }
  511. }
  512. // Yarn doesn't support concurrent access to its global cache,
  513. // i.e. parallel execution of several "yarn install" tasks,
  514. // since these tasks are independent, we can establish arbitrary total order
  515. // to prevent their concurrent execution.
  516. // Note that "task1.mustRunAfter(task2)" ordering has an effect only when both
  517. // tasks are scheduled for execution, therefore should be established between
  518. // all pairs of "yarn install" tasks to define their total order and to prevent
  519. // their concurrent execution even in case when one or more of these tasks not
  520. // scheduled.
  521. def yarnInstallTasks = allprojects.findResults { it -> it.tasks.findByName('yarn') }
  522. yarnInstallTasks.drop(1).eachWithIndex { it, i -> it.mustRunAfter(yarnInstallTasks[0..i]) }
  523. // by default, Yarn will update lock file if it is not up to date with "package.json"
  524. // using option "--frozen-lockfile" will disable this behavior and "yarn install" will fail if lock file is out of date
  525. // all "yarn install" tasks should be executed with this option for reproducibility of builds
  526. // and to prevent developers from forgetting to update lock file when they update "package.json"
  527. yarnInstallTasks.each { it -> it.args = ['--frozen-lockfile'] }
  528. // https://github.com/ben-manes/gradle-versions-plugin
  529. apply plugin: 'com.github.ben-manes.versions'
  530. dependencyUpdates {
  531. rejectVersionIf {
  532. // Exclude dev versions from the list of dependency upgrades, for
  533. // example to replace:
  534. // org.slf4j:log4j-over-slf4j [1.7.25 -> 1.8.0-beta4]
  535. // by
  536. // org.slf4j:log4j-over-slf4j [1.7.25 -> 1.7.26]
  537. boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm', 'preview', 'jre12'].any { qualifier ->
  538. it.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-]*/
  539. }
  540. // Exclude upgrades on new major versions :
  541. // com.hazelcast:hazelcast [3.12.3 -> 4.0.0]
  542. rejected |= !it.candidate.version.substring(0, 2).equals(it.currentVersion.substring(0, 2))
  543. rejected
  544. }
  545. }