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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. buildscript {
  2. repositories {
  3. maven {
  4. url 'https://repox.sonarsource.com/plugins.gradle.org/'
  5. }
  6. }
  7. dependencies {
  8. // check updates with https://plugins.gradle.org/
  9. // Ordered alphabeticly to avoid duplication
  10. classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
  11. classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.4'
  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 'org.jfrog.buildinfo:build-info-extractor-gradle:4.6.2'
  16. classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.2'
  17. }
  18. }
  19. // Analyze SonarQube with SonarQube!
  20. apply plugin: 'org.sonarqube'
  21. sonarqube {
  22. properties {
  23. property 'sonar.projectName', projectTitle
  24. }
  25. }
  26. allprojects {
  27. apply plugin: 'com.jfrog.artifactory'
  28. apply plugin: 'maven-publish'
  29. ext.buildNumber = System.getProperty("buildNumber")
  30. // Replaces the version defined in sources, usually x.y-SNAPSHOT, by a version identifying the build.
  31. if (version.endsWith('-SNAPSHOT') && ext.buildNumber != null) {
  32. def versionSuffix = (version.toString().count('.') == 1 ? ".0.${ext.buildNumber}" : ".${ext.buildNumber}")
  33. version = version.replace('-SNAPSHOT', versionSuffix)
  34. }
  35. ext {
  36. release = project.hasProperty('release') && project.getProperty('release')
  37. }
  38. repositories {
  39. def repository = project.hasProperty('cix') ? 'sonarsource-qa' : 'sonarsource'
  40. maven {
  41. url "https://repox.sonarsource.com/${repository}"
  42. def artifactoryUsername = System.env.'ARTIFACTORY_PRIVATE_USERNAME' ?: (project.hasProperty('artifactoryUsername') ? project.getProperty('artifactoryUsername') : '')
  43. def artifactoryPassword = System.env.'ARTIFACTORY_PRIVATE_PASSWORD' ?: (project.hasProperty('artifactoryPassword') ? project.getProperty('artifactoryPassword') : '')
  44. if (artifactoryUsername && artifactoryPassword) {
  45. credentials {
  46. username artifactoryUsername
  47. password artifactoryPassword
  48. }
  49. }
  50. }
  51. }
  52. }
  53. subprojects {
  54. apply plugin: "com.github.hierynomus.license"
  55. apply plugin: 'io.spring.dependency-management'
  56. apply plugin: 'java'
  57. // protobuf must be applied after java
  58. apply plugin: 'com.google.protobuf'
  59. apply plugin: 'jacoco'
  60. apply plugin: 'idea'
  61. // do not deploy to Artifactory by default
  62. artifactoryPublish.skip = true
  63. ext {
  64. elasticsearchVersion = '5.6.3'
  65. protobufVersion = '3.5.1'
  66. }
  67. sonarqube {
  68. properties {
  69. property 'sonar.moduleKey', project.group + ':' + project.name
  70. }
  71. }
  72. // Central place for definition dependency versions and exclusions.
  73. dependencyManagement {
  74. dependencies {
  75. // please keep this list alphabetically ordered
  76. dependencySet(group: 'ch.qos.logback', version: '1.2.3') {
  77. entry 'logback-access'
  78. entry 'logback-classic'
  79. entry 'logback-core'
  80. }
  81. dependency('commons-beanutils:commons-beanutils:1.8.3') {
  82. exclude 'commons-logging:commons-logging'
  83. }
  84. dependency 'commons-codec:commons-codec:1.8'
  85. dependency 'commons-dbcp:commons-dbcp:1.4'
  86. dependency 'commons-dbutils:commons-dbutils:1.5'
  87. dependency 'commons-io:commons-io:2.4'
  88. dependency 'commons-lang:commons-lang:2.6'
  89. dependencySet(group: 'com.fasterxml.jackson.core', version: '2.6.6') {
  90. entry 'jackson-core'
  91. entry 'jackson-databind'
  92. entry 'jackson-annotations'
  93. }
  94. dependency 'com.github.kevinsawicki:http-request:5.4.1'
  95. dependency 'com.github.tlrx:elasticsearch-test:1.2.1'
  96. dependency 'com.googlecode.java-diff-utils:diffutils:1.2'
  97. dependency('com.googlecode.json-simple:json-simple:1.1.1') {
  98. exclude 'junit:junit'
  99. }
  100. dependency 'com.google.code.findbugs:jsr305:3.0.2'
  101. dependency 'com.google.code.gson:gson:2.3.1'
  102. dependency 'com.google.guava:guava:18.0'
  103. dependency "com.google.protobuf:protobuf-java:${protobufVersion}"
  104. dependency 'com.h2database:h2:1.3.176'
  105. dependencySet(group: 'com.hazelcast', version: '3.8.6') {
  106. entry 'hazelcast'
  107. entry 'hazelcast-client'
  108. }
  109. dependency 'com.ibm.icu:icu4j:3.4.4'
  110. dependency 'com.microsoft.sqlserver:mssql-jdbc:6.2.2.jre8'
  111. dependency 'com.oracle.jdbc:ojdbc8:12.2.0.1.0'
  112. dependencySet(group: 'com.squareup.okhttp3', version: '3.7.0') {
  113. entry 'okhttp'
  114. entry 'mockwebserver'
  115. }
  116. dependency 'com.tngtech.java:junit-dataprovider:1.9.2'
  117. dependency 'io.jsonwebtoken:jjwt:0.9.0'
  118. dependency 'javax.servlet:javax.servlet-api:3.0.1'
  119. dependency 'javax.xml.bind:jaxb-api:2.3.0'
  120. dependency 'junit:junit:4.12'
  121. dependency 'mysql:mysql-connector-java:5.1.42'
  122. dependency 'net.jpountz.lz4:lz4:1.3.0'
  123. dependency 'org.apache.commons:commons-csv:1.4'
  124. dependency 'org.apache.commons:commons-email:1.5'
  125. dependency('org.apache.httpcomponents:httpclient:4.5.2'){
  126. exclude 'commons-logging:commons-logging'
  127. }
  128. // Be aware that Log4j is used by Elasticsearch client
  129. dependencySet(group: 'org.apache.logging.log4j', version: '2.8.2') {
  130. entry 'log4j-api'
  131. entry 'log4j-to-slf4j'
  132. entry 'log4j-core'
  133. }
  134. dependencySet(group: 'org.apache.tomcat.embed', version: '8.5.23') {
  135. entry 'tomcat-embed-core'
  136. entry('tomcat-embed-jasper') {
  137. exclude 'org.eclipse.jdt.core.compiler:ecj'
  138. }
  139. }
  140. dependency 'org.assertj:assertj-core:3.9.0'
  141. dependency 'org.assertj:assertj-guava:3.1.0'
  142. dependency('org.codehaus.sonar:sonar-channel:4.1') {
  143. exclude 'org.slf4j:slf4j-api'
  144. }
  145. dependency 'org.codehaus.sonar:sonar-classloader:1.0'
  146. dependency('org.codehaus.woodstox:woodstox-core-lgpl:4.4.0') {
  147. exclude 'javax.xml.stream:stax-api'
  148. }
  149. dependency 'org.codehaus.sonar.runner:sonar-runner-api:2.4'
  150. dependency('org.codehaus.sonar:sonar-squid:4.1') {
  151. exclude 'org.codehaus.sonar:sonar-check-api'
  152. }
  153. dependency('org.codehaus.staxmate:staxmate:2.0.1') {
  154. exclude 'org.codehaus.woodstox:stax2-api'
  155. exclude 'stax:stax-api'
  156. exclude 'org.codehaus.woodstox:woodstox-core-asl'
  157. }
  158. dependency('org.codehaus.woodstox:stax2-api:3.1.4') {
  159. exclude 'stax:stax-api'
  160. }
  161. dependency('org.dbunit:dbunit:2.4.5') {
  162. exclude 'commons-lang:commons-lang'
  163. exclude 'xerces:xmlParserAPIs'
  164. exclude 'xerces:xercesImpl'
  165. }
  166. dependencySet(group: 'org.eclipse.jetty', version: '9.3.6.v20151106') {
  167. entry 'jetty-proxy'
  168. entry 'jetty-server'
  169. entry 'jetty-servlet'
  170. }
  171. dependency("org.elasticsearch.client:transport:${elasticsearchVersion}") {
  172. exclude 'org.elasticsearch.plugin:lang-mustache-client'
  173. exclude 'org.elasticsearch.plugin:transport-netty3-client'
  174. exclude 'commons-logging:commons-logging'
  175. exclude 'org.elasticsearch.plugin:reindex-client'
  176. }
  177. dependency 'org.freemarker:freemarker:2.3.20'
  178. dependency 'org.hamcrest:hamcrest-all:1.3'
  179. dependency('org.mockito:mockito-core:2.15.0') {
  180. exclude 'org.hamcrest:hamcrest-core'
  181. }
  182. dependency 'org.mybatis:mybatis:3.4.6'
  183. dependency 'org.nanohttpd:nanohttpd:2.3.0'
  184. dependency 'org.picocontainer:picocontainer:2.15'
  185. dependencySet(group: 'org.slf4j', version: '1.7.25') {
  186. entry 'jcl-over-slf4j'
  187. entry 'jul-to-slf4j'
  188. entry 'log4j-over-slf4j'
  189. entry 'slf4j-api'
  190. }
  191. dependency 'org.postgresql:postgresql:42.2.1'
  192. dependency 'org.reflections:reflections:0.9.9'
  193. dependency 'org.simpleframework:simple:4.1.21'
  194. dependency 'org.sonarsource.orchestrator:sonar-orchestrator:3.16.1.1446'
  195. dependency('org.sonarsource:sonar-persistit:3.3.2') {
  196. exclude 'commons-logging:commons-logging'
  197. }
  198. dependency 'org.sonarsource.update-center:sonar-update-center-common:1.18.0.487'
  199. dependency 'org.subethamail:subethasmtp:3.1.7'
  200. dependency 'xml-apis:xml-apis:1.4.01'
  201. // please keep this list alphabetically ordered
  202. }
  203. }
  204. sourceCompatibility = 1.8
  205. tasks.withType(JavaCompile) {
  206. options.encoding = 'UTF-8'
  207. }
  208. tasks.withType(Javadoc) {
  209. options.addStringOption('Xdoclint:none', '-quiet')
  210. }
  211. task sourcesJar(type: Jar, dependsOn: classes) {
  212. classifier = 'sources'
  213. from sourceSets.main.allSource
  214. }
  215. task javadocJar(type: Jar, dependsOn: javadoc) {
  216. classifier = 'javadoc'
  217. from javadoc.destinationDir
  218. }
  219. test {
  220. systemProperty 'java.awt.headless', true
  221. jacoco.enabled = project.hasProperty('jacocoEnabled')
  222. testLogging {
  223. exceptionFormat 'full' // log the full stack trace (default is the 1st line of the stack trace)
  224. events "skipped", "failed" // verbose log for failed and skipped tests (by default the name of the tests are not logged)
  225. }
  226. if (project.hasProperty('maxParallelTests'))
  227. maxParallelForks = project.maxParallelTests as int
  228. }
  229. def protoMainSrc = 'src/main/protobuf'
  230. def protoTestSrc = 'src/test/protobuf'
  231. if (file(protoMainSrc).exists() || file(protoTestSrc).exists()) {
  232. sourceSets.main.proto.srcDir protoMainSrc // in addition to the default 'src/main/proto'
  233. sourceSets.test.proto.srcDir protoTestSrc // in addition to the default 'src/test/proto'
  234. protobuf {
  235. protoc {
  236. artifact = "com.google.protobuf:protoc:${protobufVersion}"
  237. }
  238. }
  239. idea {
  240. module {
  241. sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java")
  242. testSourceDirs += file("${protobuf.generatedFilesBaseDir}/test/java")
  243. }
  244. }
  245. }
  246. task ide(dependsOn: ['generateProto', 'generateTestProto']) {
  247. }
  248. if (release) {
  249. jar {
  250. // do not break incremental build on non-release versions
  251. manifest {
  252. attributes(
  253. 'Version': "${version}",
  254. 'Implementation-Build': 'git rev-parse HEAD'.execute().text.trim(),
  255. 'Build-Time': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  256. )
  257. }
  258. }
  259. }
  260. license {
  261. header = rootProject.file('HEADER')
  262. ext.year = Calendar.getInstance().get(Calendar.YEAR)
  263. strictCheck true
  264. mapping {
  265. java = 'SLASHSTAR_STYLE'
  266. js = 'SLASHSTAR_STYLE'
  267. ts = 'SLASHSTAR_STYLE'
  268. tsx = 'SLASHSTAR_STYLE'
  269. css = 'SLASHSTAR_STYLE'
  270. less = 'SLASHSTAR_STYLE'
  271. }
  272. excludes(["**/*.txt", "**/*.properties", "**/*.xml", "**/*.xsd", "**/*.html", "**/*.json", "**/*.sql", "**/*.rb", "**/*.vm"])
  273. }
  274. }
  275. artifactory {
  276. clientConfig.setIncludeEnvVars(true)
  277. clientConfig.setEnvVarsExcludePatterns('*password*,*PASSWORD*,*secret*,*MAVEN_CMD_LINE_ARGS*,sun.java.command,*token*,*TOKEN*,*LOGIN*,*login*')
  278. contextUrl = System.getenv('ARTIFACTORY_URL')
  279. publish {
  280. repository {
  281. repoKey = System.getenv('ARTIFACTORY_DEPLOY_REPO')
  282. username = System.getenv('ARTIFACTORY_DEPLOY_USERNAME') ?: project.properties.artifactoryUsername
  283. password = System.getenv('ARTIFACTORY_DEPLOY_PASSWORD') ?: project.properties.artifactoryPaswword
  284. }
  285. defaults {
  286. properties = [
  287. 'build.name': 'sonar-enterprise',
  288. 'build.number': (System.getenv('BUILD_ID') ?: System.getenv('BUILD_NUMBER')),
  289. 'pr.branch.target': System.getenv('PULL_REQUEST_BRANCH_TARGET'),
  290. 'pr.number': System.getenv('PULL_REQUEST_NUMBER'),
  291. 'vcs.branch': System.getenv('GIT_BRANCH'),
  292. 'vcs.revision': System.getenv('GIT_COMMIT'),
  293. 'version': version
  294. ]
  295. publications('mavenJava')
  296. publishPom = true
  297. publishIvy = false
  298. }
  299. }
  300. clientConfig.info.setBuildName('sonar-enterprise')
  301. clientConfig.info.setBuildNumber(System.getenv('BUILD_NUMBER'))
  302. // Define the artifacts to be deployed to https://sonarsource.bintray.com on releases
  303. clientConfig.info.addEnvironmentProperty('ARTIFACTS_TO_PUBLISH', "${project.group}:sonar-application:zip,com.sonarsource.governance:sonar-governance-plugin:jar,com.sonarsource.developer:sonar-developer-plugin:jar,com.sonarsource.ha:sonar-ha-plugin:jar,com.sonarsource.branch:sonar-branch-plugin:jar")
  304. // The name of this variable is important because it's used by the delivery process when extracting version from Artifactory build info.
  305. clientConfig.info.addEnvironmentProperty('PROJECT_VERSION', "${version}")
  306. }