adding verify task
+import com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView
+import com.synopsys.integration.blackduck.api.generated.view.VersionBomComponentView
+import com.synopsys.integration.blackduck.configuration.BlackDuckServerConfig
+import com.synopsys.integration.blackduck.configuration.BlackDuckServerConfigBuilder
+import com.synopsys.integration.blackduck.service.BlackDuckService
+import com.synopsys.integration.blackduck.service.BlackDuckServicesFactory
+import com.synopsys.integration.blackduck.service.ProjectService
+import com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper
+import com.synopsys.integration.log.PrintStreamIntLogger
+
buildscript {
ext {
springBootVersion = '2.0.3.RELEASE'
@@ -11,6 +21,7 @@ buildscript {
dependencies {
classpath 'com.blackducksoftware.integration:common-gradle-plugin:0.0.+'
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
+ classpath 'com.blackducksoftware.integration:blackduck-common:42.2.1'
}
}
@@ -22,6 +33,10 @@ apply plugin: 'org.springframework.boot'
apply from: 'airgap.gradle'
apply from: 'artifactory-properties.gradle'
+def createArtifactName() {
+ return "${buildDir}/libs/${project.name}-${version}.jar"
+}
+
allprojects {
apply plugin: 'groovy'
apply plugin: 'io.spring.dependency-management'
@@ -51,7 +66,7 @@ subprojects {
publishing {
publications {
mavenJava(MavenPublication) {
- def jarName = "${buildDir}/libs/${project.name}-${version}.jar"
+ def jarName = createArtifactName()
artifact(jarName)
}
}
@@ -106,3 +121,40 @@ if ("true" == project.findProperty('refresh.cache')) {
}
}
}
+
+task runDetect(type: JavaExec) {
+ dependsOn build
+
+ classpath = files(createArtifactName())
+ classpath += sourceSets.main.runtimeClasspath
+ main = 'com.synopsys.integration.detect.Application'
+ args = ['--detect.tools.excluded=POLARIS', '--detect.ignore.connection.failures=true', '--detect.risk.report.pdf=true']
+}
+
+task verifyDetect() {
+ dependsOn runDetect
+
+ doLast {
+ BlackDuckServerConfigBuilder blackDuckServerConfigBuilder = BlackDuckServerConfig.newBuilder()
+ Set<String> environmentKeys = blackDuckServerConfigBuilder.getEnvironmentVariableKeys()
+ environmentKeys.each {
+ String value = System.getenv().get(it)
+ if (value) {
+ blackDuckServerConfigBuilder.setProperty(it, value)
+ }
+ }
+
+ BlackDuckServerConfig blackDuckServerConfig = blackDuckServerConfigBuilder.build()
+ BlackDuckServicesFactory blackDuckServicesFactory = blackDuckServerConfig.createBlackDuckServicesFactory(new PrintStreamIntLogger(System.out, com.synopsys.integration.log.LogLevel.INFO))
+ BlackDuckService blackDuckService = blackDuckServicesFactory.createBlackDuckService()
+ ProjectService projectService = blackDuckServicesFactory.createProjectService()
+ ProjectVersionWrapper projectVersionWrapper = projectService.getProjectVersion(project.name, version).get()
+ List<VersionBomComponentView> bomComponents = blackDuckService.getAllResponses(projectVersionWrapper.projectVersionView, ProjectVersionView.COMPONENTS_LINK_RESPONSE)
+ if (bomComponents.isEmpty()) {
+ throw new GradleException("No bom components were found for ${project.name} - ${version}");
+ }
+ bomComponents.each {
+ println "${it.componentName} - ${it.componentVersionName}"
+ }
+ }
+}
