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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. import groovy.json.JsonOutput
  2. plugins {
  3. // Ordered alphabetically
  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.19' apply false
  8. id 'com.jfrog.artifactory' version '4.24.23'
  9. id "de.undercouch.download" version "5.0.1" apply false
  10. id 'io.spring.dependency-management' version '1.0.11.RELEASE'
  11. id "org.cyclonedx.bom" version "1.6.1" apply false
  12. id 'org.sonarqube' version '3.5.0.2730'
  13. }
  14. if (!JavaVersion.current().java11Compatible) {
  15. throw new GradleException("JDK 11+ is required to perform this build. It's currently " + System.getProperty("java.home") + ".")
  16. }
  17. /**
  18. * The BOM related tasks are disabled by default, activated by:
  19. * - running in the CI and being on a main branch or a nightly build,
  20. * - or using '-Dbom' project property
  21. * - or by explicit call to 'cyclonedxBom' Gradle task
  22. */
  23. def bomTasks = "cyclonedxBom"
  24. def ghBranch = System.getenv()["GITHUB_BRANCH"]
  25. def isMainBranch = ghBranch in ['master'] || ghBranch ==~ 'branch-[\\d.]+'
  26. def isNightlyBuild = ghBranch == "branch-nightly-build"
  27. boolean enableBom = System.getenv('CI') == "true" && (isMainBranch || isNightlyBuild) ||
  28. System.getProperty("bom") != null ||
  29. gradle.startParameter.taskNames.findAll({ it.matches(".*:($bomTasks)") })
  30. allprojects {
  31. apply plugin: 'com.jfrog.artifactory'
  32. apply plugin: 'maven-publish'
  33. ext.versionInSources = version
  34. ext.buildNumber = System.getProperty("buildNumber")
  35. // when no buildNumber is provided, then project version must end with '-SNAPSHOT'
  36. if (ext.buildNumber == null) {
  37. version = "${version}-SNAPSHOT".toString()
  38. ext.versionWithoutBuildNumber = version
  39. } else {
  40. ext.versionWithoutBuildNumber = version
  41. version = (version.toString().count('.') == 1 ? "${version}.0.${ext.buildNumber}" : "${version}.${ext.buildNumber}").toString()
  42. }
  43. ext {
  44. release = project.hasProperty('release') && project.getProperty('release')
  45. official = project.hasProperty('official') && project.getProperty('official')
  46. }
  47. ext.enableBom = enableBom
  48. if (!enableBom) {
  49. tasks.matching { it.name.matches(bomTasks) }.all({
  50. logger.info("{} disabled", it.name);
  51. it.enabled = false
  52. })
  53. }
  54. repositories {
  55. def repository = project.hasProperty('qa') ? 'sonarsource-qa' : 'sonarsource'
  56. maven {
  57. // The environment variables ARTIFACTORY_PRIVATE_USERNAME and ARTIFACTORY_PRIVATE_PASSWORD are used on QA env (Jenkins)
  58. // On local box, please add artifactoryUsername and artifactoryPassword to ~/.gradle/gradle.properties
  59. def artifactoryUsername = System.env.'ARTIFACTORY_PRIVATE_USERNAME' ?: (project.hasProperty('artifactoryUsername') ? project.getProperty('artifactoryUsername') : '')
  60. def artifactoryPassword = System.env.'ARTIFACTORY_PRIVATE_PASSWORD' ?: (project.hasProperty('artifactoryPassword') ? project.getProperty('artifactoryPassword') : '')
  61. if (artifactoryUsername && artifactoryPassword) {
  62. credentials {
  63. username artifactoryUsername
  64. password artifactoryPassword
  65. }
  66. } else {
  67. // Workaround for artifactory
  68. // https://www.jfrog.com/jira/browse/RTFACT-13797
  69. repository = 'public'
  70. }
  71. url "https://repox.jfrog.io/repox/${repository}"
  72. }
  73. }
  74. task allDependencies {
  75. dependsOn 'dependencies'
  76. }
  77. artifactory {
  78. clientConfig.setIncludeEnvVars(true)
  79. clientConfig.setEnvVarsExcludePatterns('*pass*,*psw*,*secret*,*MAVEN_CMD_LINE_ARGS*,sun.java.command,*token*,*login*,*key*,*signing*,*auth*,*pwd*')
  80. contextUrl = System.getenv('ARTIFACTORY_URL')
  81. publish {
  82. repository {
  83. repoKey = System.getenv('ARTIFACTORY_DEPLOY_REPO')
  84. username = System.getenv('ARTIFACTORY_DEPLOY_USERNAME') ?: project.properties.artifactoryUsername
  85. password = System.getenv('ARTIFACTORY_DEPLOY_PASSWORD') ?: project.properties.artifactoryPaswword
  86. }
  87. defaults {
  88. properties = [
  89. 'build.name': 'sonar-enterprise',
  90. 'build.number': System.getenv('BUILD_NUMBER'),
  91. 'pr.branch.target': System.getenv('GITHUB_BASE_BRANCH'),
  92. 'pr.number': System.getenv('PULL_REQUEST'),
  93. 'vcs.branch': ghBranch,
  94. 'vcs.revision': System.getenv('GIT_SHA1'),
  95. 'version': version
  96. ]
  97. publications('mavenJava')
  98. publishPom = true
  99. publishIvy = false
  100. }
  101. }
  102. clientConfig.info.setBuildName('sonar-enterprise')
  103. clientConfig.info.setBuildNumber(System.getenv('BUILD_NUMBER'))
  104. // Define the artifacts to be deployed to https://binaries.sonarsource.com on releases
  105. clientConfig.info.addEnvironmentProperty('ARTIFACTS_TO_PUBLISH',
  106. "${project.group}:sonar-application:zip," +
  107. "com.sonarsource.sonarqube:sonarqube-developer:zip," +
  108. "com.sonarsource.sonarqube:sonarqube-datacenter:zip," +
  109. "com.sonarsource.sonarqube:sonarqube-enterprise:zip")
  110. // The name of this variable is important because it's used by the delivery process when extracting version from Artifactory build info.
  111. clientConfig.info.addEnvironmentProperty('PROJECT_VERSION', "${version}")
  112. }
  113. }
  114. apply plugin: 'org.sonarqube'
  115. sonar {
  116. properties {
  117. property 'sonar.projectName', projectTitle
  118. property 'sonar.projectVersion', "${versionInSources}-SNAPSHOT"
  119. property 'sonar.buildString', version
  120. }
  121. }
  122. tasks.named('wrapper') {
  123. distributionType = Wrapper.DistributionType.ALL
  124. }
  125. subprojects {
  126. apply plugin: 'com.github.hierynomus.license'
  127. apply plugin: 'io.spring.dependency-management'
  128. apply plugin: 'jacoco'
  129. apply plugin: 'java-library'
  130. apply plugin: 'idea'
  131. apply plugin: 'signing'
  132. // do not deploy to Artifactory by default
  133. artifactoryPublish.skip = true
  134. compileJava.options.encoding = "UTF-8"
  135. compileTestJava.options.encoding = "UTF-8"
  136. def testFixtureSrc = 'src/testFixtures'
  137. if (file(testFixtureSrc).exists()) {
  138. apply plugin: 'java-test-fixtures'
  139. }
  140. ext {
  141. protobufVersion = '3.21.7'
  142. }
  143. sonar {
  144. properties {
  145. property 'sonar.moduleKey', project.group + ':' + project.name
  146. }
  147. }
  148. // Central place for definition dependency versions and exclusions.
  149. dependencyManagement {
  150. dependencies {
  151. // bundled plugin list -- keep it alphabetically ordered
  152. dependency 'com.sonarsource.abap:sonar-abap-plugin:3.11.0.4030'
  153. dependency 'com.sonarsource.cobol:sonar-cobol-plugin:5.1.1.5827'
  154. dependency 'com.sonarsource.cpp:sonar-cfamily-plugin:6.38.0.60268'
  155. dependency 'com.sonarsource.dbd:sonar-dbd-plugin:1.7.0.2417'
  156. dependency 'com.sonarsource.dbd:sonar-dbd-java-frontend-plugin:1.7.0.2417'
  157. dependency 'com.sonarsource.dbd:sonar-dbd-python-frontend-plugin:1.7.0.2417'
  158. dependency 'com.sonarsource.pli:sonar-pli-plugin:1.11.1.2727'
  159. dependency 'com.sonarsource.plsql:sonar-plsql-plugin:3.8.0.4948'
  160. dependency 'com.sonarsource.plugins.vb:sonar-vb-plugin:2.9.0.3341'
  161. dependency 'com.sonarsource.rpg:sonar-rpg-plugin:3.2.0.3034'
  162. dependency 'com.sonarsource.security:sonar-security-csharp-frontend-plugin:9.7.0.18030'
  163. dependency 'com.sonarsource.security:sonar-security-java-frontend-plugin:9.7.0.18030'
  164. dependency 'com.sonarsource.security:sonar-security-php-frontend-plugin:9.7.0.18030'
  165. dependency 'com.sonarsource.security:sonar-security-plugin:9.7.0.18030'
  166. dependency 'com.sonarsource.security:sonar-security-python-frontend-plugin:9.7.0.18030'
  167. dependency 'com.sonarsource.security:sonar-security-js-frontend-plugin:9.7.0.18030'
  168. dependency 'com.sonarsource.slang:sonar-apex-plugin:1.11.0.3905'
  169. dependency 'com.sonarsource.swift:sonar-swift-plugin:4.7.0.5624'
  170. dependency 'com.sonarsource.tsql:sonar-tsql-plugin:1.6.0.4844'
  171. dependency 'org.sonarsource.config:sonar-config-plugin:1.2.0.267'
  172. dependency 'org.sonarsource.dotnet:sonar-csharp-plugin:8.46.0.54807'
  173. dependency 'org.sonarsource.dotnet:sonar-vbnet-plugin:8.46.0.54807'
  174. dependency 'org.sonarsource.flex:sonar-flex-plugin:2.7.0.2865'
  175. dependency 'org.sonarsource.html:sonar-html-plugin:3.6.0.3106'
  176. dependency 'org.sonarsource.jacoco:sonar-jacoco-plugin:1.1.1.1157'
  177. dependency 'org.sonarsource.java:sonar-java-plugin:7.14.0.30229'
  178. dependency 'org.sonarsource.javascript:sonar-javascript-plugin:9.9.0.19492'
  179. dependency 'org.sonarsource.php:sonar-php-plugin:3.25.0.9077'
  180. dependency 'org.sonarsource.python:sonar-python-plugin:3.19.0.10254'
  181. dependency 'org.sonarsource.slang:sonar-go-plugin:1.11.0.3905'
  182. dependency 'org.sonarsource.kotlin:sonar-kotlin-plugin:2.10.0.1456'
  183. dependency 'org.sonarsource.slang:sonar-ruby-plugin:1.11.0.3905'
  184. dependency 'org.sonarsource.slang:sonar-scala-plugin:1.11.0.3905'
  185. dependency 'org.sonarsource.api.plugin:sonar-plugin-api:9.12.0.310'
  186. dependency 'org.sonarsource.xml:sonar-xml-plugin:2.6.1.3686'
  187. dependency 'org.sonarsource.iac:sonar-iac-plugin:1.9.2.2279'
  188. dependency 'org.sonarsource.text:sonar-text-plugin:1.1.0.282'
  189. // please keep this list alphabetically ordered
  190. dependencySet(group: 'ch.qos.logback', version: '1.2.9') {
  191. entry 'logback-access'
  192. entry 'logback-classic'
  193. entry 'logback-core'
  194. }
  195. dependency('commons-beanutils:commons-beanutils:1.9.4') {
  196. exclude 'commons-logging:commons-logging'
  197. }
  198. dependency 'commons-codec:commons-codec:1.15'
  199. dependency 'commons-dbutils:commons-dbutils:1.7'
  200. dependency 'commons-io:commons-io:2.11.0'
  201. dependency 'commons-lang:commons-lang:2.6'
  202. imports { mavenBom 'com.fasterxml.jackson:jackson-bom:2.13.4.20221013' }
  203. dependency 'com.eclipsesource.minimal-json:minimal-json:0.9.5'
  204. dependencySet(group: 'com.github.scribejava', version: '8.3.1') {
  205. entry 'scribejava-apis'
  206. entry 'scribejava-core'
  207. }
  208. dependency 'com.github.everit-org.json-schema:org.everit.json.schema:1.14.0'
  209. // This project is no longer maintained and was forked
  210. // by https://github.com/java-diff-utils/java-diff-utils
  211. // (io.github.java-diff-utils:java-diff-utils).
  212. dependency 'com.googlecode.java-diff-utils:diffutils:1.3.0'
  213. dependency('com.googlecode.json-simple:json-simple:1.1.1') {
  214. exclude 'junit:junit'
  215. }
  216. dependency 'io.prometheus:simpleclient:0.16.0'
  217. dependency 'io.prometheus:simpleclient_common:0.16.0'
  218. dependency 'io.prometheus:simpleclient_servlet:0.16.0'
  219. dependency 'com.google.code.findbugs:jsr305:3.0.2'
  220. dependency 'com.google.code.gson:gson:2.9.1'
  221. dependency('com.google.guava:guava:31.1-jre') {
  222. exclude 'com.google.errorprone:error_prone_annotations'
  223. exclude 'com.google.guava:listenablefuture'
  224. exclude 'com.google.j2objc:j2objc-annotations'
  225. exclude 'org.checkerframework:checker-qual'
  226. exclude 'org.codehaus.mojo:animal-sniffer-annotations'
  227. }
  228. dependency "com.google.protobuf:protobuf-java:${protobufVersion}"
  229. dependency 'com.h2database:h2:2.1.214'
  230. dependencySet(group: 'com.hazelcast', version: '4.2.4') {
  231. entry 'hazelcast'
  232. }
  233. dependency 'com.hazelcast:hazelcast-kubernetes:2.2.3'
  234. // Documentation must be updated if mssql-jdbc is updated: https://github.com/SonarSource/sonarqube/commit/03e4773ebf6cba854cdcf57a600095f65f4f53e7
  235. dependency('com.microsoft.sqlserver:mssql-jdbc:11.2.1.jre11') {
  236. exclude 'com.fasterxml.jackson.core:jackson-databind'
  237. }
  238. dependency 'com.onelogin:java-saml:2.9.0'
  239. dependency 'com.oracle.database.jdbc:ojdbc8:21.7.0.0'
  240. dependency 'org.aspectj:aspectjtools:1.9.9.1'
  241. dependencySet(group: 'com.squareup.okhttp3', version: '4.10.0') {
  242. entry 'okhttp'
  243. entry 'mockwebserver'
  244. }
  245. dependency 'org.json:json:20220924'
  246. dependency 'com.tngtech.java:junit-dataprovider:1.13.1'
  247. dependencySet(group: 'io.jsonwebtoken', version: '0.11.2') {
  248. entry 'jjwt-api'
  249. entry 'jjwt-impl'
  250. entry 'jjwt-jackson'
  251. }
  252. dependency 'com.auth0:java-jwt:4.1.0'
  253. dependency 'io.netty:netty-all:4.1.84.Final'
  254. dependency 'com.sun.mail:javax.mail:1.6.2'
  255. dependency 'javax.annotation:javax.annotation-api:1.3.2'
  256. dependency 'javax.inject:javax.inject:1'
  257. dependency 'javax.servlet:javax.servlet-api:4.0.1'
  258. dependency 'javax.xml.bind:jaxb-api:2.3.1'
  259. dependency 'junit:junit:4.13.2'
  260. dependency 'org.xmlunit:xmlunit-core:2.9.0'
  261. dependency 'org.xmlunit:xmlunit-matchers:2.9.0'
  262. dependency 'net.jpountz.lz4:lz4:1.3.0'
  263. dependency 'net.lightbody.bmp:littleproxy:1.1.0-beta-bmp-17'
  264. dependency 'org.awaitility:awaitility:4.2.0'
  265. dependency 'org.apache.commons:commons-csv:1.9.0'
  266. dependency 'org.apache.commons:commons-email:1.5'
  267. dependency 'com.zaxxer:HikariCP:5.0.1'
  268. dependency('org.apache.httpcomponents:httpclient:4.5.13'){
  269. exclude 'commons-logging:commons-logging'
  270. }
  271. // Be aware that Log4j is used by Elasticsearch client
  272. dependencySet(group: 'org.apache.logging.log4j', version: '2.17.1') {
  273. entry 'log4j-core'
  274. entry 'log4j-api'
  275. entry 'log4j-to-slf4j'
  276. }
  277. dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.62') {
  278. entry 'tomcat-embed-core'
  279. entry('tomcat-embed-jasper') {
  280. exclude 'org.eclipse.jdt.core.compiler:ecj'
  281. }
  282. }
  283. dependency 'org.assertj:assertj-core:3.23.1'
  284. dependency 'org.assertj:assertj-guava:3.5.0'
  285. dependency('org.codehaus.sonar:sonar-channel:4.2') {
  286. exclude 'org.slf4j:slf4j-api'
  287. }
  288. dependency 'org.codehaus.sonar:sonar-classloader:1.0'
  289. dependency 'com.fasterxml.staxmate:staxmate:2.4.0'
  290. dependencySet(group: 'org.eclipse.jetty', version: '9.4.6.v20170531') {
  291. entry 'jetty-proxy'
  292. entry 'jetty-server'
  293. entry 'jetty-servlet'
  294. }
  295. // "elasticsearchDownloadUrlFile" and "elasticsearchDownloadSha512" must also be updated in gradle.properties
  296. dependency('org.elasticsearch.client:elasticsearch-rest-high-level-client:7.17.6') {
  297. exclude 'org.apache.logging.log4j:log4j-core'
  298. }
  299. dependency 'org.elasticsearch.plugin:transport-netty4-client:7.17.6'
  300. dependency 'org.elasticsearch:mocksocket:1.2'
  301. dependency 'org.codelibs.elasticsearch.module:analysis-common:7.17.1'
  302. dependency 'org.codelibs.elasticsearch.module:reindex:7.17.1'
  303. dependency 'org.eclipse.jgit:org.eclipse.jgit:6.3.0.202209071007-r'
  304. dependency 'org.tmatesoft.svnkit:svnkit:1.10.8'
  305. dependency 'org.hamcrest:hamcrest-all:1.3'
  306. dependency 'org.jsoup:jsoup:1.15.3'
  307. dependency 'org.mindrot:jbcrypt:0.4'
  308. dependency('org.mockito:mockito-core:4.8.0') {
  309. exclude 'org.hamcrest:hamcrest-core'
  310. }
  311. dependency('org.mockito:mockito-inline:4.8.0')
  312. dependency 'org.mybatis:mybatis:3.5.11'
  313. dependency 'org.nanohttpd:nanohttpd:2.3.1'
  314. dependencySet(group: 'org.slf4j', version: '1.7.30') {
  315. entry 'jcl-over-slf4j'
  316. entry 'jul-to-slf4j'
  317. entry 'log4j-over-slf4j'
  318. entry 'slf4j-api'
  319. }
  320. dependency 'org.postgresql:postgresql:42.5.0'
  321. dependency 'org.reflections:reflections:0.10.2'
  322. dependency 'org.simpleframework:simple:5.1.6'
  323. dependency 'org.sonarsource.orchestrator:sonar-orchestrator:3.40.0.183'
  324. dependency 'org.sonarsource.update-center:sonar-update-center-common:1.29.0.1000'
  325. dependency('org.springframework:spring-context:5.3.23') {
  326. exclude 'commons-logging:commons-logging'
  327. }
  328. dependency 'org.subethamail:subethasmtp:3.1.7'
  329. dependency 'org.yaml:snakeyaml:1.33'
  330. // please keep this list alphabetically ordered
  331. }
  332. }
  333. // global exclusions
  334. configurations.all {
  335. // do not conflict with com.sun.mail:javax.mail
  336. exclude group: 'javax.mail', module: 'mail'
  337. }
  338. tasks.withType(Javadoc) {
  339. options.addStringOption('Xdoclint:none', '-quiet')
  340. options.encoding = 'UTF-8'
  341. doFirst {
  342. options.addBooleanOption('-no-module-directories', true)
  343. }
  344. title = project.name + ' ' + versionWithoutBuildNumber
  345. }
  346. task sourcesJar(type: Jar, dependsOn: classes) {
  347. archiveClassifier = 'sources'
  348. from sourceSets.main.allSource
  349. }
  350. task javadocJar(type: Jar, dependsOn: javadoc) {
  351. archiveClassifier = 'javadoc'
  352. from javadoc.destinationDir
  353. }
  354. // generate code before opening project in IDE (Eclipse or Intellij)
  355. task ide() {
  356. // empty by default. Dependencies are added to the task
  357. // when needed (see protobuf modules for example)
  358. }
  359. jacocoTestReport {
  360. reports {
  361. xml.required = true
  362. csv.required = false
  363. html.required = false
  364. }
  365. }
  366. normalization {
  367. runtimeClasspath {
  368. // Following classpath resources contain volatile data that changes in each CI build (build number, commit id, time),
  369. // so we exclude them from calculation of build cache key of test tasks:
  370. ignore 'META-INF/MANIFEST.MF'
  371. ignore 'sonar-api-version.txt'
  372. ignore 'sq-version.txt'
  373. }
  374. }
  375. ext.failedTests = []
  376. test {
  377. jvmArgs '-Dfile.encoding=UTF8'
  378. maxHeapSize = '1G'
  379. systemProperty 'java.awt.headless', true
  380. testLogging {
  381. events "skipped", "failed" // verbose log for failed and skipped tests (by default the name of the tests are not logged)
  382. exceptionFormat 'full' // log the full stack trace (default is the 1st line of the stack trace)
  383. }
  384. jacoco {
  385. enabled = true // do not disable recording of code coverage, so that remote Gradle cache entry can be used locally
  386. includes = ['com.sonar.*', 'com.sonarsource.*', 'org.sonar.*', 'org.sonarqube.*', 'org.sonarsource.*']
  387. }
  388. if (project.hasProperty('maxParallelTests')) {
  389. maxParallelForks = project.maxParallelTests as int
  390. }
  391. if (project.hasProperty('parallelTests')) {
  392. // See https://guides.gradle.org/performance/#parallel_test_execution
  393. maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
  394. }
  395. afterTest { descriptor, result ->
  396. if (result.resultType == TestResult.ResultType.FAILURE) {
  397. String failedTest = " ${descriptor.className} > ${descriptor.name}"
  398. failedTests << failedTest
  399. }
  400. }
  401. }
  402. gradle.buildFinished {
  403. if (!failedTests.empty) {
  404. println "\nFailed tests:"
  405. failedTests.each { failedTest ->
  406. println failedTest
  407. }
  408. println ""
  409. }
  410. }
  411. def protoMainSrc = 'src/main/protobuf'
  412. def protoTestSrc = 'src/test/protobuf'
  413. if (file(protoMainSrc).exists() || file(protoTestSrc).exists()) {
  414. // protobuf must be applied after java
  415. apply plugin: 'com.google.protobuf'
  416. sourceSets.main.proto.srcDir protoMainSrc // in addition to the default 'src/main/proto'
  417. sourceSets.test.proto.srcDir protoTestSrc // in addition to the default 'src/test/proto'
  418. protobuf {
  419. protoc {
  420. artifact = "com.google.protobuf:protoc:${protobufVersion}"
  421. }
  422. }
  423. jar {
  424. exclude('**/*.proto')
  425. }
  426. idea {
  427. module {
  428. sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java")
  429. testSourceDirs += file("${protobuf.generatedFilesBaseDir}/test/java")
  430. generatedSourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java")
  431. generatedSourceDirs += file("${protobuf.generatedFilesBaseDir}/test/java")
  432. }
  433. }
  434. ide.dependsOn(['generateProto', 'generateTestProto'])
  435. }
  436. if (official) {
  437. jar {
  438. // do not break incremental build on non official versions
  439. manifest {
  440. attributes(
  441. 'Version': "${version}",
  442. 'Implementation-Build': System.getenv('GIT_SHA1'),
  443. 'Build-Time': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  444. )
  445. }
  446. }
  447. }
  448. license {
  449. header = rootProject.file('HEADER')
  450. strictCheck true
  451. encoding = 'UTF-8'
  452. mapping {
  453. java = 'SLASHSTAR_STYLE'
  454. js = 'SLASHSTAR_STYLE'
  455. ts = 'SLASHSTAR_STYLE'
  456. tsx = 'SLASHSTAR_STYLE'
  457. css = 'SLASHSTAR_STYLE'
  458. }
  459. includes(['**/*.java', '**/*.js', '**/*.ts', '**/*.tsx', '**/*.css'])
  460. }
  461. tasks.withType(GenerateModuleMetadata) {
  462. enabled = false
  463. }
  464. publishing {
  465. publications {
  466. mavenJava(MavenPublication) {
  467. pom {
  468. name = 'SonarQube'
  469. description = project.description
  470. url = 'http://www.sonarqube.org/'
  471. organization {
  472. name = 'SonarSource'
  473. url = 'http://www.sonarsource.com'
  474. }
  475. licenses {
  476. license {
  477. name = 'GNU LGPL 3'
  478. url = 'http://www.gnu.org/licenses/lgpl.txt'
  479. distribution = 'repo'
  480. }
  481. }
  482. scm {
  483. url = 'https://github.com/SonarSource/sonarqube'
  484. }
  485. developers {
  486. developer {
  487. id = 'sonarsource-team'
  488. name = 'SonarSource Team'
  489. }
  490. }
  491. }
  492. }
  493. }
  494. }
  495. if (isNightlyBuild) {
  496. tasks.withType(Test) {
  497. configurations {
  498. utMonitoring
  499. }
  500. dependencies {
  501. testImplementation project(":ut-monitoring")
  502. utMonitoring 'org.aspectj:aspectjweaver:1.9.9.1'
  503. }
  504. doFirst {
  505. ext {
  506. aspectJWeaver = configurations.utMonitoring.resolvedConfiguration.resolvedArtifacts.find { it.name == 'aspectjweaver' }
  507. }
  508. jvmArgs "-javaagent:${aspectJWeaver.file}"
  509. }
  510. }
  511. }
  512. signing {
  513. def signingKeyId = findProperty("signingKeyId")
  514. def signingKey = findProperty("signingKey")
  515. def signingPassword = findProperty("signingPassword")
  516. useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
  517. required {
  518. return isMainBranch && gradle.taskGraph.hasTask(":artifactoryPublish")
  519. }
  520. sign publishing.publications
  521. }
  522. tasks.withType(Sign) {
  523. onlyIf {
  524. return !artifactoryPublish.skip && isMainBranch && gradle.taskGraph.hasTask(":artifactoryPublish")
  525. }
  526. }
  527. }
  528. gradle.projectsEvaluated { gradle ->
  529. // yarn_run tasks can't all run in parallel without random issues
  530. // this script ensure all yarn_run tasks run sequentially
  531. def yarnRunTasks = allprojects.findResults { it -> it.tasks.findByName('yarn_run') }
  532. yarnRunTasks.drop(1).eachWithIndex { it, i -> it.mustRunAfter(yarnRunTasks[0..i]) }
  533. }
  534. ext.osAdaptiveCommand = { commands ->
  535. def newCommands = []
  536. if (System.properties['os.name'].toLowerCase().contains('windows')) {
  537. newCommands = ['cmd', '/c']
  538. }
  539. newCommands.addAll(commands)
  540. return newCommands
  541. }
  542. tasks.named('sonarqube') {
  543. long taskStart
  544. doFirst {
  545. taskStart = System.currentTimeMillis()
  546. }
  547. doLast {
  548. long taskDuration = System.currentTimeMillis() - taskStart
  549. File outputFile = new File("/tmp/analysis-monitoring.log")
  550. outputFile.append(JsonOutput.toJson([category: "Analysis", suite: "Standalone", operation: "total", duration: taskDuration]) + '\n')
  551. }
  552. }