0

I am developing Eclipse plugin to run Gradle from Eclipse just as an application (using Eclipse LaunchConfiguration). But even after setting JAVA_HOME and GRADLE_HOME for this new process, it finishes with error. Below is what I got by passing additional --debug --stacktrace

So for what file Access is denied and how to discover that?

21:50:18.828 [ERROR] [org.gradle.BuildExceptionReporter] 
21:50:18.828 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
21:50:18.844 [ERROR] [org.gradle.BuildExceptionReporter] 
21:50:18.844 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
21:50:18.844 [ERROR] [org.gradle.BuildExceptionReporter] java.lang.ExceptionInInitializerError (no error message)
21:50:18.844 [ERROR] [org.gradle.BuildExceptionReporter] 
21:50:18.844 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
21:50:18.844 [ERROR] [org.gradle.BuildExceptionReporter] java.lang.ExceptionInInitializerError
21:50:18.844 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.internal.nativeplatform.filesystem.FileSystems.getDefault(FileSystems.java:22)
21:50:18.844 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.initialization.LayoutCommandLineConverter.convert(LayoutCommandLineConverter.java:39)
21:50:18.844 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.cli.BuildActionsFactory.createAction(BuildActionsFactory.java:107)
21:50:18.844 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.createAction(CommandLineActionFactory.java:206)
21:50:18.859 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:196)
21:50:18.859 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
21:50:18.860 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
21:50:18.860 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
21:50:18.860 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
21:50:18.860 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
21:50:18.860 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.Main.doAction(Main.java:46)
21:50:18.860 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
21:50:18.860 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.Main.main(Main.java:37)
21:50:18.860 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
21:50:18.860 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
21:50:18.860 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
21:50:18.860 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.RuntimeException: java.io.IOException: Access denied
21:50:18.860 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.internal.nativeplatform.filesystem.GenericFileSystem.<init>(GenericFileSystem.java:88)
21:50:18.860 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.internal.nativeplatform.filesystem.FileSystems$DefaultFileSystem.<clinit>(FileSystems.java:30)
21:50:18.860 [ERROR] [org.gradle.BuildExceptionReporter]    ... 16 more
21:50:18.860 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.io.IOException: Access denied
21:50:18.860 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.internal.nativeplatform.filesystem.GenericFileSystem.createFile(GenericFileSystem.java:99)
21:50:18.860 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.internal.nativeplatform.filesystem.GenericFileSystem.<init>(GenericFileSystem.java:84)
21:50:18.860 [ERROR] [org.gradle.BuildExceptionReporter]    ... 17 more
21:50:18.860 [ERROR] [org.gradle.BuildExceptionReporter] 

Eclipse is launched with JRE 1.7 on Win32

Gradle 1.10. Of course the same works from command line shell.

Paul Verest
  • 60,022
  • 51
  • 208
  • 332

2 Answers2

2

The way to discover this is to look into the Gradle codebase. The IOException is thrown by the following line:

File file = File.createTempFile("gradle_fs_probing", null, null);

So apparently, the Java process isn't able to create a temporary file. Perhaps this is a file permission issue.

Peter Niederwieser
  • 121,412
  • 21
  • 324
  • 259
  • Thank so much. The effort continues at http://stackoverflow.com/questions/21360995/processes-launched-from-java-with-runtime-getruntime-exec-cant-get-access-t – Paul Verest Jan 26 '14 at 10:15
  • I think you must set the env variable for temp directory. For windows set TEMP and/ TMP variable. – Duff May 29 '18 at 10:18
1

In my case the same problem was caused by not defining the default environment properties (Environment was Eclipse & Windows). Then, gradle is missing some properties e.g. for temp directory.

So this works:

def myenv = [ "JAVA_HOME=./jdk" ]
def env = System.getenv().collect { k, v -> "$k=$v" } + myenv
def proc = "./gradlew".execute(env, new File('.'))

while this might not work

def myenv = [ "JAVA_HOME=.\\jdk" ]
def proc = "./gradlew".execute(myenv, new File('.'))
Harry G.
  • 318
  • 3
  • 9