aboutsummaryrefslogtreecommitdiffstats
path: root/build.gradle
blob: c53bd71fd6b5f74bf737a7143bc25b991bd06bae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
buildscript {
  repositories {
    maven {
      url 'https://repox.sonarsource.com/plugins.gradle.org/'
    }
  }
  dependencies {
    // Ordered alphabeticly to avoid duplication
    classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0'
    classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
    classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.4'
    classpath 'com.moowork.gradle:gradle-node-plugin:1.2.0'
    classpath "gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.14.0"
    classpath 'io.spring.gradle:dependency-management-plugin:1.0.4.RELEASE'
    // BuildInfo plugin is broken for 4.7.2 :
    // https://github.com/gradle/gradle/issues/4783#issuecomment-386720873
    // https://github.com/JFrogDev/build-info/issues/165
    // https://www.jfrog.com/jira/browse/GAP-288
    // https://www.jfrog.com/jira/browse/GAP-289
    classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.6.2'
    classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.2'
  }
}

// Analyze SonarQube with SonarQube!
apply plugin: 'org.sonarqube'
sonarqube {
  properties {
    property 'sonar.projectName', projectTitle
  }
}

allprojects {
  apply plugin: 'com.github.ben-manes.versions'
  apply plugin: 'com.jfrog.artifactory'
  apply plugin: 'maven-publish'

  ext.buildNumber = System.getProperty("buildNumber")
  // Replaces the version defined in sources, usually x.y-SNAPSHOT, by a version identifying the build.
  if (version.endsWith('-SNAPSHOT') && ext.buildNumber != null) {
    def versionSuffix = (version.toString().count('.') == 1 ? ".0.${ext.buildNumber}" : ".${ext.buildNumber}")
    version = version.replace('-SNAPSHOT', versionSuffix)
  }

  ext {
    release = project.hasProperty('release') && project.getProperty('release')
    official = project.hasProperty('official') && project.getProperty('official')
  }

  repositories {
    def repository = project.hasProperty('cix') ? 'sonarsource-qa' : 'sonarsource'
    maven {
      url "https://repox.sonarsource.com/${repository}"
      // The environment variables ARTIFACTORY_PRIVATE_USERNAME and ARTIFACTORY_PRIVATE_PASSWORD are used on QA env (Jenkins)
      // On local box, please add artifactoryUsername and artifactoryPassword to ~/.gradle/gradle.properties
      def artifactoryUsername = System.env.'ARTIFACTORY_PRIVATE_USERNAME' ?: (project.hasProperty('artifactoryUsername') ? project.getProperty('artifactoryUsername') : '')
      def artifactoryPassword = System.env.'ARTIFACTORY_PRIVATE_PASSWORD' ?: (project.hasProperty('artifactoryPassword') ? project.getProperty('artifactoryPassword') : '')
      if (artifactoryUsername && artifactoryPassword) {
        credentials {
          username artifactoryUsername
          password artifactoryPassword
        }
      }
    }
  }

  task printDependencies {
    dependsOn 'dependencies'
  }
}

