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

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