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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  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. dependency 'com.eclipsesource.minimal-json:minimal-json:0.9.5'
  181. dependencySet(group: 'com.github.scribejava', version: '8.3.1') {
  182. entry 'scribejava-apis'
  183. entry 'scribejava-core'
  184. }
  185. dependency 'com.github.everit-org.json-schema:org.everit.json.schema:1.14.0'
  186. // This project is no longer maintained and was forked
  187. // by https://github.com/java-diff-utils/java-diff-utils
  188. // (io.github.java-diff-utils:java-diff-utils).
  189. dependency 'com.googlecode.java-diff-utils:diffutils:1.3.0'
  190. dependency('com.googlecode.json-simple:json-simple:1.1.1') {
  191. exclude 'junit:junit'
  192. }
  193. dependency 'io.prometheus:simpleclient:0.15.0'
  194. dependency 'io.prometheus:simpleclient_common:0.15.0'
  195. dependency 'io.prometheus:simpleclient_servlet:0.15.0'
  196. dependency 'com.google.code.findbugs:jsr305:3.0.2'
  197. dependency 'com.google.code.gson:gson:2.9.0'
  198. dependency('com.google.guava:guava:31.1-jre') {
  199. exclude 'com.google.errorprone:error_prone_annotations'
  200. exclude 'com.google.guava:listenablefuture'
  201. exclude 'com.google.j2objc:j2objc-annotations'
  202. exclude 'org.checkerframework:checker-qual'
  203. exclude 'org.codehaus.mojo:animal-sniffer-annotations'
  204. }
  205. dependency "com.google.protobuf:protobuf-java:${protobufVersion}"
  206. dependency 'com.h2database:h2:2.1.210'
  207. dependencySet(group: 'com.hazelcast', version: '4.2.4') {
  208. entry 'hazelcast'
  209. }
  210. dependency 'com.hazelcast:hazelcast-kubernetes:2.2.3'
  211. // Documentation must be updated if mssql-jdbc is updated: https://github.com/SonarSource/sonarqube/commit/03e4773ebf6cba854cdcf57a600095f65f4f53e7
  212. dependency 'com.microsoft.sqlserver:mssql-jdbc:9.4.1.jre11'
  213. dependency 'com.oracle.database.jdbc:ojdbc8:21.5.0.0'
  214. dependency 'org.aspectj:aspectjtools:1.9.9.1'
  215. // upgrade okhttp3 dependency kotlin to get rid of not exploitable CVE-2020-29582
  216. dependency 'org.jetbrains.kotlin:kotlin-stdlib-common:1.6.20'
  217. dependency 'org.jetbrains.kotlin:kotlin-stdlib:1.6.20'
  218. dependencySet(group: 'com.squareup.okhttp3', version: '4.9.3') {
  219. entry 'okhttp'
  220. entry 'mockwebserver'
  221. }
  222. dependency 'org.json:json:20220320'
  223. dependency 'com.tngtech.java:junit-dataprovider:1.13.1'
  224. dependencySet(group: 'io.jsonwebtoken', version: '0.11.2') {
  225. entry 'jjwt-api'
  226. entry 'jjwt-impl'
  227. entry 'jjwt-jackson'
  228. }
  229. dependency 'com.auth0:java-jwt:3.19.1'
  230. dependency 'io.netty:netty-all:4.1.75.Final'
  231. dependency 'com.sun.mail:javax.mail:1.6.2'
  232. dependency 'javax.annotation:javax.annotation-api:1.3.2'
  233. dependency 'javax.inject:javax.inject:1'
  234. dependency 'javax.servlet:javax.servlet-api:4.0.1'
  235. dependency 'javax.xml.bind:jaxb-api:2.3.1'
  236. dependency 'junit:junit:4.13.2'
  237. dependency 'org.junit.jupiter:junit-jupiter-api:5.8.2'
  238. dependency 'org.xmlunit:xmlunit-core:2.9.0'
  239. dependency 'org.xmlunit:xmlunit-matchers:2.9.0'
  240. dependency 'net.jpountz.lz4:lz4:1.3.0'
  241. dependency 'net.lightbody.bmp:littleproxy:1.1.0-beta-bmp-17'
  242. dependency 'org.awaitility:awaitility:4.2.0'
  243. dependency 'org.apache.commons:commons-csv:1.9.0'
  244. dependency 'org.apache.commons:commons-email:1.5'
  245. dependency 'org.apache.commons:commons-dbcp2:2.9.0'
  246. dependency('org.apache.httpcomponents:httpclient:4.5.13'){
  247. exclude 'commons-logging:commons-logging'
  248. }
  249. // Be aware that Log4j is used by Elasticsearch client
  250. dependencySet(group: 'org.apache.logging.log4j', version: '2.17.1') {
  251. entry 'log4j-core'
  252. entry 'log4j-api'
  253. entry 'log4j-to-slf4j'
  254. }
  255. dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.62') {
  256. entry 'tomcat-embed-core'
  257. entry('tomcat-embed-jasper') {
  258. exclude 'org.eclipse.jdt.core.compiler:ecj'
  259. }
  260. }
  261. dependency 'org.assertj:assertj-core:3.22.0'
  262. dependency 'org.assertj:assertj-guava:3.4.0'
  263. dependency('org.codehaus.sonar:sonar-channel:4.2') {
  264. exclude 'org.slf4j:slf4j-api'
  265. }
  266. dependency 'org.codehaus.sonar:sonar-classloader:1.0'
  267. dependency 'com.fasterxml.staxmate:staxmate:2.4.0'
  268. dependencySet(group: 'org.eclipse.jetty', version: '9.4.6.v20170531') {
  269. entry 'jetty-proxy'
  270. entry 'jetty-server'
  271. entry 'jetty-servlet'
  272. }
  273. dependency('org.elasticsearch.client:elasticsearch-rest-high-level-client:7.17.2') {
  274. exclude 'org.apache.logging.log4j:log4j-core'
  275. }
  276. dependency 'org.elasticsearch.plugin:transport-netty4-client:7.17.2'
  277. dependency 'org.elasticsearch:mocksocket:1.2'
  278. dependency 'org.codelibs.elasticsearch.module:analysis-common:7.17.1'
  279. dependency 'org.codelibs.elasticsearch.module:reindex:7.17.1'
  280. dependency 'org.eclipse.jgit:org.eclipse.jgit:6.1.0.202203080745-r'
  281. dependency 'org.tmatesoft.svnkit:svnkit:1.10.5'
  282. dependency 'org.hamcrest:hamcrest-all:1.3'
  283. dependency 'org.jsoup:jsoup:1.14.3'
  284. dependency 'org.mindrot:jbcrypt:0.4'
  285. dependency('org.mockito:mockito-core:4.4.0') {
  286. exclude 'org.hamcrest:hamcrest-core'
  287. }
  288. dependency 'org.mybatis:mybatis:3.5.9'
  289. dependency 'org.nanohttpd:nanohttpd:2.3.1'
  290. dependencySet(group: 'org.slf4j', version: '1.7.30') {
  291. entry 'jcl-over-slf4j'
  292. entry 'jul-to-slf4j'
  293. entry 'log4j-over-slf4j'
  294. entry 'slf4j-api'
  295. }
  296. dependency 'org.postgresql:postgresql:42.3.3'
  297. dependency 'org.reflections:reflections:0.10.2'
  298. dependency 'org.simpleframework:simple:5.1.6'
  299. dependency 'org.sonarsource.orchestrator:sonar-orchestrator:3.37.0.87'
  300. dependency 'org.sonarsource.update-center:sonar-update-center-common:1.27.1.963'
  301. dependency('org.springframework:spring-context:5.3.18') {
  302. exclude 'commons-logging:commons-logging'
  303. }
  304. dependency 'org.subethamail:subethasmtp:3.1.7'
  305. dependency 'org.yaml:snakeyaml:1.30'
  306. // please keep this list alphabetically ordered
  307. }
  308. }
  309. // global exclusions
  310. configurations.all {
  311. // do not conflict with com.sun.mail:javax.mail
  312. exclude group: 'javax.mail', module: 'mail'
  313. }
  314. tasks.withType(Javadoc) {
  315. options.addStringOption('Xdoclint:none', '-quiet')
  316. options.encoding = 'UTF-8'
  317. doFirst {
  318. options.addBooleanOption('-no-module-directories', true)
  319. }
  320. title = project.name + ' ' + versionWithoutBuildNumber
  321. }
  322. task sourcesJar(type: Jar, dependsOn: classes) {
  323. archiveClassifier = 'sources'
  324. from sourceSets.main.allSource
  325. }
  326. task javadocJar(type: Jar, dependsOn: javadoc) {
  327. archiveClassifier = 'javadoc'
  328. from javadoc.destinationDir
  329. }
  330. // generate code before opening project in IDE (Eclipse or Intellij)
  331. task ide() {
  332. // empty by default. Dependencies are added to the task
  333. // when needed (see protobuf modules for example)
  334. }
  335. jacocoTestReport {
  336. reports {
  337. xml.required = true
  338. csv.required = false
  339. html.required = false
  340. }
  341. }
  342. normalization {
  343. runtimeClasspath {
  344. // Following classpath resources contain volatile data that changes in each CI build (build number, commit id, time),
  345. // so we exclude them from calculation of build cache key of test tasks:
  346. ignore 'META-INF/MANIFEST.MF'
  347. ignore 'sonar-api-version.txt'
  348. ignore 'sq-version.txt'
  349. }
  350. }
  351. ext.failedTests = []
  352. test {
  353. jvmArgs '-Dfile.encoding=UTF8'
  354. maxHeapSize = '1G'
  355. systemProperty 'java.awt.headless', true
  356. testLogging {
  357. events "skipped", "failed" // verbose log for failed and skipped tests (by default the name of the tests are not logged)
  358. exceptionFormat 'full' // log the full stack trace (default is the 1st line of the stack trace)
  359. }
  360. jacoco {
  361. enabled = true // do not disable recording of code coverage, so that remote Gradle cache entry can be used locally
  362. includes = ['com.sonar.*', 'com.sonarsource.*', 'org.sonar.*', 'org.sonarqube.*', 'org.sonarsource.*']
  363. }
  364. if (project.hasProperty('maxParallelTests')) {
  365. maxParallelForks = project.maxParallelTests as int
  366. }
  367. if (project.hasProperty('parallelTests')) {
  368. // See https://guides.gradle.org/performance/#parallel_test_execution
  369. maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
  370. }
  371. afterTest { descriptor, result ->
  372. if (result.resultType == TestResult.ResultType.FAILURE) {
  373. String failedTest = " ${descriptor.className} > ${descriptor.name}"
  374. failedTests << failedTest
  375. }
  376. }
  377. }
  378. gradle.buildFinished {
  379. if (!failedTests.empty) {
  380. println "\nFailed tests:"
  381. failedTests.each { failedTest ->
  382. println failedTest
  383. }
  384. println ""
  385. }
  386. }
  387. def protoMainSrc = 'src/main/protobuf'
  388. def protoTestSrc = 'src/test/protobuf'
  389. if (file(protoMainSrc).exists() || file(protoTestSrc).exists()) {
  390. // protobuf must be applied after java
  391. apply plugin: 'com.google.protobuf'
  392. sourceSets.main.proto.srcDir protoMainSrc // in addition to the default 'src/main/proto'
  393. sourceSets.test.proto.srcDir protoTestSrc // in addition to the default 'src/test/proto'
  394. protobuf {
  395. protoc {
  396. artifact = "com.google.protobuf:protoc:${protobufVersion}"
  397. }
  398. }
  399. jar {
  400. exclude('**/*.proto')
  401. }
  402. idea {
  403. module {
  404. sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java")
  405. testSourceDirs += file("${protobuf.generatedFilesBaseDir}/test/java")
  406. generatedSourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java")
  407. generatedSourceDirs += file("${protobuf.generatedFilesBaseDir}/test/java")
  408. }
  409. }
  410. ide.dependsOn(['generateProto', 'generateTestProto'])
  411. }
  412. if (official) {
  413. jar {
  414. // do not break incremental build on non official versions
  415. manifest {
  416. attributes(
  417. 'Version': "${version}",
  418. 'Implementation-Build': System.getenv('GIT_SHA1'),
  419. 'Build-Time': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  420. )
  421. }
  422. }
  423. }
  424. license {
  425. header = rootProject.file('HEADER')
  426. strictCheck true
  427. encoding = 'UTF-8'
  428. mapping {
  429. java = 'SLASHSTAR_STYLE'
  430. js = 'SLASHSTAR_STYLE'
  431. ts = 'SLASHSTAR_STYLE'
  432. tsx = 'SLASHSTAR_STYLE'
  433. css = 'SLASHSTAR_STYLE'
  434. }
  435. includes(['**/*.java', '**/*.js', '**/*.ts', '**/*.tsx', '**/*.css'])
  436. }
  437. tasks.withType(GenerateModuleMetadata) {
  438. enabled = false
  439. }
  440. publishing {
  441. publications {
  442. mavenJava(MavenPublication) {
  443. pom {
  444. name = 'SonarQube'
  445. description = project.description
  446. url = 'http://www.sonarqube.org/'
  447. organization {
  448. name = 'SonarSource'
  449. url = 'http://www.sonarsource.com'
  450. }
  451. licenses {
  452. license {
  453. name = 'GNU LGPL 3'
  454. url = 'http://www.gnu.org/licenses/lgpl.txt'
  455. distribution = 'repo'
  456. }
  457. }
  458. scm {
  459. url = 'https://github.com/SonarSource/sonarqube'
  460. }
  461. developers {
  462. developer {
  463. id = 'sonarsource-team'
  464. name = 'SonarSource Team'
  465. }
  466. }
  467. }
  468. }
  469. }
  470. }
  471. if (System.getenv('GITHUB_BRANCH') == "branch-nightly-build") {
  472. tasks.withType(Test) {
  473. configurations {
  474. utMonitoring
  475. }
  476. dependencies {
  477. testCompile project(":ut-monitoring")
  478. utMonitoring 'org.aspectj:aspectjweaver:1.9.9.1'
  479. }
  480. doFirst {
  481. ext {
  482. aspectJWeaver = configurations.utMonitoring.resolvedConfiguration.resolvedArtifacts.find { it.name == 'aspectjweaver' }
  483. }
  484. jvmArgs "-javaagent:${aspectJWeaver.file}"
  485. }
  486. }
  487. }
  488. signing {
  489. def signingKeyId = findProperty("signingKeyId")
  490. def signingKey = findProperty("signingKey")
  491. def signingPassword = findProperty("signingPassword")
  492. useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
  493. required {
  494. def branch = System.getenv()["GITHUB_BRANCH"]
  495. return (branch in ['master'] || branch ==~ 'branch-[\\d.]+') &&
  496. gradle.taskGraph.hasTask(":artifactoryPublish")
  497. }
  498. sign publishing.publications
  499. }
  500. tasks.withType(Sign) {
  501. onlyIf {
  502. def branch = System.getenv()["GITHUB_BRANCH"]
  503. return !artifactoryPublish.skip &&
  504. (branch in ['master'] || branch ==~ 'branch-[\\d.]+') &&
  505. gradle.taskGraph.hasTask(":artifactoryPublish")
  506. }
  507. }
  508. }
  509. gradle.projectsEvaluated { gradle ->
  510. // yarn_run tasks can't all run in parallel without random issues
  511. // this script ensure all yarn_run tasks run sequentially
  512. def yarnRunTasks = allprojects.findResults { it -> it.tasks.findByName('yarn_run') }
  513. yarnRunTasks.drop(1).eachWithIndex { it, i -> it.mustRunAfter(yarnRunTasks[0..i]) }
  514. }
  515. ext.osAdaptiveCommand = { commands ->
  516. def newCommands = []
  517. if (System.properties['os.name'].toLowerCase().contains('windows')) {
  518. newCommands = ['cmd', '/c']
  519. }
  520. newCommands.addAll(commands)
  521. return newCommands
  522. }
  523. tasks.named('sonarqube') {
  524. long taskStart
  525. doFirst {
  526. taskStart = System.currentTimeMillis()
  527. }
  528. doLast {
  529. long taskDuration = System.currentTimeMillis() - taskStart
  530. File outputFile = new File("/tmp/analysis-monitoring.log")
  531. outputFile.append(JsonOutput.toJson([category: "Analysis", suite: "Standalone", operation: "total", duration: taskDuration]) + '\n')
  532. }
  533. }