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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. buildscript {
  2. repositories {
  3. maven {
  4. url 'https://repox.jfrog.io/repox/plugins.gradle.org/'
  5. }
  6. }
  7. dependencies {
  8. // Ordered alphabeticly to avoid duplication
  9. classpath 'com.github.ben-manes:gradle-versions-plugin:0.21.0'
  10. classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
  11. classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.6'
  12. classpath 'com.moowork.gradle:gradle-node-plugin:1.2.0'
  13. classpath 'gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.14.0'
  14. classpath 'io.spring.gradle:dependency-management-plugin:1.0.4.RELEASE'
  15. classpath 'net.rdrei.android.buildtimetracker:gradle-plugin:0.11.0'
  16. classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.7.5'
  17. classpath "org.owasp:dependency-check-gradle:4.0.2"
  18. classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.7'
  19. }
  20. }
  21. // display a summary of task durations at the end of the build
  22. if (project.hasProperty('time-tracker')) {
  23. apply plugin: 'build-time-tracker'
  24. buildtimetracker {
  25. reporters {
  26. summary {
  27. ordered true
  28. threshold 1000
  29. barstyle 'ascii'
  30. }
  31. }
  32. }
  33. }
  34. // Analyze SonarQube with SonarQube!
  35. ext.versionInSources = version
  36. apply plugin: 'org.sonarqube'
  37. sonarqube {
  38. properties {
  39. property 'sonar.projectName', projectTitle
  40. property 'sonar.projectVersion', versionInSources
  41. }
  42. }
  43. allprojects {
  44. apply plugin: 'com.jfrog.artifactory'
  45. apply plugin: 'maven-publish'
  46. ext.buildNumber = System.getProperty("buildNumber")
  47. // Replaces the version defined in sources, usually x.y-SNAPSHOT, by a version identifying the build.
  48. if (version.endsWith('-SNAPSHOT') && ext.buildNumber != null) {
  49. def versionSuffix = (version.toString().count('.') == 1 ? ".0.${ext.buildNumber}" : ".${ext.buildNumber}")
  50. version = version.replace('-SNAPSHOT', versionSuffix)
  51. }
  52. ext {
  53. release = project.hasProperty('release') && project.getProperty('release')
  54. official = project.hasProperty('official') && project.getProperty('official')
  55. }
  56. repositories {
  57. def repository = project.hasProperty('qa') ? 'sonarsource-qa' : 'sonarsource'
  58. maven {
  59. url "https://repox.jfrog.io/repox/${repository}"
  60. // The environment variables ARTIFACTORY_PRIVATE_USERNAME and ARTIFACTORY_PRIVATE_PASSWORD are used on QA env (Jenkins)
  61. // On local box, please add artifactoryUsername and artifactoryPassword to ~/.gradle/gradle.properties
  62. def artifactoryUsername = System.env.'ARTIFACTORY_PRIVATE_USERNAME' ?: (project.hasProperty('artifactoryUsername') ? project.getProperty('artifactoryUsername') : '')
  63. def artifactoryPassword = System.env.'ARTIFACTORY_PRIVATE_PASSWORD' ?: (project.hasProperty('artifactoryPassword') ? project.getProperty('artifactoryPassword') : '')
  64. if (artifactoryUsername && artifactoryPassword) {
  65. credentials {
  66. username artifactoryUsername
  67. password artifactoryPassword
  68. }
  69. }
  70. }
  71. }
  72. }
  73. subprojects {
  74. apply plugin: 'com.github.hierynomus.license'
  75. apply plugin: 'io.spring.dependency-management'
  76. apply plugin: 'java'
  77. apply plugin: 'jacoco'
  78. apply plugin: 'idea'
  79. apply plugin: 'org.owasp.dependencycheck'
  80. // do not deploy to Artifactory by default
  81. artifactoryPublish.skip = true
  82. ext {
  83. protobufVersion = '3.7.0'
  84. }
  85. sonarqube {
  86. properties {
  87. property 'sonar.moduleKey', project.group + ':' + project.name
  88. }
  89. }
  90. // Central place for definition dependency versions and exclusions.
  91. dependencyManagement {
  92. dependencies {
  93. // please keep this list alphabetically ordered
  94. dependencySet(group: 'ch.qos.logback', version: '1.2.3') {
  95. entry 'logback-access'
  96. entry 'logback-classic'
  97. entry 'logback-core'
  98. }
  99. dependency('commons-beanutils:commons-beanutils:1.8.3') {
  100. exclude 'commons-logging:commons-logging'
  101. }
  102. dependency 'commons-codec:commons-codec:1.8'
  103. dependency 'commons-dbutils:commons-dbutils:1.5'
  104. dependency 'commons-io:commons-io:2.6'
  105. dependency 'commons-lang:commons-lang:2.6'
  106. dependencySet(group: 'com.fasterxml.jackson.core', version: '2.9.8') {
  107. entry 'jackson-core'
  108. entry 'jackson-databind'
  109. entry 'jackson-annotations'
  110. }
  111. dependency 'com.eclipsesource.minimal-json:minimal-json:0.9.5'
  112. dependency 'com.github.kevinsawicki:http-request:5.4.1'
  113. dependency 'com.googlecode.java-diff-utils:diffutils:1.2'
  114. dependency('com.googlecode.json-simple:json-simple:1.1.1') {
  115. exclude 'junit:junit'
  116. }
  117. dependency 'com.google.code.findbugs:jsr305:3.0.2'
  118. dependency 'com.google.code.gson:gson:2.8.4'
  119. dependency 'com.google.guava:guava:18.0'
  120. dependency "com.google.protobuf:protobuf-java:${protobufVersion}"
  121. dependency 'com.h2database:h2:1.3.176'
  122. dependencySet(group: 'com.hazelcast', version: '3.8.6') {
  123. entry 'hazelcast'
  124. entry 'hazelcast-client'
  125. }
  126. dependency 'com.ibm.icu:icu4j:3.4.4'
  127. dependency 'com.microsoft.sqlserver:mssql-jdbc:6.2.2.jre8'
  128. dependency 'com.oracle.jdbc:ojdbc8:12.2.0.1.0'
  129. dependencySet(group: 'com.squareup.okhttp3', version: '3.14.0') {
  130. entry 'okhttp'
  131. entry 'mockwebserver'
  132. }
  133. dependency 'com.tngtech.java:junit-dataprovider:1.9.2'
  134. dependency 'info.picocli:picocli:3.6.1'
  135. dependency 'io.jsonwebtoken:jjwt:0.9.0'
  136. dependency 'javax.servlet:javax.servlet-api:3.0.1'
  137. dependency 'javax.xml.bind:jaxb-api:2.3.0'
  138. dependency 'junit:junit:4.12'
  139. dependency 'mysql:mysql-connector-java:5.1.46'
  140. dependency 'net.jpountz.lz4:lz4:1.3.0'
  141. dependency 'org.apache.commons:commons-csv:1.4'
  142. dependency 'org.apache.commons:commons-email:1.5'
  143. dependency 'org.apache.commons:commons-dbcp2:2.5.0'
  144. dependency('org.apache.httpcomponents:httpclient:4.5.2'){
  145. exclude 'commons-logging:commons-logging'
  146. }
  147. // Be aware that Log4j is used by Elasticsearch client
  148. dependencySet(group: 'org.apache.logging.log4j', version: '2.8.2') {
  149. entry 'log4j-api'
  150. entry 'log4j-to-slf4j'
  151. entry 'log4j-core'
  152. }
  153. dependencySet(group: 'org.apache.tomcat.embed', version: '8.5.38') {
  154. entry 'tomcat-embed-core'
  155. entry('tomcat-embed-jasper') {
  156. exclude 'org.eclipse.jdt.core.compiler:ecj'
  157. }
  158. }
  159. dependency 'org.assertj:assertj-core:3.9.1'
  160. dependency 'org.assertj:assertj-guava:3.2.0'
  161. dependency('org.codehaus.sonar:sonar-channel:4.1') {
  162. exclude 'org.slf4j:slf4j-api'
  163. }
  164. dependency 'org.codehaus.sonar:sonar-classloader:1.0'
  165. dependency('org.codehaus.woodstox:woodstox-core-lgpl:4.4.0') {
  166. exclude 'javax.xml.stream:stax-api'
  167. }
  168. dependency 'org.codehaus.sonar.runner:sonar-runner-api:2.4'
  169. dependency('org.codehaus.sonar:sonar-squid:4.1') {
  170. exclude 'org.codehaus.sonar:sonar-check-api'
  171. }
  172. dependency('org.codehaus.staxmate:staxmate:2.0.1') {
  173. exclude 'org.codehaus.woodstox:stax2-api'
  174. exclude 'stax:stax-api'
  175. exclude 'org.codehaus.woodstox:woodstox-core-asl'
  176. }
  177. dependency('org.codehaus.woodstox:stax2-api:3.1.4') {
  178. exclude 'stax:stax-api'
  179. }
  180. dependency('org.dbunit:dbunit:2.4.5') {
  181. exclude 'commons-lang:commons-lang'
  182. exclude 'xerces:xmlParserAPIs'
  183. exclude 'xerces:xercesImpl'
  184. }
  185. dependencySet(group: 'org.eclipse.jetty', version: '9.4.6.v20170531') {
  186. entry 'jetty-proxy'
  187. entry 'jetty-server'
  188. entry 'jetty-servlet'
  189. }
  190. dependency('org.elasticsearch.client:transport:6.6.2') {
  191. exclude 'org.elasticsearch.plugin:lang-mustache-client'
  192. exclude 'commons-logging:commons-logging'
  193. exclude 'org.elasticsearch.plugin:reindex-client'
  194. exclude 'org.elasticsearch.plugin:rank-eval-client'
  195. }
  196. dependency('org.elasticsearch:mocksocket:1.0')
  197. // at this date, version 6.6.2 of this module has not been published to Maven central
  198. dependency('org.codelibs.elasticsearch.module:analysis-common:6.6.1')
  199. dependency 'org.freemarker:freemarker:2.3.20'
  200. dependency 'org.hamcrest:hamcrest-all:1.3'
  201. dependency 'org.mindrot:jbcrypt:0.4'
  202. dependency('org.mockito:mockito-core:2.15.0') {
  203. exclude 'org.hamcrest:hamcrest-core'
  204. }
  205. dependency 'org.mybatis:mybatis:3.4.6'
  206. dependency 'org.nanohttpd:nanohttpd:2.3.0'
  207. dependency 'org.picocontainer:picocontainer:2.15'
  208. dependencySet(group: 'org.slf4j', version: '1.7.25') {
  209. entry 'jcl-over-slf4j'
  210. entry 'jul-to-slf4j'
  211. entry 'log4j-over-slf4j'
  212. entry 'slf4j-api'
  213. }
  214. dependency 'org.postgresql:postgresql:42.2.5'
  215. dependency 'org.reflections:reflections:0.9.9'
  216. dependency 'org.simpleframework:simple:4.1.21'
  217. dependency 'org.sonarsource.orchestrator:sonar-orchestrator:3.22.0.1791'
  218. dependency 'org.sonarsource.update-center:sonar-update-center-common:1.18.0.487'
  219. dependency 'org.subethamail:subethasmtp:3.1.7'
  220. dependency 'xml-apis:xml-apis:1.4.01'
  221. // please keep this list alphabetically ordered
  222. }
  223. }
  224. sourceCompatibility = 1.8
  225. tasks.withType(JavaCompile) {
  226. options.encoding = 'UTF-8'
  227. }
  228. tasks.withType(Javadoc) {
  229. options.addStringOption('Xdoclint:none', '-quiet')
  230. options.encoding = 'UTF-8'
  231. }
  232. task sourcesJar(type: Jar, dependsOn: classes) {
  233. classifier = 'sources'
  234. from sourceSets.main.allSource
  235. }
  236. task javadocJar(type: Jar, dependsOn: javadoc) {
  237. classifier = 'javadoc'
  238. from javadoc.destinationDir
  239. }
  240. // generate code before opening project in IDE (Eclipse or Intellij)
  241. task ide() {
  242. // empty by default. Dependencies are added to the task
  243. // when needed (see protobuf modules for example)
  244. }
  245. test {
  246. jvmArgs '-Dfile.encoding=UTF8'
  247. maxHeapSize = '1G'
  248. systemProperty 'java.awt.headless', true
  249. testLogging {
  250. events "skipped", "failed" // verbose log for failed and skipped tests (by default the name of the tests are not logged)
  251. exceptionFormat 'full' // log the full stack trace (default is the 1st line of the stack trace)
  252. }
  253. jacoco {
  254. append = false
  255. enabled = project.hasProperty('jacocoEnabled')
  256. includes = ['com.sonar.*', 'com.sonarsource.*', 'org.sonar.*', 'org.sonarqube.*', 'org.sonarsource.*', 'io.sonarcloud.*']
  257. }
  258. if (project.hasProperty('maxParallelTests')) {
  259. // WARNING this is not compatible with jacocoEnabled
  260. maxParallelForks = project.maxParallelTests as int
  261. }
  262. if (project.hasProperty('parallelTests')) {
  263. // WARNING this is not compatible with jacocoEnabled
  264. // See https://guides.gradle.org/performance/#parallel_test_execution
  265. maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
  266. }
  267. }
  268. def protoMainSrc = 'src/main/protobuf'
  269. def protoTestSrc = 'src/test/protobuf'
  270. if (file(protoMainSrc).exists() || file(protoTestSrc).exists()) {
  271. // protobuf must be applied after java
  272. apply plugin: 'com.google.protobuf'
  273. sourceSets.main.proto.srcDir protoMainSrc // in addition to the default 'src/main/proto'
  274. sourceSets.test.proto.srcDir protoTestSrc // in addition to the default 'src/test/proto'
  275. protobuf {
  276. protoc {
  277. artifact = "com.google.protobuf:protoc:3.5.1"
  278. }
  279. }
  280. jar {
  281. exclude('**/*.proto')
  282. }
  283. idea {
  284. module {
  285. sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java")
  286. testSourceDirs += file("${protobuf.generatedFilesBaseDir}/test/java")
  287. generatedSourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java")
  288. generatedSourceDirs += file("${protobuf.generatedFilesBaseDir}/test/java")
  289. }
  290. }
  291. ide.dependsOn(['generateProto', 'generateTestProto'])
  292. }
  293. if (file('package.json').exists()) {
  294. apply plugin: 'com.moowork.node'
  295. node {
  296. version = '8.11.4'
  297. yarnVersion = '1.9.4'
  298. download = true
  299. }
  300. }
  301. if (official) {
  302. jar {
  303. // do not break incremental build on non official versions
  304. manifest {
  305. attributes(
  306. 'Version': "${version}",
  307. 'Implementation-Build': System.getenv('GIT_SHA1'),
  308. 'Build-Time': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  309. )
  310. }
  311. }
  312. }
  313. license {
  314. header = rootProject.file('HEADER')
  315. strictCheck true
  316. mapping {
  317. java = 'SLASHSTAR_STYLE'
  318. js = 'SLASHSTAR_STYLE'
  319. ts = 'SLASHSTAR_STYLE'
  320. tsx = 'SLASHSTAR_STYLE'
  321. css = 'SLASHSTAR_STYLE'
  322. }
  323. includes(['**/*.java', '**/*.js', '**/*.ts', '**/*.tsx', '**/*.css'])
  324. }
  325. publishing {
  326. publications {
  327. mavenJava(MavenPublication) {
  328. pom {
  329. name = 'SonarQube'
  330. description = project.description
  331. url = 'http://www.sonarqube.org/'
  332. organization {
  333. name = 'SonarSource'
  334. url = 'http://www.sonarsource.com'
  335. }
  336. licenses {
  337. license {
  338. name = 'GNU LGPL 3'
  339. url = 'http://www.gnu.org/licenses/lgpl.txt'
  340. distribution = 'repo'
  341. }
  342. }
  343. scm {
  344. url = 'https://github.com/SonarSource/sonarqube'
  345. }
  346. developers {
  347. developer {
  348. id = 'sonarsource-team'
  349. name = 'SonarSource Team'
  350. }
  351. }
  352. }
  353. }
  354. }
  355. }
  356. }
  357. artifactory {
  358. clientConfig.setIncludeEnvVars(true)
  359. clientConfig.setEnvVarsExcludePatterns('*password*,*PASSWORD*,*secret*,*MAVEN_CMD_LINE_ARGS*,sun.java.command,*token*,*TOKEN*,*LOGIN*,*login*,*key*,*KEY*')
  360. contextUrl = System.getenv('ARTIFACTORY_URL')
  361. publish {
  362. repository {
  363. repoKey = System.getenv('ARTIFACTORY_DEPLOY_REPO')
  364. username = System.getenv('ARTIFACTORY_DEPLOY_USERNAME') ?: project.properties.artifactoryUsername
  365. password = System.getenv('ARTIFACTORY_DEPLOY_PASSWORD') ?: project.properties.artifactoryPaswword
  366. }
  367. defaults {
  368. properties = [
  369. 'build.name': 'sonar-enterprise',
  370. 'build.number': System.getenv('BUILD_NUMBER'),
  371. 'pr.branch.target': System.getenv('GITHUB_BASE_BRANCH'),
  372. 'pr.number': System.getenv('PULL_REQUEST'),
  373. 'vcs.branch': System.getenv('GITHUB_BRANCH'),
  374. 'vcs.revision': System.getenv('GIT_SHA1'),
  375. 'version': version
  376. ]
  377. publications('mavenJava')
  378. publishPom = true
  379. publishIvy = false
  380. }
  381. }
  382. clientConfig.info.setBuildName('sonar-enterprise')
  383. clientConfig.info.setBuildNumber(System.getenv('BUILD_NUMBER'))
  384. // Define the artifacts to be deployed to https://binaries.sonarsource.com on releases
  385. clientConfig.info.addEnvironmentProperty('ARTIFACTS_TO_PUBLISH',
  386. "${project.group}:sonar-application:zip," +
  387. "com.sonarsource.sonarqube:sonarqube-developer:zip," +
  388. "com.sonarsource.sonarqube:sonarqube-datacenter:zip," +
  389. "com.sonarsource.sonarqube:sonarqube-enterprise:zip")
  390. // The name of this variable is important because it's used by the delivery process when extracting version from Artifactory build info.
  391. clientConfig.info.addEnvironmentProperty('PROJECT_VERSION', "${version}")
  392. }
  393. // https://github.com/ben-manes/gradle-versions-plugin
  394. apply plugin: 'com.github.ben-manes.versions'
  395. // Exclude dev versions from the list of dependency upgrades, for
  396. // example to replace:
  397. // org.slf4j:log4j-over-slf4j [1.7.25 -> 1.8.0-beta4]
  398. // by
  399. // org.slf4j:log4j-over-slf4j [1.7.25 -> 1.7.26]
  400. dependencyUpdates.resolutionStrategy {
  401. componentSelection { rules ->
  402. rules.all { ComponentSelection selection ->
  403. boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm', 'preview'].any { qualifier ->
  404. selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-]*/
  405. }
  406. if (rejected) {
  407. selection.reject('Development version')
  408. }
  409. }
  410. }
  411. }