-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathbuild.gradle
More file actions
213 lines (190 loc) · 7.77 KB
/
build.gradle
File metadata and controls
213 lines (190 loc) · 7.77 KB
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
plugins {
id 'org.sonarqube' version '7.0.0.6105'
id 'com.jfrog.artifactory' version '6.0.4'
id 'java'
id 'jacoco'
id 'maven-publish'
id 'com.github.hierynomus.license' version '0.16.1'
id 'signing'
}
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
ext {
release = project.hasProperty('release') && project.getProperty('release')
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)
}
compileJava {
// Setting the compatibility to Java 11 (https://docs.gradle.org/7.6.3/userguide/building_java_projects.html#sec:java_cross_compilation)
options.release = 11
}
tasks.withType(Javadoc) {
options.encoding = 'UTF-8'
// Workaround for bug in JDK 11.0.7 - https://bugs.openjdk.org/browse/JDK-8295850
options.addStringOption("tag", "javax.annotation.ParametersAreNonnullByDefault:ParametersAreNonnullByDefault")
}
sonarqube {
properties {
property 'sonar.organization', 'sonarsource'
property 'sonar.projectName', projectTitle
property 'sonar.projectKey', project.group + ':sonar-jacoco'
property 'sonar.sca.exclusions', 'its/src/test/resources/**'
}
}
jacocoTestReport {
reports {
xml.required = true
csv.required = false
html.required = false
}
}
test.finalizedBy jacocoTestReport
dependencies {
compileOnly('com.google.code.findbugs:jsr305:3.0.2')
compileOnly('org.sonarsource.api.plugin:sonar-plugin-api:13.2.0.3137')
implementation('org.slf4j:slf4j-api:2.0.17')
testImplementation(platform('org.junit:junit-bom:5.6.2'))
testImplementation('org.junit.jupiter:junit-jupiter')
testImplementation('org.junit.jupiter:junit-jupiter-migrationsupport')
testRuntimeOnly('org.junit.platform:junit-platform-launcher')
testImplementation('ch.qos.logback:logback-classic:1.5.27')
testImplementation('org.mockito:mockito-core:4.9.0')
testImplementation('org.assertj:assertj-core:3.10.0')
testImplementation('org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures:13.2.0.3137')
testImplementation('org.sonarsource.sonarqube:sonar-plugin-api-impl:26.1.0.118079')
}
test {
useJUnitPlatform()
}
license {
header = rootProject.file('LICENSE_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'])
}
jar {
manifest {
def version = archiveVersion.getOrNull()
def displayVersion = project.hasProperty('buildNumber') ? version.substring(0, version.lastIndexOf('.')) + " (build ${project.buildNumber})" : version
def buildDate = new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
attributes(
'Build-Time': buildDate,
'Implementation-Build': 'git rev-parse HEAD'.execute().text.trim(),
'Plugin-BuildDate': buildDate,
'Plugin-ChildFirstClassLoader': 'false',
'Plugin-Class': 'org.sonar.plugins.jacoco.JacocoPlugin',
'Plugin-Description': 'JaCoCo XML report importer',
'Plugin-Display-Version': displayVersion,
'Plugin-IssueTrackerUrl': 'https://jira.sonarsource.com/browse/JACOCO',
'Plugin-Key': 'jacoco',
'Plugin-License': 'GNU LGPL 3',
'Plugin-Name': 'JaCoCo',
'Plugin-Organization': 'SonarSource',
'Plugin-OrganizationUrl': 'http://www.sonarsource.com',
'Plugin-SourcesUrl': 'https://github.com/SonarSource/sonar-jacoco',
'Plugin-Version': archiveVersion,
'Plugin-RequiredForLanguages': 'gosu,groovy,java,kotlin,scala',
'Sonar-Version': '6.7',
'SonarLint-Supported': 'false',
'Version': "${archiveVersion}",
)
}
}
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier = 'sources'
}
task javadocJar(type: Jar) {
from javadoc
archiveClassifier = 'javadoc'
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact tasks.sourcesJar
artifact tasks.javadocJar
pom {
name = projectTitle
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/sonar-jacoco'
}
developers {
developer {
id = 'sonarsource-team'
name = 'SonarSource Team'
}
}
}
}
}
}
signing {
def signingKey = findProperty("signingKey")
def signingKeyId = findProperty("signingKeyId")
def signingPassword = findProperty("signingPassword")
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
required = {
def branch = System.getenv()["GITHUB_REF_NAME"]
return (branch == 'master' || branch ==~ 'branch-[\\d.]+') &&
gradle.taskGraph.hasTask(":artifactoryPublish")
}
sign publishing.publications
}
artifactory {
clientConfig.setIncludeEnvVars(true)
clientConfig.setEnvVarsExcludePatterns('*password*,*PASSWORD*,*secret*,*MAVEN_CMD_LINE_ARGS*,sun.java.command,*token*,*TOKEN*,*LOGIN*,*login*,*key*,*KEY*,*signing*')
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-jacoco',
'build.number': (System.getenv('BUILD_ID') ?: 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
]
publications('mavenJava')
publishPom = true
publishIvy = false
}
}
clientConfig.info.setBuildName('sonar-jacoco')
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-jacoco-plugin:jar")
// 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}")
}