From cafa0d657800d51da0e5f68cfcbd791724b457f4 Mon Sep 17 00:00:00 2001 From: Sion Williams Date: Mon, 27 Jul 2015 22:03:19 +0100 Subject: [PATCH 1/2] Integration test spec proves outputDirectory value is not being honoured when changed using dsl. --- dependency-check-gradle/build.gradle | 21 ++++++++++-- ...ependencyCheckGradlePluginIntegSpec.groovy | 34 +++++++++++++++++++ .../src/integTest/resources/outputDir.gradle | 21 ++++++++++++ 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 dependency-check-gradle/src/integTest/groovy/com/tools/security/plugin/DependencyCheckGradlePluginIntegSpec.groovy create mode 100644 dependency-check-gradle/src/integTest/resources/outputDir.gradle diff --git a/dependency-check-gradle/build.gradle b/dependency-check-gradle/build.gradle index f15527be4..2c0d302a9 100644 --- a/dependency-check-gradle/build.gradle +++ b/dependency-check-gradle/build.gradle @@ -27,10 +27,10 @@ buildscript { classpath "com.gradle.publish:plugin-publish-plugin:0.9.0" } } - +/* plugins { id 'nu.studer.plugindev' version '1.0.3' -} +}*/ apply plugin: 'idea' apply plugin: 'groovy' @@ -62,3 +62,20 @@ apply from: 'conf/publish/local.gradle' //apply from: 'conf/publish/maven.gradle' apply from: 'conf/publish/gradlePluginsPortal.gradle' //apply from: 'conf/publish/bintray.gradle' // according to the documentation of plugindev, this line has to be placed and the very end of the build file + +sourceSets { + integTest { + groovy.srcDir file('src/integTest/groovy') + resources.srcDir file('src/integTest/resources') + compileClasspath = sourceSets.main.output + configurations.testRuntime + runtimeClasspath = output + compileClasspath + } +} + +task integTest(type: Test) { + group = 'verification' + testClassesDir = sourceSets.integTest.output.classesDir + classpath = sourceSets.integTest.runtimeClasspath + reports.html.destination = file("$buildDir/reports/integ") + jvmArgs '-XX:MaxPermSize=256m' +} \ No newline at end of file diff --git a/dependency-check-gradle/src/integTest/groovy/com/tools/security/plugin/DependencyCheckGradlePluginIntegSpec.groovy b/dependency-check-gradle/src/integTest/groovy/com/tools/security/plugin/DependencyCheckGradlePluginIntegSpec.groovy new file mode 100644 index 000000000..895571d3c --- /dev/null +++ b/dependency-check-gradle/src/integTest/groovy/com/tools/security/plugin/DependencyCheckGradlePluginIntegSpec.groovy @@ -0,0 +1,34 @@ +package com.tools.security.plugin + +import nebula.test.IntegrationSpec +import nebula.test.functional.ExecutionResult + +/** + * @author Sion Williams + */ +class DependencyCheckGradlePluginIntegSpec extends IntegrationSpec { + def "I can add the plugin to a build with no errors"() { + setup: + buildFile << ''' + apply plugin: 'dependency-check' + '''.stripIndent() + + when: + ExecutionResult result = runTasksSuccessfully('tasks') + + then: + result.standardOutput.contains('dependencyCheck - Produce dependency security report.') + } + + def "I can override outputDir with extension"() { + setup: + writeHelloWorld('com.example') + copyResources('outputDir.gradle', 'build.gradle') + + when: + runTasksSuccessfully('dependencyCheck') + + then: + fileExists('build/dependencyCheckReport') + } +} diff --git a/dependency-check-gradle/src/integTest/resources/outputDir.gradle b/dependency-check-gradle/src/integTest/resources/outputDir.gradle new file mode 100644 index 000000000..8212eeed6 --- /dev/null +++ b/dependency-check-gradle/src/integTest/resources/outputDir.gradle @@ -0,0 +1,21 @@ +/** + * Build file to exercise dependency check + * @author Sion Williams + */ +apply plugin: 'java' +apply plugin: 'dependency-check' + +sourceCompatibility = 1.5 +version = '1.0' + +repositories { + mavenCentral() +} + +dependencies { + compile group: 'commons-collections', name: 'commons-collections', version: '3.2' +} + +dependencyCheck { + outputDirectory = "${buildDir}/dependencyCheckReport" +} \ No newline at end of file From 498835015ae5860c21789da169a8dbbf54a38fe7 Mon Sep 17 00:00:00 2001 From: Sion Williams Date: Mon, 27 Jul 2015 22:33:39 +0100 Subject: [PATCH 2/2] outputDirectory should have been called using the method rather than directly calling the property. This now fixes the failing integration test in the last commit. --- .../groovy/com/tools/security/tasks/DependencyCheckTask.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependency-check-gradle/src/main/groovy/com/tools/security/tasks/DependencyCheckTask.groovy b/dependency-check-gradle/src/main/groovy/com/tools/security/tasks/DependencyCheckTask.groovy index c18cf8c7e..9eb32791a 100644 --- a/dependency-check-gradle/src/main/groovy/com/tools/security/tasks/DependencyCheckTask.groovy +++ b/dependency-check-gradle/src/main/groovy/com/tools/security/tasks/DependencyCheckTask.groovy @@ -100,7 +100,7 @@ class DependencyCheckTask extends DefaultTask { } def generateReportDirectory(String currentProjectName) { - "${outputDirectory}/${currentProjectName}" + "${getOutputDirectory()}/${currentProjectName}" } def overrideProxySetting() {