0

So I have a folder that has many jar files. And I have to use these jar files in classpath for java exec task. But it gives me -

What went wrong:
Execution failed for task ':TestProj:runTest'.
 A problem occurred starting process 'command 'C:\Program Files\Java\jdk1.6.0_31\bin\
java.exe''
Caused by: java.io.IOException: CreateProcess error=206, The filename or extension is
too long

I am doing something like

def jarFiles = files { file('testDir').listFiles() }
task runTest(type: JavaExec) {
   main = 'Main'
   classpath = jarFiles 
} 

I've tried to use '/*' in path but gradle throws exception

Could not normalize path for file....

Any workarounds?

Opal
  • 81,889
  • 28
  • 189
  • 210
Aniket Thakur
  • 66,731
  • 38
  • 279
  • 289
  • This is probably not a gradle question but rather Windows-specific problem. Have You already seen this question: http://stackoverflow.com/questions/10519558/createprocess-error-206-the-filename-or-extension-is-too-long-when-running-main ? – Opal Apr 02 '15 at 07:38
  • I also tried this in cygwin. Same error.... – Aniket Thakur Apr 02 '15 at 07:38
  • When I provide path to a folder in javaexec classpath it does not consider all jar files in it. So I have to do listfile and provide each one in the class path which is too large. – Aniket Thakur Apr 02 '15 at 07:40
  • I know that you've tried wildcard but I've prepared demo: https://github.com/Opalo/stackoverflow/tree/master/29407414, could you please clone the repo and execute `gradle runMain`? If it works, that is teh answer. – Opal Apr 02 '15 at 07:53
  • Same thing `Could not determine the dependencies of task ':runMain'. > Could not normalize path for file 'C:\Users\athakur\Desktop\TempDump\stackoverflow\2 9407414\libs\*'.` – Aniket Thakur Apr 02 '15 at 08:44
  • What about `/*` instead of `\*`? – Opal Apr 02 '15 at 08:47
  • Yes your code is exactly the same `classpath = files { project.file('libs/*')`. Since I am using windows it is resolved like that. – Aniket Thakur Apr 02 '15 at 08:51
  • Ok, so with both `\` and `/` it does not work on windows, yes? – Opal Apr 02 '15 at 09:29
  • Nope. Does not work with either. – Aniket Thakur Apr 02 '15 at 17:47

0 Answers0