subprojects {
  apply plugin: "com.github.hierynomus.license"
  apply plugin: 'io.spring.dependency-management'
  apply plugin: 'java'
  // protobuf must be applied after java
  apply plugin: 'com.google.protobuf'
  apply plugin: 'jacoco'
  apply plugin: 'idea'

  // do not deploy to Artifactory by default
  artifactoryPublish.skip = true

  ext {
    protobufVersion = '3.5.1'
  }

  sonarqube {
    properties {
      property 'sonar.moduleKey', project.group + ':' + project.name
    }
  }

  // Central place for definition dependency versions and exclusions.
  dependencyManagement {
    dependencies {
      // please keep this list alphabetically ordered
      dependencySet(group: 'ch.qos.logback', version: '1.2.3') {
        entry 'logback-access'
        entry 'logback-classic'
        entry 'logback-core'
      }
      dependency('commons-beanutils:commons-beanutils:1.8.3') {
        exclude 'commons-logging:commons-logging'
      }
      dependency 'commons-codec:commons-codec:1.8'
      dependency 'commons-dbcp:commons-dbcp:1.4'
      dependency 'commons-dbutils:commons-dbutils:1.5'
      dependency 'commons-io:commons-io:2.6'
      dependency 'commons-lang:commons-lang:2.6'
      dependencySet(group: 'com.fasterxml.jackson.core', version: '2.9.5') {
        entry 'jackson-core'
        entry 'jackson-databind'
        entry 'jackson-annotations'
      }
      dependency 'com.github.kevinsawicki:http-request:5.4.1'
      dependency 'com.googlecode.java-diff-utils:diffutils:1.2'
      dependency('com.googlecode.json-simple:json-simple:1.1.1') {
        exclude 'junit:junit'
      }
      dependency 'com.google.code.findbugs:jsr305:3.0.2'
      dependency 'com.google.code.gson:gson:2.8.4'
      dependency 'com.google.guava:guava:18.0'
      dependency "com.google.protobuf:protobuf-java:${protobufVersion}"
      dependency 'com.h2database:h2:1.3.176'
      dependencySet(group: 'com.hazelcast', version: '3.8.6') {
        entry 'hazelcast'
        entry 'hazelcast-client'
      }
      dependency 'com.ibm.icu:icu4j:3.4.4'
      dependency 'com.microsoft.sqlserver:mssql-jdbc:6.2.2.jre8'
      dependency 'com.oracle.jdbc:ojdbc8:12.2.0.1.0'
      dependencySet(group: 'com.squareup.okhttp3', version: '3.7.0') {
        entry 'okhttp'
        entry 'mockwebserver'
      }
      dependency 'com.tngtech.java:junit-dataprovider:1.9.2'
      dependency 'io.jsonwebtoken:jjwt:0.9.0'
      dependency 'javax.servlet:javax.servlet-api:3.0.1'
      dependency 'javax.xml.bind:jaxb-api:2.3.0'
      dependency 'junit:junit:4.12'
      dependency 'mysql:mysql-connector-java:5.1.46'
      dependency 'net.jpountz.lz4:lz4:1.3.0'
      dependency 'org.apache.commons:commons-csv:1.4'
      dependency 'org.apache.commons:commons-email:1.5'
      dependency('org.apache.httpcomponents:httpclient:4.5.2'){
        exclude 'commons-logging:commons-logging'
      }
      // Be aware that Log4j is used by Elasticsearch client
      dependencySet(group: 'org.apache.logging.log4j', version: '2.8.2') {
        entry 'log4j-api'
        entry 'log4j-to-slf4j'
        entry 'log4j-core'
      }
      dependencySet(group: 'org.apache.tomcat.embed', version: '8.5.23') {
        entry 'tomcat-embed-core'
        entry('tomcat-embed-jasper') {
          exclude 'org.eclipse.jdt.core.compiler:ecj'
        }
      }
      dependency 'org.assertj:assertj-core:3.9.1'
      dependency 'org.assertj:assertj-guava:3.2.0'
      dependency('org.codehaus.sonar:sonar-channel:4.1') {
        exclude 'org.slf4j:slf4j-api'
      }
      dependency 'org.codehaus.sonar:sonar-classloader:1.0'
      dependency('org.codehaus.woodstox:woodstox-core-lgpl:4.4.0') {
        exclude 'javax.xml.stream:stax-api'
      }
      dependency 'org.codehaus.sonar.runner:sonar-runner-api:2.4'
      dependency('org.codehaus.sonar:sonar-squid:4.1') {
        exclude 'org.codehaus.sonar:sonar-check-api'
      }
      dependency('org.codehaus.staxmate:staxmate:2.0.1') {
        exclude 'org.codehaus.woodstox:stax2-api'
        exclude 'stax:stax-api'
        exclude 'org.codehaus.woodstox:woodstox-core-asl'
      }
      dependency('org.codehaus.woodstox:stax2-api:3.1.4') {
        exclude 'stax:stax-api'
      }
      dependency('org.dbunit:dbunit:2.4.5') {
        exclude 'commons-lang:commons-lang'
        exclude 'xerces:xmlParserAPIs'
        exclude 'xerces:xercesImpl'
      }
      dependencySet(group: 'org.eclipse.jetty', version: '9.3.6.v20151106') {
        entry 'jetty-proxy'
        entry 'jetty-server'
        entry 'jetty-servlet'
      }
      dependency('org.elasticsearch.client:transport:5.6.3') {
        exclude 'org.elasticsearch.plugin:lang-mustache-client'
        exclude 'org.elasticsearch.plugin:transport-netty3-client'
        exclude 'commons-logging:commons-logging'
        exclude 'org.elasticsearch.plugin:reindex-client'
      }
      dependency 'org.freemarker:freemarker:2.3.20'
      dependency 'org.hamcrest:hamcrest-all:1.3'
      dependency 'org.mindrot:jbcrypt:0.4'
      dependency('org.mockito:mockito-core:2.15.0') {
        exclude 'org.hamcrest:hamcrest-core'
      }
      dependency 'org.mybatis:mybatis:3.4.6'
      dependency 'org.nanohttpd:nanohttpd:2.3.0'
      dependency 'org.picocontainer:picocontainer:2.15'
      dependencySet(group: 'org.slf4j', version: '1.7.25') {
        entry 'jcl-over-slf4j'
        entry 'jul-to-slf4j'
        entry 'log4j-over-slf4j'
        entry 'slf4j-api'
      }
      dependency 'org.postgresql:postgresql:42.2.2'
      dependency 'org.reflections:reflections:0.9.9'
      dependency 'org.simpleframework:simple:4.1.21'
      dependency 'org.sonarsource.orchestrator:sonar-orchestrator:3.19.0.1641'
      dependency('org.sonarsource:sonar-persistit:3.3.2') {
        exclude 'commons-logging:commons-logging'
      }
      dependency 'org.sonarsource.update-center:sonar-update-center-common:1.18.0.487'
      dependency 'org.subethamail:subethasmtp:3.1.7'
      dependency 'xml-apis:xml-apis:1.4.01'

      // please keep this list alphabetically ordered
    }
  }

  sourceCompatibility = 1.8
  tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
  }

  tasks.withType(Javadoc) {
    options.addStringOption('Xdoclint:none', '-quiet')
  }

  task sourcesJar(type: Jar, dependsOn: classes) {
    classifier = 'sources'
    from sourceSets.main.allSource
  }

  task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
  }

  test {
    systemProperty 'java.awt.headless', true
    jacoco.enabled = project.hasProperty('jacocoEnabled')
    testLogging {
      exceptionFormat 'full' // log the full stack trace (default is the 1st line of the stack trace)
      events "skipped", "failed" // verbose log for failed and skipped tests (by default the name of the tests are not logged)
    }
    if (project.hasProperty('maxParallelTests'))
        maxParallelForks = project.maxParallelTests as int
  }

  def protoMainSrc = 'src/main/protobuf'
  def protoTestSrc = 'src/test/protobuf'
  if (file(protoMainSrc).exists() || file(protoTestSrc).exists()) {
    sourceSets.main.proto.srcDir protoMainSrc  // in addition to the default 'src/main/proto'
    sourceSets.test.proto.srcDir protoTestSrc  // in addition to the default 'src/test/proto'
    protobuf {
      protoc {
        artifact = "com.google.protobuf:protoc:${protobufVersion}"
      }
    }
    idea {
      module {
        sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java")
        testSourceDirs += file("${protobuf.generatedFilesBaseDir}/test/java")
      }
    }
  }

  task ide(dependsOn: ['generateProto', 'generateTestProto']) {
  }

  if (official) {
    jar {
      // do not break incremental build on non official versions
      manifest {
        attributes(
          'Version': "${version}",
          'Implementation-Build': 'git rev-parse HEAD'.execute().text.trim(),
          'Build-Time': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
        )
      }
    }
  }

  license {
    header = rootProject.file('HEADER')
    ext.year = Calendar.getInstance().get(Calendar.YEAR)
    strictCheck true
    mapping {
      java = 'SLASHSTAR_STYLE'
      js = 'SLASHSTAR_STYLE'
      ts = 'SLASHSTAR_STYLE'
      tsx = 'SLASHSTAR_STYLE'
      css = 'SLASHSTAR_STYLE'
      less = 'SLASHSTAR_STYLE'
    }
    excludes(['**/*.txt', '**/*.properties', '**/*.xml', '**/*.xsd', '**/*.html', '**/*.json', '**/*.sql', '**/*.rb', '**/*.vm', '**/*.snap', '**/*.svg', '**/*.jar', '**/*.zip', '**/*.log', '**/*.cnf', '**/*.jks', '**/README', '**/*.pdf'])
  }

  publishing {
    publications {
      mavenJava(MavenPublication) {
        pom.withXml {
          asNode().appendNode('name', projectTitle)
          asNode().appendNode('description', description)
          asNode().appendNode('url', 'http://www.sonarqube.org/')

          def organization = asNode().appendNode('organization')
          organization.appendNode('name', 'SonarSource')
          organization.appendNode('url', 'http://www.sonarsource.com')

          def licenses = asNode().appendNode('licenses')
          def license = licenses.appendNode('license')
          license.appendNode('name', 'GNU LGPL 3')
          license.appendNode('url', 'http://www.gnu.org/licenses/lgpl.txt')
          license.appendNode('distribution', 'repo')

          def scm = asNode().appendNode('scm')
          scm.appendNode('url', 'https://github.com/SonarSource/sonarqube')

          def developers = asNode().appendNode('developers')
          def developer = developers.appendNode('developer')
          developer.appendNode('id', 'bellingard')
          developer.appendNode('name', 'Fabrice Bellingard')

          developer = developers.appendNode('developer')
          developer.appendNode('id', 'dbolkensteyn')
          developer.appendNode('name', 'Dinesh Bolkensteyn')

          developer = developers.appendNode('developer')
          developer.appendNode('id', 'ehartmann')
          developer.appendNode('name', 'Eric Hartmann')

          developer = developers.appendNode('developer')
          developer.appendNode('id', 'fmallet')
          developer.appendNode('name', 'Freddy Mallet')

          developer = developers.appendNode('developer')
          developer.appendNode('id', 'Godin')
          developer.appendNode('name', 'Evgeny Mandrikov')

          developer = developers.appendNode('developer')
          developer.appendNode('id', 'henryju')
          developer.appendNode('name', 'Julien Henry')

          developer = developers.appendNode('developer')
          developer.appendNode('id', 'jblievremont')
          developer.appendNode('name', 'Jean-Baptiste Lievremont')

          developer = developers.appendNode('developer')
          developer.appendNode('id', 'julienlancelot')
          developer.appendNode('name', 'Julien Lancelot')

          developer = developers.appendNode('developer')
          developer.appendNode('id', 'olivier.gaudin')
          developer.appendNode('name', 'Olivier Gaudin')

          developer = developers.appendNode('developer')
          developer.appendNode('id', 'simonbrandhof')
          developer.appendNode('name', 'Simon Brandhof')

          developer = developers.appendNode('developer')
          developer.appendNode('id', 'sns-seb')
          developer.appendNode('name', 'Sebastien Lesaint')

          developer = developers.appendNode('developer')
          developer.appendNode('id', 'stas-vilchik')
          developer.appendNode('name', 'Stas Vilchik')

          developer = developers.appendNode('developer')
          developer.appendNode('id', 'teryk')
          developer.appendNode('name', 'Teryk Bellahsene')
        }
      }
    }
  }
}

