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

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