buildscript { repositories { maven { url 'https://repox.jfrog.io/repox/plugins.gradle.org/' } } dependencies { // Ordered alphabeticly to avoid duplication classpath 'com.github.ben-manes:gradle-versions-plugin:0.27.0' classpath 'com.github.jengelman.gradle.plugins:shadow:5.1.0' classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.10' classpath 'com.moowork.gradle:gradle-node-plugin:1.3.1' classpath 'gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.14.0' classpath 'io.spring.gradle:dependency-management-plugin:1.0.4.RELEASE' classpath 'net.rdrei.android.buildtimetracker:gradle-plugin:0.11.1' classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.10.0' classpath 'org.owasp:dependency-check-gradle:5.2.2' classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.8' } } // display a summary of task durations at the end of the build if (project.hasProperty('time-tracker')) { apply plugin: 'build-time-tracker' buildtimetracker { reporters { summary { ordered true threshold 1000 barstyle 'ascii' } } } } if (!JavaVersion.current().java11Compatible) { throw new GradleException("JDK 11+ is required to perform this build. It's currently " + System.getProperty("java.home") + ".") } allprojects { apply plugin: 'com.jfrog.artifactory' apply plugin: 'maven-publish' ext.versionInSources = version ext.buildNumber = System.getProperty("buildNumber") // when no buildNumber is provided, then project version must end with '-SNAPSHOT' if (ext.buildNumber == null) { version = "${version}-SNAPSHOT".toString() ext.versionWithoutBuildNumber = version } else { ext.versionWithoutBuildNumber = version version = (version.toString().count('.') == 1 ? "${version}.0.${ext.buildNumber}" : "${version}.${ext.buildNumber}").toString() } ext { release = project.hasProperty('release') && project.getProperty('release') official = project.hasProperty('official') && project.getProperty('official') } repositories { def repository = project.hasProperty('qa') ? 'sonarsource-qa' : 'sonarsource' maven { url "https://repox.jfrog.io/repox/${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 } } } } } apply plugin: 'org.sonarqube' sonarqube { properties { property 'sonar.projectName', projectTitle property 'sonar.projectVersion', "${versionInSources}-SNAPSHOT" property 'sonar.buildString', version } } subprojects { apply plugin: 'com.github.hierynomus.license' apply plugin: 'io.spring.dependency-management' apply plugin: 'jacoco' apply plugin: 'java' apply plugin: 'idea' apply plugin: 'org.owasp.dependencycheck' sourceCompatibility = 1.8 targetCompatibility = 1.8 // do not deploy to Artifactory by default artifactoryPublish.skip = true def testFixtureSrc = 'src/testFixtures' if (file(testFixtureSrc).exists()) { apply plugin: 'java-test-fixtures' } ext { protobufVersion = '3.10.0' jjwtVersion = '0.10.7' } sonarqube { properties { property 'sonar.moduleKey', project.group + ':' + project.name } } // Central place for definition dependency versions and exclusions. dependencyManagement { dependencies { // bundled plugin list -- keep it alphabetically ordered // comment is used by the Plugin Update bot to identify bundled plugins to check updates for // // !!! do not use variable for version number, bot in charge of updating plugin does not support them !! // // comment format is: // bundled_plugin:[updateCenterKey]:[githubRepository] // updateCenterKey: Update Center Plugin key, last release will be resolved from repox when not provided // githubRepository: name of github repository of the plugin in the SonarSource organisation dependency 'com.sonarsource.abap:sonar-abap-plugin:3.8.0.2034' // bundled_plugin:abap:sonar-abap dependency 'com.sonarsource.cobol:sonar-cobol-plugin:4.4.0.3403' // bundled_plugin:cobol:sonar-cobol dependency 'com.sonarsource.cpp:sonar-cfamily-plugin:6.6.0.13759' // bundled_plugin:cpp:sonar-cpp dependency 'com.sonarsource.pli:sonar-pli-plugin:1.10.0.1880' // bundled_plugin:pli:sonar-pli dependency 'com.sonarsource.plsql:sonar-plsql-plugin:3.4.1.2576' // bundled_plugin:plsql:sonar-plsql dependency 'com.sonarsource.plugins.vb:sonar-vb-plugin:2.6.0.1875' // bundled_plugin:vb:sonar-vb dependency 'com.sonarsource.rpg:sonar-rpg-plugin:2.3.0.1187' // bundled_plugin:rpg:sonar-rpg dependency 'com.sonarsource.security:sonar-security-csharp-frontend-plugin:8.1.0.675' // bundled_plugin::sonar-security dependency 'com.sonarsource.security:sonar-security-java-frontend-plugin:8.1.0.675' // bundled_plugin::sonar-security dependency 'com.sonarsource.security:sonar-security-php-frontend-plugin:8.1.0.675' // bundled_plugin::sonar-security dependency 'com.sonarsource.security:sonar-security-plugin:8.1.0.675' // bundled_plugin::sonar-security dependency 'com.sonarsource.security:sonar-security-python-frontend-plugin:8.1.0.675' // bundled_plugin::sonar-security dependency 'com.sonarsource.slang:sonar-apex-plugin:1.7.0.883' // bundled_plugin:sonarapex:slang-enterprise dependency 'com.sonarsource.swift:sonar-swift-plugin:4.2.2.77' // bundled_plugin:swift:sonar-swift dependency 'com.sonarsource.tsql:sonar-tsql-plugin:1.4.0.3334' // bundled_plugin:tsql:sonar-tsql dependency 'org.sonarsource.css:sonar-css-plugin:1.1.1.1010' // bundled_plugin:cssfamily:sonar-css dependency 'org.sonarsource.dotnet:sonar-csharp-plugin:8.1.0.13383' // bundled_plugin:csharp:sonar-dotnet dependency 'org.sonarsource.dotnet:sonar-vbnet-plugin:8.1.0.13383' // bundled_plugin:vbnet:sonar-dotnet dependency 'org.sonarsource.flex:sonar-flex-plugin:2.5.1.1831' // bundled_plugin:flex:sonar-flex dependency 'org.sonarsource.html:sonar-html-plugin:3.2.0.2082' // bundled_plugin:web:sonar-html dependency 'org.sonarsource.jacoco:sonar-jacoco-plugin:1.0.2.475' // bundled_plugin:jacoco:sonar-jacoco dependency 'org.sonarsource.java:sonar-java-plugin:6.0.0.20538' // bundled_plugin:java:sonar-java dependency 'org.sonarsource.javascript:sonar-javascript-plugin:6.1.0.11503' // bundled_plugin:javascript:SonarJS dependency 'org.sonarsource.php:sonar-php-plugin:3.3.0.5166' // bundled_plugin:php:sonar-php dependency 'org.sonarsource.python:sonar-python-plugin:2.3.0.5351' // bundled_plugin:python:sonar-python dependency 'org.sonarsource.scm.git:sonar-scm-git-plugin:1.9.1.1834' // bundled_plugin:scmgit:sonar-scm-git dependency 'org.sonarsource.scm.svn:sonar-scm-svn-plugin:1.9.0.1295' // bundled_plugin:scmsvn:sonar-scm-svn dependency 'org.sonarsource.slang:sonar-go-plugin:1.6.0.719' // bundled_plugin:go:slang-enterprise dependency 'org.sonarsource.slang:sonar-kotlin-plugin:1.5.0.315' // bundled_plugin:kotlin:slang-enterprise dependency 'org.sonarsource.slang:sonar-ruby-plugin:1.5.0.315' // bundled_plugin:ruby:slang-enterprise dependency 'org.sonarsource.slang:sonar-scala-plugin:1.5.0.315' // bundled_plugin:sonarscala:slang-enterprise dependency 'org.sonarsource.typescript:sonar-typescript-plugin:2.1.0.4359' // bundled_plugin:typescript:SonarTS dependency 'org.sonarsource.xml:sonar-xml-plugin:2.0.1.2020' // bundled_plugin:xml:sonar-xml // 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.12' 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.10.1') { entry 'jackson-core' entry 'jackson-annotations' entry 'jackson-databind' } dependency 'com.eclipsesource.minimal-json:minimal-json:0.9.5' dependency 'com.github.kevinsawicki:http-request:5.4.1' dependency 'com.github.scribejava:scribejava-core:6.8.1' dependency 'com.github.scribejava:scribejava-apis:6.8.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.5' dependency 'com.google.guava:guava:28.1-jre' dependency "com.google.protobuf:protobuf-java:${protobufVersion}" dependency 'com.h2database:h2:1.4.199' dependencySet(group: 'com.hazelcast', version: '3.12.3') { entry 'hazelcast' entry 'hazelcast-client' } dependency 'com.ibm.icu:icu4j:3.4.4' dependency 'com.microsoft.sqlserver:mssql-jdbc:7.2.2.jre11' dependency 'com.oracle.jdbc:ojdbc8:19.3' dependencySet(group: 'com.squareup.okhttp3', version: '3.14.2') { entry 'okhttp' entry 'mockwebserver' } dependency 'com.tngtech.java:junit-dataprovider:1.9.2' dependency 'info.picocli:picocli:3.6.1' dependency "io.jsonwebtoken:jjwt-api:${jjwtVersion}" dependency "io.jsonwebtoken:jjwt-impl:${jjwtVersion}" dependency "io.jsonwebtoken:jjwt-jackson:${jjwtVersion}" dependency 'io.netty:netty-all:4.0.51.Final' dependency 'com.sun.mail:javax.mail:1.5.6' dependency 'javax.annotation:javax.annotation-api:1.3.1' dependency 'javax.servlet:javax.servlet-api:3.1.0' dependency 'javax.xml.bind:jaxb-api:2.3.0' dependency 'junit:junit:4.12' dependency 'org.junit.jupiter:junit-jupiter-api:5.5.2' dependency 'net.jpountz.lz4:lz4:1.3.0' dependency 'net.lightbody.bmp:littleproxy:1.1.0-beta-bmp-17' dependency 'org.awaitility:awaitility:4.0.1' dependency 'org.apache.commons:commons-csv:1.7' dependency 'org.apache.commons:commons-email:1.5' dependency 'org.apache.commons:commons-dbcp2:2.7.0' dependency('org.apache.httpcomponents:httpclient:4.5.10'){ 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.41') { entry 'tomcat-embed-core' entry('tomcat-embed-jasper') { exclude 'org.eclipse.jdt.core.compiler:ecj' } } dependency 'org.assertj:assertj-core:3.13.2' dependency 'org.assertj:assertj-guava:3.2.1' 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' } dependencySet(group: 'org.eclipse.jetty', version: '9.4.6.v20170531') { entry 'jetty-proxy' entry 'jetty-server' entry 'jetty-servlet' } dependency('org.elasticsearch.client:transport:6.8.4') { exclude 'org.elasticsearch.plugin:lang-mustache-client' exclude 'commons-logging:commons-logging' exclude 'org.elasticsearch.plugin:reindex-client' exclude 'org.elasticsearch.plugin:rank-eval-client' } dependency 'org.elasticsearch:mocksocket:1.0' dependency 'org.codelibs.elasticsearch.module:analysis-common:6.8.4' dependency 'org.freemarker:freemarker:2.3.20' dependency 'org.hamcrest:hamcrest-all:1.3' dependency 'org.jsoup:jsoup:1.12.1' dependency 'org.mindrot:jbcrypt:0.4' dependency('org.mockito:mockito-core:3.1.0') { exclude 'org.hamcrest:hamcrest-core' } dependency 'org.mybatis:mybatis:3.5.3' dependency 'org.nanohttpd:nanohttpd:2.3.0' dependency 'org.picocontainer:picocontainer:2.15' dependencySet(group: 'org.slf4j', version: '1.7.28') { entry 'jcl-over-slf4j' entry 'jul-to-slf4j' entry 'log4j-over-slf4j' entry 'slf4j-api' } dependency 'org.postgresql:postgresql:42.2.8' dependency 'org.reflections:reflections:0.9.9' dependency 'org.simpleframework:simple:4.1.21' dependency 'org.sonarsource.orchestrator:sonar-orchestrator:3.27.0.2172' dependency 'org.sonarsource.update-center:sonar-update-center-common:1.23.0.723' dependency 'org.subethamail:subethasmtp:3.1.7' dependency 'org.yaml:snakeyaml:1.25' dependency 'xml-apis:xml-apis:1.4.01' // please keep this list alphabetically ordered } } // global exclusions configurations.all { // do not conflict with com.sun.mail:javax.mail exclude group: 'javax.mail', module: 'mail' } tasks.withType(JavaCompile) { options.compilerArgs.addAll(['--release', '8']) options.encoding = 'UTF-8' } tasks.withType(Javadoc) { options.addStringOption('Xdoclint:none', '-quiet') options.encoding = 'UTF-8' title = project.name + ' ' + versionWithoutBuildNumber } task sourcesJar(type: Jar, dependsOn: classes) { classifier = 'sources' from sourceSets.main.allSource } task javadocJar(type: Jar, dependsOn: javadoc) { classifier = 'javadoc' from javadoc.destinationDir } // generate code before opening project in IDE (Eclipse or Intellij) task ide() { // empty by default. Dependencies are added to the task // when needed (see protobuf modules for example) } jacocoTestReport { reports { xml.enabled true csv.enabled false html.enabled false } } normalization { runtimeClasspath { // Following classpath resources contain volatile data that changes in each CI build (build number, commit id, time), // so we exclude them from calculation of build cache key of test tasks: ignore 'META-INF/MANIFEST.MF' ignore 'sonar-api-version.txt' ignore 'sq-version.txt' } } test { jvmArgs '-Dfile.encoding=UTF8' maxHeapSize = '1G' systemProperty 'java.awt.headless', true testLogging { events "skipped", "failed" // verbose log for failed and skipped tests (by default the name of the tests are not logged) exceptionFormat 'full' // log the full stack trace (default is the 1st line of the stack trace) } jacoco { enabled = true // do not disable recording of code coverage, so that remote Gradle cache entry can be used locally includes = ['com.sonar.*', 'com.sonarsource.*', 'org.sonar.*', 'org.sonarqube.*', 'org.sonarsource.*'] } if (project.hasProperty('maxParallelTests')) { maxParallelForks = project.maxParallelTests as int } if (project.hasProperty('parallelTests')) { // See https://guides.gradle.org/performance/#parallel_test_execution maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1 } } def protoMainSrc = 'src/main/protobuf' def protoTestSrc = 'src/test/protobuf' if (file(protoMainSrc).exists() || file(protoTestSrc).exists()) { // protobuf must be applied after java apply plugin: 'com.google.protobuf' 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}" } } jar { exclude('**/*.proto') } idea { module { sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java") testSourceDirs += file("${protobuf.generatedFilesBaseDir}/test/java") generatedSourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java") generatedSourceDirs += file("${protobuf.generatedFilesBaseDir}/test/java") } } ide.dependsOn(['generateProto', 'generateTestProto']) } if (file('package.json').exists()) { apply plugin: 'com.moowork.node' node { version = '10.15.3' yarnVersion = '1.15.2' download = true } } if (official) { jar { // do not break incremental build on non official versions manifest { attributes( 'Version': "${version}", 'Implementation-Build': System.getenv('GIT_SHA1'), 'Build-Time': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") ) } } } license { header = rootProject.file('HEADER') strictCheck true mapping { java = 'SLASHSTAR_STYLE' js = 'SLASHSTAR_STYLE' ts = 'SLASHSTAR_STYLE' tsx = 'SLASHSTAR_STYLE' css = 'SLASHSTAR_STYLE' } includes(['**/*.java', '**/*.js', '**/*.ts', '**/*.tsx', '**/*.css']) } publishing { publications { mavenJava(MavenPublication) { pom { name = 'SonarQube' description = project.description url = 'http://www.sonarqube.org/' organization { name = 'SonarSource' url = 'http://www.sonarsource.com' } licenses { license { name = 'GNU LGPL 3' url = 'http://www.gnu.org/licenses/lgpl.txt' distribution = 'repo' } } scm { url = 'https://github.com/SonarSource/sonarqube' } developers { developer { id = 'sonarsource-team' name = 'SonarSource Team' } } } } } } } // Yarn doesn't support concurrent access to its global cache, // i.e. parallel execution of several "yarn install" tasks, // since these tasks are independent, we can establish arbitrary total order // to prevent their concurrent execution. // Note that "task1.mustRunAfter(task2)" ordering has an effect only when both // tasks are scheduled for execution, therefore should be established between // all pairs of "yarn install" tasks to define their total order and to prevent // their concurrent execution even in case when one or more of these tasks not // scheduled. def yarnInstallTasks = allprojects.findResults { it -> it.tasks.findByName('yarn') } yarnInstallTasks.drop(1).eachWithIndex { it, i -> it.mustRunAfter(yarnInstallTasks[0..i]) } // by default, Yarn will update lock file if it is not up to date with "package.json" // using option "--frozen-lockfile" will disable this behavior and "yarn install" will fail if lock file is out of date // all "yarn install" tasks should be executed with this option for reproducibility of builds // and to prevent developers from forgetting to update lock file when they update "package.json" yarnInstallTasks.each { it -> it.args = ['--frozen-lockfile'] } artifactory { clientConfig.setIncludeEnvVars(true) clientConfig.setEnvVarsExcludePatterns('*password*,*PASSWORD*,*secret*,*MAVEN_CMD_LINE_ARGS*,sun.java.command,*token*,*TOKEN*,*LOGIN*,*login*,*key*,*KEY*') 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_NUMBER'), 'pr.branch.target': System.getenv('GITHUB_BASE_BRANCH'), 'pr.number': System.getenv('PULL_REQUEST'), 'vcs.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://binaries.sonarsource.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") // 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}") } // https://github.com/ben-manes/gradle-versions-plugin apply plugin: 'com.github.ben-manes.versions' // Exclude dev versions from the list of dependency upgrades, for // example to replace: // org.slf4j:log4j-over-slf4j [1.7.25 -> 1.8.0-beta4] // by // org.slf4j:log4j-over-slf4j [1.7.25 -> 1.7.26] dependencyUpdates.resolutionStrategy { componentSelection { rules -> rules.all { ComponentSelection selection -> boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm', 'preview'].any { qualifier -> selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-]*/ } if (rejected) { selection.reject('Development version') } } } }