NPE in OutputDirectoryPropertyAnnotationHandler


(Bryan Helm) #1

Stack trace here: https://gist.github.com/anonymous/9078691

Running an integrationTest task in the root project of a multi-project build, Gradle 1.10 via ‘gradle --stacktrace integrationTest’ in the project root directory. Here is the task definition:

task integrationTest(type: Test) {
    description 'Perform all integration tests'
    group 'verification'
    doLast {
        println 'Integration tests done.'
    }
}
integrationTest.dependsOn {['waitForDeployment',':sub-proj1:integrationTest',':sub-proj2:integrationTest']}
integrationTest.mustRunAfter ear

The tests themselves are in sub-projects and they all run. Debug shows the integrationTest task is completed, but it does not print the expected output.

NPE is at org.gradle.api.internal.project.taskfactory.OutputDirectoryPropertyAnnotationHandler$1.validate(OutputDirectoryPropertyAnnotationHandler.java:46)

I am new to Gradle and love it except when I can’t figure out what is going wrong. I am attempting to convert a complex and ugly ant build. Any clue for me on how to prevent this exception?


(Peter Niederwieser) #2

What are you trying to achieve here? Why do you have a ‘Test’ task in the root project that doesn’t have any tests? This task likely shouldn’t have type ‘Test’. (The exception likely occurs because the task isn’t configured sufficiently.)


(Bryan Helm) #3

Thanks, that is exactly the clue I needed. The sub-project tasks of the same name ARE Test tasks, but the one in the root is there entirely so I can type ‘integrationTest’ on the command line to run integration tests in all sub-projects, and did not need any type to be specified. Removing it fixed the problem. Thanks again!


(Bryan Helm) #4

The NPE is likely the bad default behavior of the foreach loop in Java when the collection is null. It should do nothing, but instead it blows up. Since most people don’t subclass Test with no tests, the check is probably not needed. Of course when it happens to you, you wish there was a check that said “why don’t you have any tests?” instead of NPE.


(Luke Daley) #5

The problem is a bit deeper. Raised GRADLE-3028 for the NPE issue.


(Damien Coraboeuf) #6

Hi,

Is there any workaround the GRADLE-3028 issue?

In our case, we have already the binaries and deployment scripts in Artifactory. We have then a job that deploys on a pooled CI server using the artifacts. Then we want to run some tests that are packaged in a JAR (stored in Artifactory of course).

How do we achieve this? With GRADLE-3028 + GRADLE-2654, it seems we are stuck :frowning:

Damien.