How to set correct project directory for GradleConnector. It points to ****/daemon/2.0/****

Hello,

I use below code for starting Gradle to run some tests:

ProjectConnection connection = GradleConnector.newConnector()
                .forProjectDirectory(targetDir)
                .useDistribution(new URI("file:///tmp/downloads/gradle-2.0-bin.zip"))
                .connect()
 try {
            connection.newBuild().setStandardOutput(out).forTasks(taskName).run()
           } finally {
            out.close();
            connection.close();
        }

I am wondering how to setup the project directory where GradleConnector points to. I get below exception, because the directory with the build file doesn’t exists. How can I set the path to the the existing build file I have created for the tests? The variable targetDir is set to the correct directory but it seems that GradleConnector don’t use it as it should be. How can I prevent that GradleConnector doesn’t use the “daemon/2.0” directory.

Caused by: org.gradle.api.InvalidUserDataException: Project directory ‘*/daemon/2.0/’ does not exist.

at org.gradle.initialization.ProjectDirectoryProjectSpec.checkPreconditions(ProjectDirectoryProjectSpec.java:53)

at org.gradle.initialization.AbstractProjectSpec.containsProject(AbstractProjectSpec.java:27)

at org.gradle.initialization.SettingsHandler.findAndLoadSettings(SettingsHandler.java:50)

at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:120)

at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:105)

… 44 more

I would be glad, if someone can help me.

Best, Christian

Hey Christian, I can’t reproduce this behaviour. Could you provide a self contained example?

cheers, rené