Could not determine the dependencies of task -testone

Viewed 96

I started learning Gradle (Java + Gradle) and created this very basic - build.gralde - file.

task testone(type: Test) {
    println ("Started TestSetUp")
}

In Console when ran command -> gradlew testone -- intellij is throwing error:

> Configure project :
Started TestSetUp

FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':testone'.
2 Answers

I think i can help you with that , By changing the type from Test to Copy , this will build perfectly , Copy is a defined type in gradle and running gradle testone -q will show your output .

I think the problem is with your defined type , by declaring the type as Test you need to add more configuration for this , because the error i got when i tried to register the task like

tasks.register testone(type: Test) {
    println ("Started TestSetUp")
}

was Could not find method testone() for arguments [{type=class org.gradle.api.tasks.testing.Test} so your issue is with the Test type , i spose your missing some extra configuration .

When you’re using a JVM language plugin — such as the Java Plugin — you will automatically get the following:

A dedicated test source set for unit tests

A test task of type Test that runs those unit tests

In "build.gradle", after adding java plugin, the task ran successfully.

plugins {
    id 'java' 
}
task testone(type: Test) {
    println ("Task of type Test Success")
}
Related