Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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