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

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