-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
227 lines (195 loc) · 6.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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
import static org.gradle.jvm.toolchain.JavaLanguageVersion.of
import static org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
import static org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_8
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id 'org.jetbrains.kotlin.jvm' apply false
id 'base'
id 'io.gitlab.arturbosch.detekt' apply false
id 'jacoco' // test coverage
id 'corda.root-publish'
id 'io.snyk.gradle.plugin.snykplugin'
id 'com.github.ben-manes.versions' // discover possible dependency version upgrades
id 'org.cyclonedx.bom' apply false
id "org.sonarqube"
}
snyk {
api = project.findProperty("snykApiToken") ?: System.getenv('SNYK_TOKEN')
arguments = project.findProperty("snykArguments") ?: '--all-sub-projects'
severity = project.findProperty("snykSeverity") ?: 'low'
autoDownload = true
autoUpdate = true
}
sonar {
properties {
property "sonar.projectKey", "corda"
property "sonar.organization", "corda"
property "sonar.host.url", "https://sonarcloud.io"
}
}
ext.pluginsDir = "$buildDir/plugins"
if (System.getenv("RELEASE_VERSION")?.trim()) {
version = System.getenv("RELEASE_VERSION")
} else {
def versionSuffix = '-SNAPSHOT'
if (System.getenv('VERSION_SUFFIX')) {
versionSuffix = System.getenv('VERSION_SUFFIX')
}
version = "$cliHostVersion$versionSuffix"
}
subprojects {
group = 'net.corda.cli'
version rootProject.version
pluginManager.withPlugin('org.jetbrains.kotlin.jvm'){
apply plugin: 'io.gitlab.arturbosch.detekt'
kotlin {
jvmToolchain {
languageVersion = of(17)
}
}
dependencies {
detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:$detektPluginVersion"
}
}
pluginManager.withPlugin('io.gitlab.arturbosch.detekt'){
dependencies {
detekt "io.gitlab.arturbosch.detekt:detekt-cli:$detektPluginVersion"
constraints {
detekt("org.yaml:snakeyaml:$snakeyamlVersion") {
because "required until detekt plugin updates it's internal version of snakeYaml, not fixed as of detekt version 1.21"
}
}
}
}
tasks.withType(KotlinCompile).configureEach {
compilerOptions {
languageVersion = KOTLIN_1_8
apiVersion = KOTLIN_1_8
jvmTarget = JVM_17
verbose = true
javaParameters = true
freeCompilerArgs.addAll([
"-Xjvm-default=all"
])
}
}
tasks.withType(GenerateModuleMetadata).configureEach {
enabled = false
}
tasks.register('compileAll') { task ->
description = "Compiles all the Kotlin and Java classes, including all of the test classes."
group = "verification"
task.dependsOn tasks.withType(AbstractCompile), tasks.withType(KotlinCompile)
}
apply plugin: 'io.gitlab.arturbosch.detekt'
apply plugin: 'jacoco'
apply plugin: 'maven-publish'
apply plugin: 'org.cyclonedx.bom'
cyclonedxBom {
includeConfigs = ["runtimeClasspath"]
skipProjects = [rootProject.name]
destination = file("${buildDir}/reports/SBOM")
outputName = "${project.name}-corda-cli-plugin-host-sbom"
}
tasks.named("detekt").configure {
if(file("$projectDir/detekt-baseline.xml").exists()){
baseline = file("$projectDir/detekt-baseline.xml")
}
ignoreFailures = true
config.setFrom(files("$rootDir/detekt-config.yml"))
parallel = true
reports {
xml{
outputLocation.set(file("$projectDir/build/detekt-report.xml"))
}
txt.required.set(false)
sarif.required.set(false)
html.required.set(false)
}
}
tasks.register('releasableArtifacts') {
description = "Prints a list of all modules which will be released externally"
group = "Release"
if (project.hasProperty('releasable') && project.releasable.toBoolean()) {
logArtifacts(project)
}
}
tasks.register('unReleasableArtifacts') {
description = "Prints a list of all modules which will not be released externally"
group = "Release"
if (!project.hasProperty('releasable') || !project.releasable.toBoolean()) {
logArtifacts(project)
}
}
}
tasks.named("wrapper") {
gradleVersion = '8.4'
distributionType = Wrapper.DistributionType.BIN
}
tasks.register("generateVersionedScripts"){
description 'Wrapper task to ensure we have the correct version specified in provided scripts'
dependsOn cleanDir, copyScripts
}
tasks.register("cleanDir", Delete){
description 'Removes any previously generated scripts'
delete 'build/generatedScripts'
}
tasks.register("copyScripts", Copy){
mustRunAfter cleanDir
description 'Copy corda-cli scripts to a location in build dir and update to use correct version'
from 'templateScripts'
into 'build/generatedScripts'
filter {
String line -> line.replaceAll("corda-cli-.(.)*.jar", "corda-cli-${version}.jar")
}
}
def isNonStable = { String version ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
def regex = /^[0-9,.v-]+(-r)?$/
return !stableKeyword && !(version ==~ regex)
}
tasks.named("dependencyUpdates").configure {
rejectVersionIf {
isNonStable(it.candidate.version) && !isNonStable(it.currentVersion)
}
}
// Automatically ran as part of build process
assemble.finalizedBy(generateVersionedScripts)
// helper to log artifacts we will or will not publish during a release process
def logArtifacts(Project project) {
project.publishing.publications.each { publication ->
logger.quiet("\n${publication.groupId}:${publication.artifactId}:${publication.version} [${project.path}]")
publication.artifacts.each { artifact ->
logger.quiet(" * ${artifact.file.name}")
}
}
}
tasks.register('createSBOMZip', Zip) {
description = 'Create SBOM zip file for release'
group = 'documentation'
String sourceDestFolder = buildDir.toString() + "/archive/SBOM/"
archiveFileName = "${project.name}-SBOM-${project.version}.zip"
subprojects.each {
String srcPath = it.buildDir.toString() + "/reports/SBOM/"
it.copy{
from srcPath
into sourceDestFolder
}
}
from sourceDestFolder
destinationDirectory = (file(buildDir.toString() + "/archive/corda-cli-plugin-host-SBOM/"))
}
if (project.hasProperty('generateSBOM')) {
publishing {
publications {
sbom(MavenPublication) {
artifact createSBOMZip
artifactId "${project.name}-sbom"
groupId 'net.corda'
}
}
}
artifactoryPublish {
publications('sbom')
}
}