forked from SonarSource/sonar-scanner-gradle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
210 lines (184 loc) · 5.92 KB
/
build.gradle
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
#!groovy
// The above triggers groovy syntax highlighting in vim
plugins {
id "com.gradle.plugin-publish" version "0.9.9"
// Eat your own dog food :)
id "org.sonarqube" version "2.7"
id "com.jfrog.artifactory" version "4.5.4"
id "com.github.hierynomus.license" version "0.14.0"
id "net.researchgate.release" version "2.6.0"
id "com.jfrog.bintray" version "1.7.3"
}
apply plugin: 'java-gradle-plugin'
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'maven-publish'
group = 'org.sonarsource.scanner.gradle'
description = 'Gradle plugin to help analyzing projects with SonarQube'
def projectName = 'SonarQube Scanner for Gradle'
def docUrl = 'http://redirect.sonarsource.com/doc/gradle.html'
def githubUrl = 'https://github.com/SonarSource/sonar-scanner-gradle'
sourceCompatibility = 1.8
targetCompatibility = 1.8
compileJava {
options.encoding = 'UTF-8'
}
javadoc {
options.encoding = 'UTF-8'
}
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 {
maven {
url "https://maven.google.com"
}
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
}
}
}
}
dependencies {
compile gradleApi()
compile 'org.sonarsource.scanner.api:sonar-scanner-api:2.14.0.2002'
compileOnly 'com.android.tools.build:gradle:3.1.0'
compileOnly 'com.google.code.findbugs:jsr305:3.0.2'
testCompile localGroovy()
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-all:1.3'
testCompile('org.spockframework:spock-core:1.1-groovy-2.4') {
exclude module : 'groovy-all'
}
}
pluginBundle {
website = docUrl
vcsUrl = githubUrl
description = project.description
tags = ['sonarqube', 'sonar', 'quality', 'qa']
plugins {
sonarqubePlugin {
id = 'org.sonarqube'
displayName = projectName
}
}
mavenCoordinates {
groupId = project.group
artifactId = "sonarqube-gradle-plugin"
}
}
sonarqube {
properties {
property 'sonar.projectName', projectName
}
}
license {
strictCheck true
exclude "**/version.txt"
}
jacoco {
toolVersion = "0.8.1"
}
// Add required informations to deploy on central
install {
repositories.mavenInstaller {
pom.project {
name projectName
description project.description
url docUrl
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 githubUrl
}
developers {
developer {
id 'henryju'
name 'Julien Henry'
}
}
}
}
}
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')
password = System.getenv('ARTIFACTORY_DEPLOY_PASSWORD')
}
defaults {
properties = [
'build.name': 'sonar-scanner-gradle',
'build.number': System.getenv('BUILD_NUMBER'),
'pr.branch.target': System.getenv('PULL_REQUEST_BRANCH_TARGET'),
'pr.number': System.getenv('PULL_REQUEST_NUMBER'),
'vcs.branch': System.getenv('GIT_BRANCH'),
'vcs.revision': System.getenv('GIT_COMMIT'),
'version': version
]
publishConfigs('archives', 'published')
publishPom = true // Publish generated POM files to Artifactory (true by default)
publishIvy = false // Publish generated Ivy descriptor files to Artifactory (true by default)
}
}
clientConfig.info.setBuildName('sonar-scanner-gradle')
clientConfig.info.setBuildNumber(System.getenv('BUILD_NUMBER'))
// 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}")
}
bintray {
user = System.getenv('BINTRAY_USER')
key = System.getenv('BINTRAY_KEY')
pkg {
repo = 'SonarQube'
name = project.group
userOrg = 'sonarsource'
version {
name = project.version
desc = "${project.description} ${project.version}"
released = new Date()
vcsTag = project.version
}
configurations = ['archives']
}
}
publishPlugins.dependsOn bintrayUpload
afterReleaseBuild.dependsOn publishPlugins
processResources {
filesMatching('**/version.txt') {
expand version: project.version
}
}