Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

build.gradle 17KB

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