artifactory {
  clientConfig.setIncludeEnvVars(true)
  clientConfig.setEnvVarsExcludePatterns('*password*,*PASSWORD*,*secret*,*MAVEN_CMD_LINE_ARGS*,sun.java.command,*token*,*TOKEN*,*LOGIN*,*login*')
  contextUrl = System.getenv('ARTIFACTORY_URL')
  publish {
    repository {
      repoKey = System.getenv('ARTIFACTORY_DEPLOY_REPO')
      username = System.getenv('ARTIFACTORY_DEPLOY_USERNAME') ?: project.properties.artifactoryUsername
      password = System.getenv('ARTIFACTORY_DEPLOY_PASSWORD') ?: project.properties.artifactoryPaswword
    }
    defaults {
      properties = [
        'build.name': 'sonar-enterprise',
        'build.number': (System.getenv('BUILD_ID') ?: System.getenv('BUILD_NUMBER')),
        'pr.branch.target': System.getenv('GITHUB_TARGET_BRANCH'),
        'pr.number': System.getenv('PULL_REQUEST'),
        'vcs.branch': System.getenv('GITHUB_BASE_BRANCH') ?: System.getenv('GITHUB_BRANCH'),
        'vcs.revision': System.getenv('GIT_SHA1'),
        'version': version
      ]
      publications('mavenJava')
      publishPom = true
      publishIvy = false
    }
  }
  clientConfig.info.setBuildName('sonar-enterprise')
  clientConfig.info.setBuildNumber(System.getenv('BUILD_NUMBER'))
  // Define the artifacts to be deployed to https://sonarsource.bintray.com on releases
  clientConfig.info.addEnvironmentProperty('ARTIFACTS_TO_PUBLISH',
      "${project.group}:sonar-application:zip," +
      "com.sonarsource.sonarqube:sonarqube-developer:zip," +
      "com.sonarsource.sonarqube:sonarqube-datacenter:zip," +
      "com.sonarsource.sonarqube:sonarqube-enterprise:zip")
  clientConfig.info.addEnvironmentProperty('ARTIFACTS_TO_DOWNLOAD',
      'com.sonarsource.sonarqube:sonarcloud:zip,' +
      'com.sonarsource.sonarqube:sonarqube-developer:yguard,' +
      'com.sonarsource.sonarqube:sonarqube-datacenter:yguard,' +
      'com.sonarsource.sonarqube:sonarqube-enterprise:yguard')
  // The name of this variable is important because it's used by the delivery process when extracting version from Artifactory build info.
  clientConfig.info.addEnvironmentProperty('PROJECT_VERSION', "${version}")
}