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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  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.30.1'
  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.6.1" 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.2.10') {
  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.2') {
  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'
  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.2.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.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.5') {
  248. entry 'jjwt-api'
  249. entry 'jjwt-impl'
  250. entry 'jjwt-jackson'
  251. }
  252. dependency 'com.auth0:java-jwt:4.2.1'
  253. dependency 'io.netty:netty-all:4.1.86.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.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.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.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:4.10.0') {
  309. exclude 'org.hamcrest:hamcrest-core'
  310. }
  311. dependency('org.mockito:mockito-inline:4.10.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.36') {
  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.1'
  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. title = project.name + ' ' + versionWithoutBuildNumber
  342. }
  343. task sourcesJar(type: Jar, dependsOn: classes) {
  344. archiveClassifier = 'sources'
  345. from sourceSets.main.allSource
  346. }
  347. task javadocJar(type: Jar, dependsOn: javadoc) {
  348. archiveClassifier = 'javadoc'
  349. from javadoc.destinationDir
  350. }
  351. // generate code before opening project in IDE (Eclipse or Intellij)
  352. task ide() {
  353. // empty by default. Dependencies are added to the task
  354. // when needed (see protobuf modules for example)
  355. }
  356. jacocoTestReport {
  357. reports {
  358. xml.required = true
  359. csv.required = false
  360. html.required = false
  361. }
  362. }
  363. normalization {
  364. runtimeClasspath {
  365. // Following classpath resources contain volatile data that changes in each CI build (build number, commit id, time),
  366. // so we exclude them from calculation of build cache key of test tasks:
  367. ignore 'META-INF/MANIFEST.MF'
  368. ignore 'sonar-api-version.txt'
  369. ignore 'sq-version.txt'
  370. }
  371. }
  372. ext.failedTests = []
  373. test {
  374. jvmArgs '-Dfile.encoding=UTF8'
  375. maxHeapSize = '1G'
  376. systemProperty 'java.awt.headless', true
  377. testLogging {
  378. events "skipped", "failed" // verbose log for failed and skipped tests (by default the name of the tests are not logged)
  379. exceptionFormat 'full' // log the full stack trace (default is the 1st line of the stack trace)
  380. }
  381. jacoco {
  382. enabled = true // do not disable recording of code coverage, so that remote Gradle cache entry can be used locally
  383. includes = ['com.sonar.*', 'com.sonarsource.*', 'org.sonar.*', 'org.sonarqube.*', 'org.sonarsource.*']
  384. }
  385. if (project.hasProperty('maxParallelTests')) {
  386. maxParallelForks = project.maxParallelTests as int
  387. }
  388. if (project.hasProperty('parallelTests')) {
  389. // See https://guides.gradle.org/performance/#parallel_test_execution
  390. maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
  391. }
  392. afterTest { descriptor, result ->
  393. if (result.resultType == TestResult.ResultType.FAILURE) {
  394. String failedTest = " ${descriptor.className} > ${descriptor.name}"
  395. failedTests << failedTest
  396. }
  397. }
  398. }
  399. gradle.buildFinished {
  400. if (!failedTests.empty) {
  401. println "\nFailed tests:"
  402. failedTests.each { failedTest ->
  403. println failedTest
  404. }
  405. println ""
  406. }
  407. }
  408. def protoMainSrc = 'src/main/protobuf'
  409. def protoTestSrc = 'src/test/protobuf'
  410. if (file(protoMainSrc).exists() || file(protoTestSrc).exists()) {
  411. // protobuf must be applied after java
  412. apply plugin: 'com.google.protobuf'
  413. sourceSets.main.proto.srcDir protoMainSrc // in addition to the default 'src/main/proto'
  414. sourceSets.test.proto.srcDir protoTestSrc // in addition to the default 'src/test/proto'
  415. protobuf {
  416. protoc {
  417. artifact = "com.google.protobuf:protoc:${protobufVersion}"
  418. }
  419. }
  420. jar {
  421. exclude('**/*.proto')
  422. }
  423. idea {
  424. module {
  425. sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java")
  426. testSourceDirs += file("${protobuf.generatedFilesBaseDir}/test/java")
  427. generatedSourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java")
  428. generatedSourceDirs += file("${protobuf.generatedFilesBaseDir}/test/java")
  429. }
  430. }
  431. ide.dependsOn(['generateProto', 'generateTestProto'])
  432. }
  433. if (official) {
  434. jar {
  435. // do not break incremental build on non official versions
  436. manifest {
  437. attributes(
  438. 'Version': "${version}",
  439. 'Implementation-Build': System.getenv('GIT_SHA1'),
  440. 'Build-Time': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  441. )
  442. }
  443. }
  444. }
  445. license {
  446. header = rootProject.file('HEADER')
  447. strictCheck true
  448. encoding = 'UTF-8'
  449. mapping {
  450. java = 'SLASHSTAR_STYLE'
  451. js = 'SLASHSTAR_STYLE'
  452. ts = 'SLASHSTAR_STYLE'
  453. tsx = 'SLASHSTAR_STYLE'
  454. css = 'SLASHSTAR_STYLE'
  455. }
  456. includes(['**/*.java', '**/*.js', '**/*.ts', '**/*.tsx', '**/*.css'])
  457. }
  458. tasks.withType(GenerateModuleMetadata) {
  459. enabled = false
  460. }
  461. publishing {
  462. publications {
  463. mavenJava(MavenPublication) {
  464. pom {
  465. name = 'SonarQube'
  466. description = project.description
  467. url = 'http://www.sonarqube.org/'
  468. organization {
  469. name = 'SonarSource'
  470. url = 'http://www.sonarsource.com'
  471. }
  472. licenses {
  473. license {
  474. name = 'GNU LGPL 3'
  475. url = 'http://www.gnu.org/licenses/lgpl.txt'
  476. distribution = 'repo'
  477. }
  478. }
  479. scm {
  480. url = 'https://github.com/SonarSource/sonarqube'
  481. }
  482. developers {
  483. developer {
  484. id = 'sonarsource-team'
  485. name = 'SonarSource Team'
  486. }
  487. }
  488. }
  489. }
  490. }
  491. }
  492. if (isNightlyBuild) {
  493. tasks.withType(Test) {
  494. configurations {
  495. utMonitoring
  496. }
  497. dependencies {
  498. testImplementation project(":ut-monitoring")
  499. utMonitoring 'org.aspectj:aspectjweaver:1.9.9.1'
  500. }
  501. doFirst {
  502. ext {
  503. aspectJWeaver = configurations.utMonitoring.resolvedConfiguration.resolvedArtifacts.find { it.name == 'aspectjweaver' }
  504. }
  505. jvmArgs "-javaagent:${aspectJWeaver.file}"
  506. }
  507. }
  508. }
  509. signing {
  510. def signingKeyId = findProperty("signingKeyId")
  511. def signingKey = findProperty("signingKey")
  512. def signingPassword = findProperty("signingPassword")
  513. useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
  514. required {
  515. return isMainBranch && gradle.taskGraph.hasTask(":artifactoryPublish")
  516. }
  517. sign publishing.publications
  518. }
  519. tasks.withType(Sign) {
  520. onlyIf {
  521. return !artifactoryPublish.skip && isMainBranch && gradle.taskGraph.hasTask(":artifactoryPublish")
  522. }
  523. }
  524. }
  525. gradle.projectsEvaluated { gradle ->
  526. // yarn_run tasks can't all run in parallel without random issues
  527. // this script ensure all yarn_run tasks run sequentially
  528. def yarnRunTasks = allprojects.findResults { it -> it.tasks.findByName('yarn_run') }
  529. yarnRunTasks.drop(1).eachWithIndex { it, i -> it.mustRunAfter(yarnRunTasks[0..i]) }
  530. }
  531. ext.osAdaptiveCommand = { commands ->
  532. def newCommands = []
  533. if (System.properties['os.name'].toLowerCase().contains('windows')) {
  534. newCommands = ['cmd', '/c']
  535. }
  536. newCommands.addAll(commands)
  537. return newCommands
  538. }
  539. tasks.named('sonarqube') {
  540. long taskStart
  541. doFirst {
  542. taskStart = System.currentTimeMillis()
  543. }
  544. doLast {
  545. long taskDuration = System.currentTimeMillis() - taskStart
  546. File outputFile = new File("/tmp/analysis-monitoring.log")
  547. outputFile.append(JsonOutput.toJson([category: "Analysis", suite: "Standalone", operation: "total", duration: taskDuration]) + '\n')
  548. }
  549. }