diff --git a/src/main/groovy/org/jenkinsci/gradle/plugins/jpi/JpiExtension.groovy b/src/main/groovy/org/jenkinsci/gradle/plugins/jpi/JpiExtension.groovy index 848ccadd..5ff7a47e 100644 --- a/src/main/groovy/org/jenkinsci/gradle/plugins/jpi/JpiExtension.groovy +++ b/src/main/groovy/org/jenkinsci/gradle/plugins/jpi/JpiExtension.groovy @@ -211,7 +211,7 @@ class JpiExtension { private File workDir File getWorkDir() { - workDir ?: new File(project.rootDir, 'work') + workDir ?: new File(project.projectDir, 'work') } /** diff --git a/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/JpiExtensionSpec.groovy b/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/JpiExtensionSpec.groovy index b0c3bbea..6e229f37 100644 --- a/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/JpiExtensionSpec.groovy +++ b/src/test/groovy/org/jenkinsci/gradle/plugins/jpi/JpiExtensionSpec.groovy @@ -114,7 +114,18 @@ class JpiExtensionSpec extends Specification { jpiExtension.workDir = null then: - jpiExtension.workDir == new File(project.rootDir, 'work') + jpiExtension.workDir == new File(project.projectDir, 'work') + } + + def 'work directory defaults to work in child project the extension is applied to if not set'() { + when: + Project parent = ProjectBuilder.builder().build() + Project project = ProjectBuilder.builder().withParent(parent).build() + JpiExtension jpiExtension = new JpiExtension(project) + jpiExtension.workDir = null + + then: + jpiExtension.workDir == new File(project.projectDir, 'work') } def 'work directory is used when set'() {