Skip to content

Instantly share code, notes, and snippets.

@HokieGeek
Last active October 25, 2019 13:09
Show Gist options
  • Save HokieGeek/f47083f659c7e7815369e76231aa3a58 to your computer and use it in GitHub Desktop.
Save HokieGeek/f47083f659c7e7815369e76231aa3a58 to your computer and use it in GitHub Desktop.
Gradle dependencies with Lifecycle

Usage

  1. Add these tasks to your build.gradle.
  2. In your Jenkins build, add a shell task which executes the line ./gradlew copyDependencies
  3. Add a Invoke Nexus Policy Evaluation, and from the Advanced options add build/dependencies/**/* to the scan locations
def targetPath = file("$buildDir/dependencies")
task verifyTargetPath {
doLast {
if (!targetPath.exists()) {
mkdir targetPath
}
}
}
task copyCompileDependencies(type: Copy, dependsOn: ['verifyTargetPath']) {
into targetPath
from configurations.compile
}
task copyTestDependencies(type: Copy, dependsOn: ['verifyTargetPath']) {
into targetPath
from configurations.testCompile
}
task copyDependencies(dependsOn: ['copyCompileDependencies', 'copyTestDependencies']) {
println "Copying dependencies to " + targetPath
}
task iqScan(type: JavaExec) {
main = '-jar'
args "<PATH TO JAR>",
'-s', 'http://localhost:8070',
'-i', '<APP NAME>',
'-a', '<IQ USER>:<IQ PASS>',
targetPath
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment