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

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