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

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