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 24KB

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