This repository has been archived by the owner on Jul 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
build.gradle
172 lines (149 loc) · 6.77 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
plugins {
id 'org.sonarqube' version '2.6.2'
id 'com.jfrog.artifactory' version '4.9.5'
id 'io.spring.dependency-management' version '1.0.4.RELEASE' apply false
id 'com.github.hierynomus.license' version "0.14.0"
}
sonarqube {
properties {
property 'sonar.projectName', projectTitle
}
}
allprojects {
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)
}
repositories {
def repository = project.hasProperty('cix') ? 'sonarsource-qa' : 'sonarsource'
maven {
url "https://repox.jfrog.io/repox/${repository}"
}
}
}
subprojects {
// do not publish to Artifactory by default
artifactoryPublish.skip = true
apply plugin: 'com.github.hierynomus.license'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'jacoco'
apply plugin: 'java'
dependencyManagement {
dependencies {
dependency 'com.google.code.gson:gson:2.8.2'
dependency 'com.google.code.findbugs:jsr305:3.0.2'
dependency 'org.assertj:assertj-core:3.9.0'
dependencySet(group: 'org.junit.jupiter', version: '5.1.0') {
entry 'junit-jupiter-api'
entry 'junit-jupiter-engine'
entry 'junit-jupiter-params'
entry 'junit-jupiter-migrationsupport'
}
dependency 'org.junit.platform:junit-platform-launcher:1.1.0'
dependency('org.mockito:mockito-core:2.26.0') {
exclude 'org.hamcrest:hamcrest-core'
}
dependencySet(group: 'org.sonarsource.analyzer-commons', version: '1.7.0.243') {
entry 'sonar-analyzer-commons'
entry 'sonar-analyzer-test-commons'
}
dependency 'org.sonarsource.sonarqube:sonar-plugin-api:7.7'
dependency 'org.sonarsource.orchestrator:sonar-orchestrator:3.24.0.1993'
}
}
tasks.withType(JavaCompile) {
options.compilerArgs.addAll(['--release', '8'])
options.encoding = 'UTF-8'
}
jacoco {
toolVersion = "0.8.3"
}
license {
header = rootProject.file('LICENSE')
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", "**/*.md", "**/*.gradle", "**/*.go", "**/*.out"])
}
publishing {
publications {
mavenJava(MavenPublication) {
if (release) {
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/sonar-go')
def developers = asNode().appendNode('developers')
def developer = developers.appendNode('developer')
developer.appendNode('id', 'alban-auzeill')
developer.appendNode('name', 'Alban Auzeill')
developer = developers.appendNode('developer')
developer.appendNode('id', 'janos-ss')
developer.appendNode('name', 'Janos Gyerik')
developer = developers.appendNode('developer')
developer.appendNode('id', 'm-g-sonar')
developer.appendNode('name', 'Michael Gumowski')
developer = developers.appendNode('developer')
developer.appendNode('id', 'saberduck')
developer.appendNode('name', 'Tibor Blenessy')
}
}
}
}
}
}
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-go',
'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.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-go-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}")
}