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