forked from blackducksoftware/detect
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
224 lines (184 loc) · 7.61 KB
/
build.gradle
File metadata and controls
224 lines (184 loc) · 7.61 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
214
215
216
217
218
219
220
221
222
223
224
import com.synopsys.integration.detect.artifactory.UpdateArtifactoryPropertiesTask
import com.synopsys.integration.detect.battery.UpdateBatteryTask
import com.synopsys.integration.detect.verification.VerifyBlackDuckDetectTask
buildscript {
ext {
springBootVersion = '2.4.3'
blackDuckCommonVersion = '54.2.1'
junitPlatformDefaultTestTags = 'integration, performance, battery'
}
apply from: 'https://raw.githubusercontent.com/blackducksoftware/integration-resources/master/gradle_common/buildscript-repositories.gradle', to: buildscript
apply from: 'https://raw.githubusercontent.com/blackducksoftware/integration-resources/master/gradle_common/buildscript-dependencies.gradle', to: buildscript
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
}
}
//TODO Remove this when the Spock dependency, Spock 2.0, is officially released. Upgrade to a Spring Boot version that depends on Groovy 3.0.0 and Spock 2.0 by default.
ext['groovy.version'] = '3.0.0'
group = 'com.synopsys.integration'
version = '7.1.0-SNAPSHOT'
apply plugin: 'com.synopsys.integration.solution'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply from: 'docs.gradle'
final def resources = new File("${projectDir}/src/main/resources")
final def versionFile = new File(resources, "version.txt")
resources.mkdirs()
versionFile.delete()
versionFile << version
def createArtifactName() {
return "${buildDir}/libs/${project.name}-${version}.jar"
}
def createBatteryPath() {
return "${buildDir}/battery/"
}
subprojects {
group = rootProject.group
version = rootProject.version
apply plugin: 'com.synopsys.integration.simple'
license {
header rootProject.file('LICENSE')
}
}
allprojects {
dependencies {
implementation "org.slf4j:slf4j-api:1.7.30"
implementation "org.apache.commons:commons-lang3:3.10" /* this could be managed by blackduck common */
implementation 'org.jetbrains:annotations:19.0.0'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.4.2'
testImplementation 'org.mockito:mockito-core:2.+'
}
}
publishing {
publications {
mavenJava(MavenPublication) {
def jarName = createArtifactName()
artifact(jarName)
}
}
}
artifactory {
publish {
defaults { publications('mavenJava') }
}
}
test {
testLogging {
exceptionFormat = 'full'
}
}
dependencies {
implementation project(':common')
implementation project(':configuration')
implementation project(':detectable')
implementation project(':detector')
implementation 'ch.qos.logback:logback-classic:1.2.3'
implementation 'com.esotericsoftware.yamlbeans:yamlbeans:1.11'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.9.8'
implementation "com.synopsys.integration:blackduck-common:${blackDuckCommonVersion}"
implementation 'com.synopsys:method-analyzer-core:0.1.0'
implementation 'org.apache.maven.shared:maven-invoker:3.0.0'
implementation "org.springframework.boot:spring-boot"
implementation 'org.yaml:snakeyaml:1.24'
implementation 'org.zeroturnaround:zt-zip:1.13'
implementation 'org.freemarker:freemarker:2.3.26-incubating'
// spring-boot-starter-test *can* provide these, but we choose to be more explicit about the dependencies we ACTUALLY use
testImplementation 'org.assertj:assertj-core:3.13.2'
testImplementation 'org.skyscreamer:jsonassert:1.5.0'
testImplementation project(':configuration').sourceSets.test.output
testImplementation project(':common-test')
}
springBoot { mainClass = 'com.synopsys.integration.detect.Application' }
tasks['testBattery'].doFirst {
def batteryPath = new File(createBatteryPath())
batteryPath.mkdirs()
environment 'BATTERY_TESTS_DETECT_JAR_PATH', createArtifactName()
environment 'BATTERY_TESTS_PATH', batteryPath.getCanonicalPath()
environment 'BATTERY_TESTS_JAVA_PATH', org.gradle.internal.jvm.Jvm.current().javaExecutable.getCanonicalPath()
}
task updateBattery(type: UpdateBatteryTask) {}
task updateArtifactoryProperties(type: UpdateArtifactoryPropertiesTask) {
dependsOn artifactoryDeploy
}
task runDetect(type: JavaExec) {
dependsOn build
classpath = files(createArtifactName())
classpath += sourceSets.main.runtimeClasspath
main = 'com.synopsys.integration.detect.Application'
args = ['--detect.risk.report.pdf=true']
}
task verifyBlackDuckDetect(type: VerifyBlackDuckDetectTask) {
dependsOn runDetect
task verifyDetect() {
dependsOn verifyBlackDuckDetect
}
}
String parseAirGapZipPath(ByteArrayOutputStream standardOutput) {
String marker = 'Detect Air Gap Zip: '
String line = standardOutput.toString().split('\n').find { it.contains(marker) }
String path = line.substring(line.lastIndexOf(marker) + marker.length()).trim()
println "Found Air Gap Zip: ${path}"
return path
}
task createAirGapZip(type: JavaExec) {
dependsOn build
classpath = files(createArtifactName())
classpath += sourceSets.main.runtimeClasspath
main = 'com.synopsys.integration.detect.Application'
args = ['--detect.gradle.path=gradlew', "--detect.output.path=${buildDir}/libs/", '-z']
standardOutput = new ByteArrayOutputStream()
doLast {
createAirGapZip.ext.airGapPath = parseAirGapZipPath(standardOutput)
}
}
task publishAirGapZip() {
dependsOn createAirGapZip
doLast {
def airGapZipName = "${project.name}-${version}-air-gap.zip"
def airGapZipLocation = createAirGapZip.airGapPath
exec {
commandLine 'curl', '--insecure', '-u', "${project.ext.artifactoryDeployerUsername}:${project.ext.artifactoryDeployerPassword}", '-X', 'PUT',
"${project.ext.deployArtifactoryUrl}/${project.ext.artifactoryRepo}/com/synopsys/integration/${project.name}/${version}/${airGapZipName}", '-T', "${airGapZipLocation}", '-f'
}
}
}
task createAirGapZipWithoutDocker(type: JavaExec) {
dependsOn build
classpath = files(createArtifactName())
classpath += sourceSets.main.runtimeClasspath
main = 'com.synopsys.integration.detect.Application'
args = ['--detect.gradle.path=gradlew', '-z', 'GRADLE,NUGET']
standardOutput = new ByteArrayOutputStream()
doLast {
createAirGapZipWithoutDocker.ext.airGapPath = parseAirGapZipPath(standardOutput)
}
}
task publishAirGapZipWithoutDocker() {
dependsOn createAirGapZipWithoutDocker
doLast {
def airGapZipName = "${project.name}-${version}-air-gap-gradle-nuget.zip"
def airGapZipLocation = createAirGapZipWithoutDocker.airGapPath
exec {
commandLine 'curl', '--insecure', '-u', "${project.ext.artifactoryDeployerUsername}:${project.ext.artifactoryDeployerPassword}", '-X', 'PUT',
"${project.ext.deployArtifactoryUrl}/${project.ext.artifactoryRepo}/com/synopsys/integration/${project.name}/${version}/${airGapZipName}", '-T', "${airGapZipLocation}", '-f'
}
}
}
task signJar() {
dependsOn build
finalizedBy 'verifyJar'
doLast {
exec {
commandLine 'jarsigner', '-tsa', 'http://tsa.starfieldtech.com/', '-storetype', 'pkcs12', '-storepass', "${jarSigningKeystorePassword}", '-keystore', "${jarSigningKeystorePath}", "${createArtifactName()}", "${jarSigningCertificateAlias}"
}
}
}
task verifyJar() {
dependsOn signJar
doLast {
exec {
// returns 0 if successfully verified as signed; non-0 if not
commandLine 'jarsigner', '-verify', '-strict', "${createArtifactName()}"
}
}
}