From 7854ee06b57a658b6b06611e97049dae4b89e4ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scheibe?= Date: Wed, 1 Jan 2020 16:01:31 +0100 Subject: [PATCH] Fix generate-test-hpl task dependency for running tests This issue was introduced in commit 7a565d3d51b400e67ce5643e3f71b9113c194296, when lazily registering the task. --- .../org/jenkinsci/gradle/plugins/jpi/JpiPlugin.groovy | 7 +++++-- .../jenkinsci/gradle/plugins/jpi/JpiIntegrationSpec.groovy | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/groovy/org/jenkinsci/gradle/plugins/jpi/JpiPlugin.groovy b/src/main/groovy/org/jenkinsci/gradle/plugins/jpi/JpiPlugin.groovy index eb73ce46..976dbad2 100644 --- a/src/main/groovy/org/jenkinsci/gradle/plugins/jpi/JpiPlugin.groovy +++ b/src/main/groovy/org/jenkinsci/gradle/plugins/jpi/JpiPlugin.groovy @@ -422,10 +422,13 @@ class JpiPlugin implements Plugin { // generate test hpl manifest for the current plugin, to be used during unit test def outputDir = project.layout.buildDirectory.dir('generated-resources/test') - project.tasks.register('generate-test-hpl', GenerateTestHpl) { + testSourceSet.output.dir(outputDir) + + def generateTestHplTask = project.tasks.register('generate-test-hpl', GenerateTestHpl) { it.hplDir.set(outputDir) } - testSourceSet.output.dir(outputDir) + + project.tasks.named(JavaPlugin.TEST_CLASSES_TASK_NAME).configure { it.dependsOn(generateTestHplTask) } } private static void resolvePluginDependencies(Project project) { diff --git a/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/JpiIntegrationSpec.groovy b/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/JpiIntegrationSpec.groovy index aca70047..b62c85a9 100644 --- a/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/JpiIntegrationSpec.groovy +++ b/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/JpiIntegrationSpec.groovy @@ -166,6 +166,7 @@ class JpiIntegrationSpec extends IntegrationSpec { 'processTestResources' | ':resolveTestDependencies' | TaskOutcome.NO_SOURCE 'jpi' | ':war' | TaskOutcome.SUCCESS 'compileTestJava' | ':insertTest' | TaskOutcome.SKIPPED + 'testClasses' | ':generate-test-hpl' | TaskOutcome.SUCCESS 'compileJava' | ':localizer' | TaskOutcome.SUCCESS }